简体   繁体   English

Opencv 调整大小取消/停止

[英]Opencv Resize Cancel/Stop

Can you cancel/stop a resize function?您可以取消/停止调整 function 的大小吗? Say if it is resizing an image for 4 seconds and I would like to cancel it after 2 seconds (timing does not matter) because I do not want to resize this particular image, is there a method of doing so?假设它正在调整图像大小 4 秒,我想在 2 秒后取消它(时间无关紧要),因为我不想调整这个特定图像的大小,有没有这样做的方法?

cvResize(srcImg, dstImg, CV_INTER_AREA);   //Cancel this function

If you're on a platform that supports POSIX threads, you could start a new thread to perform the cvResize operation, then use pthread_cancel if you need to stop it before it runs to completion.如果您在支持 POSIX 线程的平台上,您可以启动一个新线程来执行cvResize操作,然后如果您需要在它运行完成之前停止它,请使用pthread_cancel There's nothing built into standard C++ or OpenCV to do what you're asking.标准 C++ 或 OpenCV 中没有内置任何内容来满足您的要求。

What @Jim says is the way to go. @Jim 说的是通往 go 的方法。 But another approach that might work for you is simply to check the size of the image before executing cvResize() .但是另一种可能对您有用的方法是在执行cvResize()之前检查图像的大小。 You probably know which image takes 4 seconds to process, so what you can do is always check the size of the image and if it's too big , you just don't call cvResize() .您可能知道处理哪个图像需要 4 秒,所以您可以做的是始终检查图像的大小,如果它太大,您就不要调用cvResize()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM