B4J Question Threading library for OpenCV

peacemaker

Expert
Licensed User
Longtime User
HI, All

I know that the threading lib is not recommended at all.
But it's very important for OpenCV work with IP-cameras, that can give big frames latency, and the main window is frozen while waiting for a frame.

How to be? how to use the lib correctly in B4J ?
 

agraham

Expert
Licensed User
Longtime User
so question is how to use it in B4J with debugging...
Sorry - you can't unless Erel rewrites the debugger. But you should be able to debug the threaded code by running it all unthreaded with the performance hit
 
Upvote 1

Jmu5667

Well-Known Member
Licensed User
Longtime User
Just reading frames from IP-camera, those are freezing the main window. Single IP camera.
Processing of each frame is about 0.8...1 second (as 200+ image samples to be recognized on a camera frame).

App is big, complex, and debugging in the debug mode is the must.
Threading is widely recommended for OpenCV with IP-cameras, so question is how to use it in B4J with debugging...
You cant.
 
Upvote 1

agraham

Expert
Licensed User
Longtime User
But ... MAT object of OpenCV cannot be a public variable,
I've no idea what you mean by this. But that error doesn't look like a threading problem.

How the result of threaded sub can be got ?
Several ways. Probably most convenient is to place the return values in global variables and return from the thread sub. This will raise the Ended event.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
I have ported the main B4A example of Threading lib to B4J, it works, but only in Release mode.
So is it not possible to debug an app at all in the debug mode with this lib ?
 

Attachments

  • b4j_threading_test.zip
    3.5 KB · Views: 184
Upvote 0

stevel05

Expert
Licensed User
Longtime User
So is it not possible to debug an app at all in the debug mode with this lib ?
Correct, although if your threaded code is in a separate class, you can compile that to a library once it's working (not a b4xlib) then use that in your app which you can then debug.

If I remember correctly.

Edit: It will depend on the level of integration whether it will work in your case or not.
 
Last edited:
Upvote 0

agraham

Expert
Licensed User
Longtime User
You cannot debug a threaded Sub as the debugger knows nothing about threads. If the normal debugger doesn't work in your non-threaded code you could try the legacy debugger - if B4J implements it. I'm away from my computer and can't remember. EDIT: It doesn't!
 
Last edited:
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
that can give big frames latency, and the main window is frozen while waiting for a frame.
Can you describe what you are trying to do: Multiple video views on the Main form ? I use the threading lib in a B4J ui app(without issues), you cannot debug the app as everything runs on the main thread in debug mode.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
what you are trying to do
Just reading frames from IP-camera, those are freezing the main window. Single IP camera.
Processing of each frame is about 0.8...1 second (as 200+ image samples to be recognized on a camera frame).

App is big, complex, and debugging in the debug mode is the must.
Threading is widely recommended for OpenCV with IP-cameras, so question is how to use it in B4J with debugging...
 
Upvote 0
Top