Reputation: 781
I am recording a video footage and preforming various image processing methods on each frame to obtain desired result.
Now once I get the result I am looking for i want to capture and store a particular frame on my hdd.
To do this I am using imwrite function to write the frame as a jpg. then I use imshow to display this frame in a namesWindow.
The problem is that when all the conditions are meet to store the image my program instead of storing the image, gives me a run time error.......
Here is the code:
for(vector<double>::iterator iter_dis = Left_Point_distance.begin(); iter_dis != Left_Point_distance.end();++iter_dis)
{
if(*iter_dis > 20 && center.y >= 120 && center.x >=510 && Box[0].width > Box[0].height)
{
char* window_Punches = "Punches";
namedWindow(window_Punches ,1);
Mat Hook;
imwrite("C:\\Hook.jpg", Hook);
imshow(window_Punches, Hook);
}
if(*iter_dis >20 && center.y <=60)
{
}
}
Going through opencv tutorials This is how this how its done but in my case is not working......
Further more all the process takes place in a infinite while loop, and videoframes are stored in Mat frame; which is then displayed in a window using imshow function.
Can anybody spot what am doing wrong here....?
Upvotes: 0
Views: 373
Reputation: 52337
What do you expect from this code:
Mat Hook;
imwrite("C:\\Hook.jpg", Hook);
imshow(window_Punches, Hook);
You create an empty matrix and use it.
Upvotes: 0
Reputation: 7919
You define Mat Hook but it is empty while trying to write with imwrite()
Upvotes: 3