After this question I found that OpenCV gives me this error:
Starting
C:\Users\nikola\Documents\build-ConsoleTry-Desktop_Qt_5_5_0_MSVC2013_64bit-Debug\debug\ConsoleTry.exe...
C:\Users\nikola\Documents\build-ConsoleTry-Desktop_Qt_5_5_0_MSVC2013_64bit-Debug\debug\ConsoleTry.exe exited with code -1073741701
after trying to run this console code:
#include <QCoreApplication>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
using namespace::cv;
using namespace::std;
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
const char* filename = "1-page.png";
// cout << filename << endl;
cout << "111" << endl;
Mat src = imread(filename, 0);
cout << "222" << endl;
return a.exec();
}
How to fix it? I have copied DLL files in the debug directory. In this answer is mentioned the need of conversation of Mat to Qt QImage. Is this the case and are other objects required to be converted?
Result when start .exe from cmd.
Micka is right - it do need highgui, so I have copied all .dll files from D:\opencv_2411\opencv\build\x64\vc12\bin to debug directory. I was having hadeaches because before this I have copied all .dll files from my Visual Studio 2013 project directory, but they were x86, and the QT project is x64. Thank you all!!! And if someone still have problem see this topic too.
Related
I downloaded a webcam_face_pose_ex.cpp file from GitHub and now i want to compile and run it on my mac.
#include <dlib/opencv.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <dlib/image_processing/frontal_face_detector.h>
#include <dlib/image_processing/render_face_detections.h>
#include <dlib/image_processing.h>
#include <dlib/gui_widgets.h>
#include <X11/Xlib.h>
using namespace dlib;
using namespace std;
int main()
{
try
{
cv::VideoCapture cap(0);
if (!cap.isOpened())
{
cerr << "Unable to connect to camera" << endl;
return 1;
}
image_window win;
// Load face detection and pose estimation models.
frontal_face_detector detector = get_frontal_face_detector();
shape_predictor pose_model;
deserialize("shape_predictor_68_face_landmarks.dat") >> pose_model;
// Grab and process frames until the main window is closed by the user.
while(!win.is_closed())
{
// Grab a frame
cv::Mat temp;
if (!cap.read(temp))
{
break;
}
// Turn OpenCV's Mat into something dlib can deal with. Note that this just
// wraps the Mat object, it doesn't copy anything. So cimg is only valid as
// long as temp is valid. Also don't do anything to temp that would cause it
// to reallocate the memory which stores the image as that will make cimg
// contain dangling pointers. This basically means you shouldn't modify temp
// while using cimg.
cv_image<bgr_pixel> cimg(temp);
// Detect faces
std::vector<rectangle> faces = detector(cimg);
// Find the pose of each face.
std::vector<full_object_detection> shapes;
for (unsigned long i = 0; i < faces.size(); ++i)
shapes.push_back(pose_model(cimg, faces[i]));
// Display it all on the screen
win.clear_overlay();
win.set_image(cimg);
win.add_overlay(render_face_detections(shapes));
}
}
catch(serialization_error& e)
{
cout << "You need dlib's default face landmarking model file to run this example." << endl;
cout << "You can get it from the following URL: " << endl;
cout << " http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2" << endl;
cout << endl << e.what() << endl;
}
catch(exception& e)
{
cout << e.what() << endl;
}
}
I tried g++ webcam_face_pose_ex.cpp command but I get:
webcam_face_pose_ex.cpp:30:10: fatal error: 'dlib/opencv.h' file not found
#include <dlib/opencv.h>
^~~~~~~~~~~~~~~
1 error generated.
Was Wondering what I could do to fix this?
The Example File Is Not Meant to be Compiled Using g++
Read the following to learn a bit about the -I flag and #include statements:
The webcam_face_pose_ex.cpp is part of a larger project and you won't be able to compile it on its own because it depends on other files. The #include directive specifies that in order to compile this program, code from the file specified by #includemust be compiled first. This means the entire dlib must be downloaded before compiling webcam_face_pose_ex.cpp. This project also requires opencv2 so we can download it and place the opencv2 folder in the dlib project folder.
Now we can open terminal and change directory into the dlib project folder and compile the file using the following command:
g++ -I. examples/webcam_face_pose_ex.cpp
Note we're specifying the directory of where to find the files specified by #include using the -I parameter as -I. this means to search the current working directory for the files. There it will find the dlib folder and dlib/opencv.h.
How ever, this isn't enough. When you execute the command, you'll encounter an error opencv2/opencv_modules.hpp: No such file or directory.
Solution
The dlib project documentation states that the examples should be built using cmake. Make sure to use cmake to compile the examples.
after google search, I came up with this Solution
g++ finlename.cpp -I{include file directory address} -L{Library file directory address}
-l(linkeroptions)
seems like this doesn't work for me. when I compile using this I get an error stating:- cannot find the headername.h(header file that was included in my program of the external lib).
file:-
#include <iostream>
#include <SDL.h>
using namespace std;
int main(int argc, char* argv)
{
cout << "Hello world!" << endl;
return 0;
}
I am trying to use Gnuplot on Windows with gnuplot_i.hpp. When I type "gnuplot" into cmd everthing works, so the PATH variable should be set correctly. This is my code:
#include <iostream>
#include "gnuplot_i.hpp"
using std::cout;
using std::endl;
int main(int argc, char* argv[]) {
try {
Gnuplot g1("lines");
} catch (GnuplotException ge) {
cout << ge.what() << endl;
}
return 0;
}
The output is Can't find gnuplot neither in PATH nor in "C:/program files/gnuplot/bin" .
When I add the line
Gnuplot::set_GNUPlotPath("C:/gnuplot/bin/");
it just changes to Can't find gnuplot neither in PATH nor in "".
What am I doing wrong here?
Found the answer myself: For some reason gnuplot_i.hpp expects your exe to be called pgnuplot.exe instead of gnuplot.exe ... Now everything works.
I had some Problems to run the following simple code:
http://docs.opencv.org/doc/tutorials/introduction/display_image/display_image.html
System: Windows 7 x64
Microsoft Visual Studio 2013 (free to use)
Project for 32 bit.
I had many various linking error as LNK2001 and LNK2019.
all of it was solved when I added this Libraries under "Configuration Prosperities"> "Linker" > "Input"
Libraries under "Configuration Prosperities"> "Linker" > "Input":
opencv_calib3d300.lib
opencv_core300.lib
opencv_features2d300.lib
opencv_flann300.lib
opencv_hal300.lib
libtiff.lib
libpng.lib
libjpeg.lib
libjasper.lib
IlmImf.lib
zlib.lib
opencv_highgui300.lib
opencv_imgproc300.lib
opencv_imgcodecs300.lib
opencv_ml300.lib
opencv_objdetect300.lib
opencv_photo300.lib
opencv_shape300.lib
opencv_stitching300.lib
opencv_ts300.lib
opencv_video300.lib
opencv_videostab300.lib
ippicvmt.lib
libwebp.lib
I used this code:
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <iostream>
#include <stdlib.h>
#include "stdafx.h"
#include <opencv2/opencv.hpp>
#include <opencv2/shape.hpp>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
if (argc != 2)
{
cout << " Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}
Mat image;
image = imread(argv[1], IMREAD_COLOR); // Read the file
if (!image.data) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl;
return -1;
}
namedWindow("Display window", WINDOW_AUTOSIZE); // Create a window for display.
imshow("Display window", image); // Show our image inside it.
waitKey(0); // Wait for a keystroke in the window
return 0;
}
Hello guys I am developing a simple openCV application with eclipse CDT;
Here is my code
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
using namespace cv;
int main()
{
Mat M(2,2, CV_8UC3, Scalar(0,0,255));
cout << "M = " << endl << " " << M << endl << endl;
return 0;
}
I have built the project and when I try to run, I am getting this error
The program file specified in the launch configuration does not exist
D:\AndroidKeyStore\ExOpen\Debug\ExOpen.exe not found
Assuming the compilation didn't fail, the executable you're building appears to be different from the one you're trying to run in your configuration.
I'm not familiar with Eclipse CDT but you should
go to the Debug Configurations window for your project
select your launch configuration
change the exe you pasted above to the one your project is configured to build (you can find it in the project properties->C/C++ Build->Build directory)