Run OpenCV to MFC
I have reproduced this sample, in a MFC app.
The cv::Mat is a CDOcument variable member:
// Attributes
public:
std::vector<CBlob> m_blobs;
cv::Mat m_Mat;
and I draw rectangles over image, with an method (called at some time intervals, according FPS rate):
DrawBlobInfoOnImage(m_blobs, m_Mat);
Here is the code of this method:
void CMyDoc::DrawBlobInfoOnImage(std::vector<CBlob>& blobs, cv::Mat& Mat)
{
for (unsigned int i = 0;i < blobs.size();++i)
{
if (blobs[i].m_bStillBeingTracked)
{
cv::rectangle(Mat, blobs[i].m_rectCurrentBounding, SCALAR_RED, 2);
double dFontScale = blobs[i].m_dCurrentDiagonalSize / 60.0;
int nFontThickness = (int)roundf(dFontScale * 1.0);
cv::putText(Mat, (LPCTSTR)IntToString(i), blobs[i].m_vecPointCenterPositions.back(), CV_FONT_HERSHEY_SIMPLEX, dFontScale, SCALAR_GREEN, nFontThickness);
}
}
}
but the result of this method is something like that:
My question is: how can I draw only the last blobs result over my image ?
I have tried to clean up m_Mat, and to enable to draw only blobs.size() - 1 blob over image, none of this worked ...
How did you "clean up m_Mat"? What is the code you used? That code probably didn't work correctly. If it is too hard to "undo" a modification (drawing of rectangles), perhaps it is necessary to copy (to create a clone) of the matrix before drawing, using
Mat.clone()
methodDraw the blobs as a dialog,IOW,do not draw in MAT.after all ,you are using MFC
Can you detail a little bit ? These blobs should not be drawn on m_Mat ? But where then ?
P.S. And do you mean with IOW ?
i think ,IOW = in other words