I am using the following code to convert an cv::Mat into dlib array2D (which is required to track objects through dlib correlation tracker)
int main()
{
cv::Mat img = cv::imread("wine_plant.jpg");
dlib::cv_image<dlib::bgr_pixel> dlib_img(img);
return 0;
}
But while debugging I get the following error message.
Error C2440 'initializing': cannot convert from 'const cv::Mat' to 'IplImage' yolo_cywine c:\users\antho\documents\c++\dlib-19.7\source\dlib\opencv\cv_image.h 37
Based on other issues already opened on the same matter, I also tried this
cv::Mat img = cv::imread("wine_plant.jpg");
dlib::cv_image<unsigned char> dlib_img(img);
But same result.
Am I missing something or is there something I am doing wrong? Could you please help me out?
Thanks in advance.
Your dlib version 19.7 seems too old. I also faced similar error on dlib 19.19 downloading from its website. It was fixed on github, but http://dlib.net/ did not contain the fixes when I used it. For me compiling from source solved it. Newer dlib version should fix this error.
These issues discuss this problem,
https://github.com/davisking/dlib/issues/1955
https://github.com/davisking/dlib/issues/1949
https://github.com/davisking/dlib/issues/2071
Changes to cv_image.h,
https://github.com/davisking/dlib/commits/master/dlib/opencv/cv_image.h
https://github.com/davisking/dlib/commit/54a9a5bbf3267386dd39a82fb792bab1bb60796c#diff-7c8f1a39b770981bf2d3a132da6f083b130b7c52cd994dbccb1d2115f0d729fd
https://github.com/davisking/dlib/commit/a4bf6e1e6afef5c55414164dc4414908d91a8be5#diff-7c8f1a39b770981bf2d3a132da6f083b130b7c52cd994dbccb1d2115f0d729fd
Related
I am trying a code from tutorial to test the marker-less AR experience with OpenCV + OpenGL. But the problem is that when I compiled the code I found out that there is an error with the following segment of code:
cv::Ptr<cv::DescriptorExtractor> extractor = cv::FREAK(false, false),
and the error is:
FREAK is not a member of cv.
So, can someone tell me why is that happening? I have tried to search for a solution and tried to solve as much as I can but every time I got error.
Does anyone have solution for this problem:
Ptr<SURF> detector = SURF::create(minHessian);
std::vector<KeyPoint> keypoints_object;
detector->detect( inImage, keypoints_object );
It gives me Unhandeled exeption error while going throu detect function. I have linked the xfeatures2d module and included it into file, also I included nonfree.hpp, which is part of xfeatures2d. In earlier versions, this problem was solved using initModule_nonfree(), I think, but here, this function do not exist. Thanks in advance.
A very simple question...why am I getting a read access violation error with this code?
cv::Mat laserSpeckle = Mat::zeros(100,100,CV_8UC1);
imwrite( "C://testimage.jpg", laserSpeckle );
When i attach a debugger and look into it further, it throws the exception at this snippet in grfmt.cpp.
if( params[i] == CV_IMWRITE_JPEG_QUALITY )
{
quality = params[i+1];
quality = MIN(MAX(quality, 0), 100);
}
It occurs with .png and .tiff too. Im an OpenCV newbie, my apologies if this is something really simple. I am using Qt for what its worth.
Do you build OpenCV yourself? If yes, make sure that the option WITH_JPEG is enabled when you configure your build files:
cmake ... -DWITH_JPEG=ON ...
If you want to save image with alpha channel you should use png format. It is described here
It should work with bmp format:
cv::Mat laserSpeckle = cv::Mat::zeros(100,100,CV_8UC1);
cv::imwrite( "C://testimage.bmp", laserSpeckle );
Your code also works on my computer. However, it seems that on some systems it works only for bmp images. I saw similar issues reported here and here.
The problem is with the debugger version (x64) if you build the code using the release version (x64) it works fine for me.
In my case c++ Code Generation settings were wrong
Should have been Multithreaded DEBUG dll MD
I was trying to update OpenCV (to 2.4.9) when I ran into a problem. I cannot find the file that defines "MatND_". In the old version of OpenCV it was in cxcore.cpp. I searched through google, the CV documentation and the new OpenCV library and found a lot of information regarding MatND but nothing relevant about MatND_. Does anyone know where I can find it? Thank you for your time.
Which version of OpenCV was "the old version". Even in 2.2 cxcore.hpp had comments about being deprecated and did not have MatND_. ?
If MatND_ is to MatND as Mat_ is to Mat, you may be able to just use aMat_`
MatND is declared in opencv2/core/core.hpp:
typedef Mat MatND;
I'm trying to compile some OpenCV code without success. So please if you can help me It would be really nice.
This is the code:
cv::Vec3b c = my_cv_mat.at<cv::Vec3b>(i, j) / interval;
cv::Vec3b t = another_cv_mat.at<cv::Vec3b>(i, j) / interval;
The error is:
Invalid operands to binary expression ('cv::Vec<unsigned char,3>' and 'int')
One thing to note is that I am compiling an iOS app with OpenCV support.Any ideas how can I fix this?. I already checked the source code and it's exactly the same as other projects which are working fine.
Thanks a lot.
Is your my_cv_mat and your another_cv_mat an image with three channels? If it is not your code will probably result in an error or return bogus values. You are probably using a grayscale or binary image. In that case use cv::uchar in stead of cv::Vec3b.