Trying to make a hello-world style opencv program, but fails to compile if I don't include highgui.hpp, yet fails to link if I do include it.
For example, when I include that header, the linker complains:
undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&
#include <opencv2/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <iostream>
using namespace std;
using namespace cv;
int main(int argc, char *args[])
{
Mat &frame;
Mat grayscale;
CascadeClassifier &face_cascade;
vector<cv::Rect> &faces;
VideoCapture *capture;
...
If I don't include highgui.hpp, then it doesn't compile due to errors like:
'VideoCapture’ was not declared in this scope
I'm using pyimagesearch's vagrant based ubuntu virtual machine that comes with cv2 installed. The cv2 Python scripts work fine, but just not the c++
Related
#include <iostream>
#include <opencv2/opencv.hpp>
#include <string>
#include <tesseract/baseapi.h>
using namespace std;
using namespace cv;
int main() {
string text;
Mat im;
tesseract::TessBaseAPI* ocr = new tesseract::TessBaseAPI();
return 0;
}
This gives me the error unresolved external symbol in TessBaseAPI. My tesseract should be properly downloaded, in command prompt, "tesseract --version" says I'm using version 5.0, its added to my path. I also tried following this https://github.com/vtempest/tesseract-ocr-sample which didn't work and gave me the linker error.
I wrote a very simple program with opencv
and I get this problem ( I'm using TDM-GCC x64 compiler)
cannot find c:/opencv/opencv2/build/x64/lib permission denied
#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 image =imread("An0nymOu5.jpg");
namedWindow("image",cv::WINDOW_FREERATIO);
imshow("image",image);
waitKey(0);
}
Could be a compiler error; you can try in this link to find the toolchain
mingw-w64
Also assure the image file is near your program file.
try this aswell.
Mat image;
image = imread("An0nymOu5.jpg", CV_LOAD_IMAGE_COLOR);
I try to compile Qt project using dlib
#include <dlib/image_processing/frontal_face_detector.h>
#include <dlib/dnn.h>
#include <dlib/gui_widgets.h>
#include <dlib/clustering.h>
#include <dlib/string.h>
#include <dlib/image_io.h>
#include <iostream>
using namespace cv;
using namespace dlib;
using namespace std;
int main(int argc, char *argv[])
{
frontal_face_detector detector = get_frontal_face_detector();
matrix <rgb_pixel> image;
load_image(image, "/Users/ivanlebedev/Desktop/Projects/ManSearch/cars/2.jpg");
image_window win(image);
}
but i have this ERROR:
/usr/local/Cellar/dlib/19.15/include/dlib/gui_core/gui_core_kernel_2.h:12: ошибка: "Also make sure you have libx11-dev installed on your system"
#error "Also make sure you have libx11-dev installed on your system"
^
How i can make my program work?
You don't need nor want x11-anything. You need to compile dlib without x11 support, and then it'll work fine.
I'm new to opencv library and every time i try to compile This code
#include "opencv2/core.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgcodecs.hpp"
using namespace cv;
using namespace std;
int main()
{
Mat img;
img = imread("lena.jpg");
imshow("Original Image", img);
waitKey();
}
I get This error undefined reference to `__atomic_fetch_add_4
This code is copied from a tutorial and It's was working with its writer so the problem is definitely with me
I looked for a solution for this problem to much and I did not found any working solution, I do not even no what is the cause of the problem
I'm using Code::Blocks IDE
Thanks,
Go to Setting>Compiler Settings and tick the Intel i486 option. It worked for me
I try to use OpenCV C Api in my code. I have opencv and opencv2 folder under usr/include. I can use OpenCV C++ Api. C++ code and compilation&linking commands are below :
#include <iostream>
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/opencv.hpp"
using namespace cv;
int main()
{
Mat im = imread("Sobel.jpg");
return 0;
}
Compile : g++ -c main.cpp
Linking : g++ -o exe main.opkg-config --libs opencv`
Now I want to use OpenCV C-Api. My code is here :
#include <iostream>
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/opencv.hpp"
using namespace cv;
int main()
{
IplImage* pImg = CvLoadImage("Sobel.jpg");
if(pImg == NULL)
return -1;
// ... big bloat to do the same operations with IplImage
CvShowImage("Image", pImg);
cvWaitKey();
CvReleaseImage(&pImg); // Do not forget to release memory.
// end code here
return 0;
}
When I compile g++ -c main.cpp, the compiler says that ‘CvLoadImage’ was not declared in this scope
A simple spelling mistake, the function prototype is
IplImage* cvLoadImage( const char* filename, int iscolor=CV_LOAD_IMAGE_COLOR );