Home > Software engineering >  Apply a opencv graphics recognition case to MFC
Apply a opencv graphics recognition case to MFC

Time:09-24

There is now a use case opencv2 version of the image recognition, because the case is in the console running, now want to run the MFC interface and display, the great god under the guidance of grateful,,,,,

Images of the rectangular graphics to make use of opencv recognition and shear, (download)


Tenet of vs2013 MFC interface (download), a great god look, zha to apply at the top of the case here

Or, literally build a demo of MFC, the application of the case of above go up to also go, strives for the great god,

Thank you very much,,,

In addition, would I have done try to list out the following:




Debugging after the operation, making mistakes and try to slam shut, seek advice,,,

CodePudding user response:

Don't be A language code is modified to B language code busywork,
Also don't use A language code to directly invoke B language code base, this complicated things so easy to get wrong,
Just make A, B language code of input and output is redirected to A text file, or modify A, B language code let it through text file input and output,
Can easily make A, B coordination between the two languages,
For example:
A will request data written to A file a.t xt, renamed after finish aa. TXT
B find aa. TXT, read its contents, call the corresponding function, and writes the results file b.t xt, after finish delete aa. TXT, then b.t xt renamed bb. TXT
Found A bb. TXT, read the content, after finish delete bb. TXT
Above can be replaced by any kind of A language or development environment, B can be replaced by any kind of with the development of A different language or development environment,
Unless A or B does not support to determine whether A file exists, file read and write and file name,
But who can name does not support to determine whether a file exists, file read and write and file name for the development of language or development environment?
Can put the temporary files on the RamDisk efficiency decrease wear disk,
Data structure is very complex, a text file format problems refer to a json or XML

The communication methods between the temporary text file sharing this process there are plenty of advantages, compared to other method only listed below I can think of now:
Loose coupling between process,
Can be on the same machine, process, also can cross machine, across the operating system, hardware platform, and even multinational,
, convenient debugging, and monitoring, only let the third party or artificial view the temporary text files,
Switch, convenient online service, need to delete or create the temporary text files,
, is convenient to realize distributed and load balancing,
Services to provide convenient, queue, queue is full and it is almost impossible to happen (unless the hard disk space full)
DE...

"Across different languages, machine, across the operating system, hardware platform, multinational, cross *. *" misery,
Back is "the use of Shared a plain text file information communication" of the shore!

CodePudding user response:

Opencv use c + + ah, just the case complicated, don't understand how can I call on the MFC, especially defines a structure in the case, don't know how to get completely,,,

CodePudding user response:

1, opencv focused on image processing, image processing algorithms both console and MFC is the same as
2, the use of Mat the default configuration object, its image formats as well as the arrangement of its window bitmap, you can directly copy to a DIB
3, the only difference is OpenCV no 4 byte alignment, and DIB asks to 4 bytes aligned
4, you can also be called directly in MFC applications imshow display directly, just imshow creates a pop-up window

CodePudding user response:

You need is just a drawMattoHdc method, send a online before,
 void MatToCImage (Mat & amp; Mat, CImage & amp; Img) 
{
if (! Mat. Data)
return;
Int nBPP=mat. Channels () * 8;
Img. Destroy ();
Img. Create (mat. Cols, mat. Rows, nBPP);
If (nBPP==8)
{
The static RGBQUAD pRGB [256].
for (int i=0; I & lt; 256; I++)
PRGB [I] rgbBlue=pRGB [I] rgbGreen=pRGB [I] rgbRed=I;
Img. SetColorTable (0, 256, pRGB);
}
Uchar * PSRC=https://bbs.csdn.net/topics/mat.data;
Uchar * PDST=(uchar *) img. GetBits ();
Int imgPitch=img. GetPitch ();
For (int y=0; Y & lt; Mat. Rows; Y++)
{
Memcpy (PDST PSRC, mat, cols * mat in channels ());//mat - & gt; Step is incorrect for those images created by ROI (sub - images!)
PSRC +=mat. Step;
PDST +=imgPitch;
}
}
//use the following:
Mat mt=imread ();
CImage img.
MatToCimage (mt, img);
HBITMAP HBMP=img. Detach ();

CodePudding user response:

@ worldy
Right, the main problem of image recognition is mainly algorithm, but his algorithm, this case can't read, just after the experiment, discover the effect of do you want, just thinking of opportunistic, can try to bring them here to use,

It in the algorithm, defines a structure body Line, and then the methods defined in the application and the structure parameters, under the MFC because didn't before, don't know how to deal with, get the complete case source code to use


@ evionmzs
You put the pictures of the Mat to HDC? I after the image processing using CvvImage class is almost appeared to be effect? Thanks for advice,,,

CodePudding user response:

CodePudding user response:

reference 5 floor Cage_Z reply:
@ evionmzs
You put the pictures of the Mat to HDC? I after the image processing using CvvImage class is almost appeared to be effect? Thank you for advice,,,

Sorry, not very understand your problem, but I think, to integrate the program to the MFC, in addition to the interface display, other method, can use the inside of the opencv function,
I now program, did the same, in addition to the show, with that in the rest of the opencv,
What do you mean, where the algorithm into the inside of the c + + method?

CodePudding user response:

Based on opencv camera collection and the MFC code (GOMFCTemplate2) continuously updated
Write with interface of the image processing program, select the opencv + MFC is a good choice; In terms of camera data read, online a lot of methods, including shiqiyu camerads method is good,
Based on existing data, through the accumulation in the actual projects, I summed up a set of combination of opencv and MFC camera collection framework, has the following characteristics:
1, based on directshow, good compatibility, fast, so far, whether industrial camera or ordinary camera, didn't find incompatible;
Read part 2, the camera by thread, ensure smooth running of the interface;
3, frame after many polishing, has been relatively stable, there will be no exception error; The code simple, convenient and reuse,

CodePudding user response:

I think can be added inside the button event image control and write

CodePudding user response:

refer to the original poster Cage_Z response:
there is now a use case opencv2 version of the image recognition, because the case is in the console running, now want to run the MFC interface and display, the great god under the guidance of grateful,,,,,

Images of the rectangular graphics to make use of opencv recognition and shear, (download)


Tenet of vs2013 MFC interface (download), a great god look, zha to apply at the top of the case here

Or, literally build a demo of MFC, the application of the case of above go up to also go, strives for the great god,

Thank you very much,,,

In addition, would I have done try to list out the following:




Debugging after the operation, making mistakes and try to slam shut, seek advice,,,

You are not a knowledge didn't solved, so all you need is to send a outsourcing, on the CSTO of outsourcing, as if not late last year, you can go to try luck
  • Related