I use VideoWriter::write to wrote a Mat with the pixel format of CV_32FC3,but it would always cause an error when VideoWriter::write was called.
Then i found that any pixel format of CV_8UC* would always succeed.
But Why?
Error Msg Was:
OpenCV(4.2.0) Error: Assertion failed (!fixedType() || ((Mat*)obj)->type() == mtype) in cv::debug_build_guard::_OutputArray::create, file C:\build\master_winpack-build-win64-vc15\opencv\modules\core\src\matrix_wrap.cpp, line 1195
Any answer will be helpful
video is simply not stored at such high colour depths
Quoted From #MarkSetchell
Related
I am getting Corrupt JPEG data: 1 extraneous bytes before marker 0xd3 error while using functions of opencv as mentioned in the code section. I am running this code using python3 in Raspberry Pi 3.
I found that manually updating the kernel resolve this issue in some cases and would like to know how to update it.
video = cv2.VideoCapture(0)
ret, frame=video.read()
if ret == True:
cv2.imwrite(str(time.time()) + '.jpg',frame)
Kindly guide about ways to remove this error.
While trying this command:
kvazaar -i video.yuv --input-res 1280x720 -o video_tiled.hevc --roi roi.txt --slices tiles
I get this error:
Reading ROI file failed.
invalid argument: roi=roi.txt
Any ideas?
Thanks!
Your roi.txt file must be incomplete and inadequate to the specified size.
About the roi.txt file:
(...) the first two values are the width and height, followed by
width*height delta QP values in raster order.
Here is a link to the source code giving the error: [ https://github.com/ultravideo/kvazaar/blob/f8c5bb18a4604175f20dea673d14ca66257ac0c0/src/cfg.c#L1103 ]
I am using the BackgroundsubtractorMOG() to basically extract a mask to separate out the foreground. I am then using convexHull() on the mask to locate the position of a moving object.
But i am getting the following error:
openCV Error: Assertion failed (nelems >= 0 && (depth == CV_32F || depth == CV_32S)) in convexHull, file /home/ameya/OpenCV2.4.2/modules/imgproc/src/contours.cpp, line 1947
terminate called after throwing an instance of 'cv::Exception'
what(): /home/ameya/OpenCV2.4.2/modules/imgproc/src/contours.cpp:1947: error: (-215) nelems >= 0 && (depth == CV_32F || depth == CV_32S) in function convexHull
I have checked the no. of elements as well as type-casted the mask matrix. But the error still persists.
Has anyone encountered a similar problem before. I am using OpenCV 2.4.2
Use this format, it will help (notice typecasting to Mat):
convexhull(Mat(inputarray),hull,0,0)
are you calling convexhull on your mask image there ?
it's supposed to work with point2d(or index) vectors, eg. from findContours()
I need to resize an IplImage and convert it into a CvMat of different depth, this is the code I've written so far:
void cvResize2(IplImage *imgSrc, IplImage *imgDst)
{
IplImage *imgTemp;
imgTemp = cvCreateImage( cvGetSize( imgSrc ), IPL_DEPTH_64F, 1 );
cvScale( imgSrc, imgTemp, 1/255., 0.0 );
cvResize( imgTemp, imgDst );
}
The source image is grayscale, the destination one is 64F bit deep. cvScale only scales between images of same size, hence the temp image.
The program rises the following exception when invoking cvResize:
OpenCV Error: Assertion failed (func != 0) in resize, file /tmp/buildd/opencv-2.1.0/src/cv/cvimgwarp.cpp, line 1488
terminate called after throwing an instance of 'cv::Exception'
what(): /tmp/buildd/opencv-2.1.0/src/cv/cvimgwarp.cpp:1488: error: (-215) func != 0 in function resize
I can't figure out why, I've checked that the images respect the conditions imposed
src: 512x384, 8 depth
tmp: 512x384, 64 depth
dst: 64x64, 64 depth
Any clues?
Thanks in advance
You may have found a bug. I can reproduce it on my end, too (Ubuntu 64-bit, OpenCV-2.1.0). If you use 32-bit floating point precision, it works, but crashes with 64-bit floats. My recommendation is to update your OpenCV to the most recent version and see if the problem goes away. If not, then build the library in debug mode and step through the function that is throwing the assertion. From looking at the culprit source in cvimgwarp.cpp, it looks like it's unable to find an interpolation method to use for the destination image.
I'm trying to implement the fourier transformation in frequency domain.
I used getOptimalDFTSize accordingly, and I copied the image and mask, in bigger images, suitable for fourier transformation. I used the sample code from here as a reference.
Now, I have to separate the real and imaginary part, and to perform pixelwise multiplication of the image imaginary part with the mask imaginary part, and the same for the real part.But when I try to do so, I get the following error message:
OpenCV Error: Assertion failed (type == srcB.type() && srcA.size() == srcB.size()) in mulSpectrums, file /build/buildd/opencv-2.1.0/src/cxcore/cxdxt.cpp, line 1855
/build/buildd/opencv-2.1.0/src/cxcore/cxdxt.cpp:1855: error: (-215) type == srcB.type() && srcA.size() == srcB.size() in function mulSpectrums
The code is following:
//fourier transfromation of real and imaginary part
Mat complex_image, real_image, complex_mask, real_mask;
cv::dft(new_image, complex_image, DFT_COMPLEX_OUTPUT);
cv::dft(new_image, real_image, DFT_REAL_OUTPUT);
cv::dft(new_mask, complex_mask, DFT_COMPLEX_OUTPUT);
cv::dft(new_mask, real_mask, DFT_REAL_OUTPUT);
//pixelwise multiplication
Mat multiplied_complex, multiplied_real;
cv::mulSpectrums(complex_image, complex_mask, multiplied_complex, DFT_COMPLEX_OUTPUT );
cv::mulSpectrums(real_image, real_mask, multiplied_real, DFT_REAL_OUTPUT);
What am I doing wrong here?
Image and mask should have same size (width and height) and (most probably this is problem) type. So if it is different type you need to convert one of them so they have equal type.