I am using an OpenCV function in a compiled library on Android. It regularly runs for more than 10 seconds until it fails. A success will take approximately 2 seconds. I want to be able to interrupt the function if it takes more than 2 seconds.
At first, I tried using a thread and interrupting it after 2 seconds, but I realized after awhile that the function itself has to cooperate with the interrupt in order for it to work.
Is there any way to do this without modifying the OpenCV code itself and recompiling the libraries? Can I run this function on another process or service and interrupt it there?
If a running code is not designed to react to attempts to interrupt it, then we can do nothing about it. As a workaround we can run it in a separate process and cancel it with Process.destroy()
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加