Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to replace argc and argv to execute in visual studio 2015??

I am using opencv 3.1 under windows 10 OS 64 bit, Visual studios 2015 in the debug mode 64 i am getting an error "The program '[20572] learning.exe' has exited with code -1073741510 (0xc000013a)." where here learning.exe is the name of my project. I understnad that i m getting this error due to return of -1 from the function parseCmdArgs(int argc, char** argv). I also understand that argc takes argument or the file name say "stitching.cpp" and "argv" takes in the img in linux compiler when executing the command but my question is how to i alter it so that i can get the result of stitched image. Here is my code which is given in OPENCV samples section

include <iostream>

include <fstream>

include "opencv2/imgcodecs.hpp"

include "opencv2/highgui.hpp"

include "opencv2/stitching.hpp"

using namespace std; using namespace cv;

bool try_use_gpu = false; //bool type variable vector<mat> imgs; //image data type string result_name = "result.jpg"; //string datatype

void printUsage(); // list of instructions int parseCmdArgs(int argc, char** argv);

int main(int argc, char* argv[]) { int retval = parseCmdArgs(argc, argv); if (retval) return -1;

Mat pano;
Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
Stitcher::Status status = stitcher.stitch(imgs, pano);
cout<<"hello";
if (status != Stitcher::OK)
{
    cout << "Can't stitch images, error code = " << int(status) << endl;
    return -1;
}

imwrite(result_name, pano);
getchar(); getchar();
return 0;

}

void printUsage() { cout << "Rotation model images stitcher.\n\n" "stitching img1 img2 [...imgN]\n\n" "Flags:\n" " --try_use_gpu (yes|no)\n" " Try to use GPU. The default value is 'no'. All default values\n" " are for CPU mode.\n" " --output <result_img>\n" " The default is 'result.jpg'.\n"; }

int parseCmdArgs(int argc, char** argv) { if (argc == 1) { printUsage(); return -1; } for (int i = 1; i < argc; ++i) { if (string(argv[i]) == "--help" || string(argv[i]) == "/?") { printUsage(); return -1; } else if (string(argv[i]) == "--try_use_gpu") { if (string(argv[i + 1]) == "no") try_use_gpu = false; else if (string(argv[i + 1]) == "yes") try_use_gpu = true; else { cout << "Bad --try_use_gpu flag value\n"; return -1; } i++; } else if (string(argv[i]) == "--output") { result_name = argv[i + 1]; i++; } else { Mat img = imread(argv[i]); if (img.empty()) { cout << "Can't read image '" << argv[i] << "'\n"; return -1; } imgs.push_back(img); } } return 0; }

Here is the debug list

VIDEOINPUT LIBRARY - 0.1995 - TFW07

The thread 0x2af4 has exited with code -1 (0xffffffff). The thread 0x5138 has exited with code -1 (0xffffffff). The thread 0xd8 has exited with code -1 (0xffffffff). The program '[23492] learning.exe' has exited with code -1 (0xffffffff).

Build was succeded

How to replace argc and argv to execute in visual studio 2015??

I am using opencv 3.1 under windows 10 OS 64 bit, Visual studios 2015 in the debug mode 64 i am getting an error "The program '[20572] learning.exe' has exited with code -1073741510 (0xc000013a)." where here learning.exe is the name of my project. I understnad that i m getting this error due to return of -1 from the function parseCmdArgs(int argc, char** argv). I also understand that argc takes argument or the file name say "stitching.cpp" and "argv" takes in the img in linux compiler when executing the command but my question is how to i alter it so that i can get the result of stitched image. Here is my code which is given in OPENCV samples section

include <iostream>

include <fstream>

include "opencv2/imgcodecs.hpp"

include "opencv2/highgui.hpp"

include "opencv2/stitching.hpp"

#include <iostream>
#include <fstream>
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/stitching.hpp"

using namespace std;
using namespace cv;

cv; bool try_use_gpu = false; //bool type variable vector<mat> vector<Mat> imgs; //image data type string result_name = "result.jpg"; //string datatype

datatype void printUsage(); // list of instructions int parseCmdArgs(int argc, char** argv);

int main(int argc, char* argv[]) { int retval = parseCmdArgs(argc, argv); if (retval) return -1;

-1;
Mat pano;
 Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
 Stitcher::Status status = stitcher.stitch(imgs, pano);
 cout<<"hello";
 if (status != Stitcher::OK)
{
 {
 cout << "Can't stitch images, error code = " << int(status) << endl;
 return -1;
}
 }
imwrite(result_name, pano);
 getchar(); getchar();
 return 0;

}

} void printUsage() { cout << "Rotation model images stitcher.\n\n" "stitching img1 img2 [...imgN]\n\n" "Flags:\n" " --try_use_gpu (yes|no)\n" " Try to use GPU. The default value is 'no'. All default values\n" " are for CPU mode.\n" " --output <result_img>\n" " The default is 'result.jpg'.\n"; }

} int parseCmdArgs(int argc, char** argv) { if (argc == 1) { printUsage(); return -1; } for (int i = 1; i < argc; ++i) { if (string(argv[i]) == "--help" || string(argv[i]) == "/?") { printUsage(); return -1; } else if (string(argv[i]) == "--try_use_gpu") { if (string(argv[i + 1]) == "no") try_use_gpu = false; else if (string(argv[i + 1]) == "yes") try_use_gpu = true; else { cout << "Bad --try_use_gpu flag value\n"; return -1; } i++; } else if (string(argv[i]) == "--output") { result_name = argv[i + 1]; i++; } else { Mat img = imread(argv[i]); if (img.empty()) { cout << "Can't read image '" << argv[i] << "'\n"; return -1; } imgs.push_back(img); } } return 0; }

}

Here is the debug list

VIDEOINPUT LIBRARY - 0.1995 - TFW07

The thread 0x2af4 has exited with code -1 (0xffffffff). The thread 0x5138 has exited with code -1 (0xffffffff). The thread 0xd8 has exited with code -1 (0xffffffff). The program '[23492] learning.exe' has exited with code -1 (0xffffffff).

Build was succeded