I have some problem with cv::Mat object. Output of the below code was wrong
void processFrame(const cv::Mat image, MyTracker& t)
{
//some code
}
void main()
{
MyTracker t;
cv::VideoCapture(0);
cv::Mat im , im_gray;
while (true)
{
cap >> im;
cv::cvtColor(im, im_gray, CV_BGR2GRAY);
processFrame(im_gray,t);
cv::Rect r = t.bb_rot.boundingRect(); // get last bounding box of tracker
std::cout<<r.x<<"\t"<<r.y<<"\t"<<r.width<<"\t<<r.height;
}
}
But when i use processFrame(im_gray.clone(),t);
instead, solved the problem and result is correct.
What is the problem that clone()
function can solved this , however the first parameter of processFrame
is const cv::Mat image
and can't change in ProcessFrame
.
I think image
object will change in processFrame
function