c++ - OpenCv, get image information -
i playing around open source opencv application. provided image sets, works great, when attempt pass live camera stream, or recorded frames camera stream, crashes. assume cv::mat type, differing image channels, or conversion not doing.
the provided dataset grey-scale, 8 bit, , images. application expects grayscale (cv_8u).
my question is:
given 1 of (working) provided images, , 1 of recorded (not working) images, best way compare them using opencv, find out difference might causing crashes?
thank you.
i have tried:
commenting out code (which gave assertion errors)
if(mimgray.channels()==3) { cvtcolor(mimgray,mimgray,cv_bgr2gray); cvtcolor(imgrayright,imgrayright,cv_bgr2gray); } else if(mimgray.channels()==4) { cvtcolor(mimgray,mimgray,cv_bgra2gray); cvtcolor(imgrayright,imgrayright,cv_bgra2gray); }
and replacing with:
cv::mat templ; mimgray.convertto(templ, cv_8u); cvtcolor(templ, mimgray, cv_bayergr2bgr); cvtcolor(mimgray, mimgray, cv_bgr2gray);
and program crashes no error...
you can try code:
if ( mimgray.depth() != cv_8u ) mimgray.convertto(mimgray, cv_8u); if (mimgray.channels() == 3 ) { cvtcolor(mimgray, mimgray, color_bgr2gray); }
or can define new mat create function , use that.
Comments
Post a Comment