Opencv Error: Assertion Failed on iOS

OpenCV error: Assertion failed on iOS

I don't know how do cv::Mat objects look in objective c, but You need to make sure that all the dimensions, channel number and depth of images used with the classifier are uniform. Probably there was a step previously when You fed the classifier with training images. Maybe one of them is not compatible with the mat that You are trying to classify.

You can try debugging with opencv if You compile it Yourself and set debug version in CMake.

cv::HoughLines on iOS fails with 'OpenCV Error: Assertion failed'

The docs are pretty much clear about this:

void HoughLines(Mat& image, vector<Vec2f>& lines, double rho, double theta, int threshold, double srn=0, double stn=0)

That said, you need to change the parameter type to std::vector<cv::Vec2f>:

std::vector<cv::Vec2f> lines;
cv::HoughLines(outputImage, lines, 1, CV_PI/180, 100);

If you have any more problems try to look for examples that use this function, like the FiducialDetector.

iOS & OpenCV Error: Assertion Failed in PhaseCorrelateRes

Nevermind, this was actually caused by the fact that the UIImage has 3 channels in the first place. When converted into Mat and to CV_32F type, the resulting Mat was actually of type CV_32FC3 (3 channels); Therefore an error occurred as the parameter type did not match.

My solution is to split the original Mat into array of channels, then pass ONE channel only to the phaseCorrelate function:

vector<Mat> refChannels;
split(refMatImage, refChannels);
phaseCorrelate(refChannels[0],...);

OpenCV on iOS simple stitching example fails with resize error

I have discovered the cause of the problem. My code to create the stitcher object is apparently faulty, and is presumably a result of inappropriately mixing Objective-C object pointer with C++ Ptr.

Stitcher *stitcher = Stitcher::create(mode); // INCORRECT

cv::Ptr<Stitcher> stitcher = Stitcher::create(mode); // CORRECT

By making the incorrect call, a usable stitcher object was created, but its internal storage (and hence all its initial default settings) were all nil/zero values. Due to these incorrect default values, the subsequent call to stitch was failing.

Once the object was correctly created, the stitching executed successfully.

openCV Error: Assertion failed (scn == 3 || scn == 4)

You need to check your frame is empty or not after each query

Like

   frame=cvQueryFrame(capture);
if (frame.empty()) break;

You are getting such an error because you are trying to convert an empty Mat to grayscale after last frame, so exit the loop if frame is empty.

OpenCV VideoWriter issue crashing on iOS - info.backendFactory.empty() in function 'open'

I figured it out. For iOS, looks like you need force the Backend used for video writing. Therefore, using

videoWriter.open(
outputFilePath.UTF8String,
cv::CAP_AVFOUNDATION,
cv::VideoWriter::fourcc('M', 'J', 'P', 'G'),
15,
cv::Size(1920, 1080)
);

Worked for me. Relevant here is the cv::CAP_AVFOUNDATION api attribute



Related Topics



Leave a reply



Submit