I have been attempting to use OpenCV together with Tesseract to produce some manner of Label reader. 'resize' under the cv namespace has however refused to cooperate and produces an erroneous image with a red cross much like a union jack. Here is the (most likely) offending piece(s) of code;
cv::VideoCapture capture;
cv::Mat CVImg;
if ( !capture.open(CV_CAP_ANY) )
{
//TODO
return;
}
if (!IsIconic((HWND)this->Handle.ToInt32()))
{
if (!capture.read(CVImg))
{
//TODO
return;
}
cv::Mat CVNewImg (pictureBox1->Width, pictureBox1->Height, CVImg.type());
cv::resize(CVImg,CVNewImg, CVNewImg.size(), 0, 0, CV_INTER_LINEAR); //Problematic
displayMat(CVNewImg);
}
void displayMat (cv::Mat DSPIMG)
{
this->pictureBox1->Image=(gcnew System::Drawing::Bitmap(
DSPIMG.size().width,
DSPIMG.size().height,
DSPIMG.size().height * 4,
System::Drawing::Imaging::PixelFormat::Format24bppRgb,
(System::IntPtr)DSPIMG.data));
}
This is in windows MFC, so forgive me if I do not wish to cover an entire page with all the junk code. If this is something very simple that I have overlooked I would very much appreciate it if you in your superior wisdom could enlighten me, perhaps I have completely misinterpreted the correct use of the function. In short: It is very possible I am being a complete moron, alas my sleep has been rather lacking as I am under a lot of pressure time-wise.
I can parse the original CVImg to displayMat and it will display properly, save for not actually adjusting to the size of the picturebox of course. However not so with CVNewImg, producing the aforementioned symbol of britland.