OpenCV Cannot find MatND_ - c++

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;

Related

Cannot convert OpenCV Mat to dlib arrray2D

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

OpenCV 3.1. SURF and SIFT C++

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.

How it should code in OpenCV 2.4 or OpenCV 3.0

I want to change this lines of code it original coded in opecv2.3 version
Ptr<DescriptorExtractor > extractor(new SurfDescriptorExtractor());// extractor;
new OpponentColorDescriptorExtractor(
Ptr<DescriptorExtractor>(new SiftDescriptorExtractor())
)
);
convert to openCV2.4 or OpenCV3.0.
Is anyone understand how i should code this ? Appreciated if you can share your guide. Thanks

OpenCV imwrite params read access violation

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

Opencv Mosaic from video

I need to do the same thing of this video https://youtu.be/59RJeLlDAxQ but in Opencv. For now I'm doing this thing http://ramsrigoutham.com/2012/11/22/panorama-image-stitching-in-opencv/ with a little modify in the final image merging, but it doesn't work very well. How can I proceed?
EDIT
For testing I'm using the video lab from this page http://www.cs.ucsb.edu/~holl/CS290I/Assignments/Assignments-3/Assignment3Mosaicing.html
I ran my code on that video and I obtain this:
It's not very accurate but its ok.If I let the program run, at a certain point my stitcher produce this:
.
For the stitching ROIs instead of the ramsrigoutham.com ones I'm using this:
warpPerspective(current_frame, rImg, H, Size(current_frame.cols, current_frame.rows), INTER_NEAREST);
Mat roi1(final_img, Rect(img_loop.cols, img_loop.rows, vImg[1].cols, vImg[1].rows));
Mat roi2(final_img, Rect(img_loop.cols, img_loop.rows, rImg.cols, rImg.rows));
rImg.copyTo(roi2);
vImg[1].copyTo(roi1);
Why not using: http://docs.opencv.org/modules/stitching/doc/high_level.html#stitcher-composepanorama
It's available on 2.4.11 and 3.0.0.
The link you mentioned is access deniedhttp://www.cs.ucsb.edu/~holl/CS290I/Assignments/Assignments-3/Assignment3Mosaicing.html
.
what are 'img_loop' and 'Vimg' and 'rimg' in your code? there is some difference between your code and the code you linked.if it is possible explain a little so I can work on your problem , cause Im doing the same thing in opencv