OpenCv: Application hangs when rotating an image in a for loop
-
15-06-2021 - |
Question
The following code gives seg fault and some time stalls/hangs and never works.
for(i=0;i<360;i++)
{
CVrotate(image, i); //i is angle
display("image" in some window);
}
but the following work very well.
for(i=0;i<360;i++)
{
CVrotate(image, i); //i is angle
waitkey(10);
display("image" in some window);
}
Cvrotate is a function that is rotating an image, and the rotated image is being displayed by the opencv function for displaying.
Why is waitkey(); needed here? I understand that the display should be called only after CVrotate is done with its job. Similarly, I am assuming that the next iteration starts when the display is over and not before that. Please enlighten me.
Solution
What does OpenCV's cvWaitKey( ) function do? this link clears all the misconceptions regarding the cvWaitkey and its uses .Hope this is useful for you. cvWaitKey's main function is to pause the code for a while.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow