Ask Your Question

RSTP video stream freezes the program while connection is lost..

asked 2016-11-03 09:13:34 -0500

PiMac gravatar image


I have a fairly simple Java app which connects to few cameras through rstp stream, grabs the image and shows it in swing JFrame usnig OpenCV SwingWorker. My reconnect() method looks like this:

public void reconnect(String address) {
    if (new ConnectionTester().pingHost(NETWORK_HOST, NETWORK_PORT, 50)); // networkAddress
    System.out.println("Still running");

    if (!capturedVideo.isOpened()) {
        System.out.println("Error while opening the camera!");

Because of a weak WiFi signal ( connection breaks) between the camera and my pc I sometimes get result like:

    Connection avaliable

and the program hangs while performing;

or on method:

if (isOpened) {;

Is there any way to avoid such situations by maybe waiting a set amount of time before stopping everything and reconnect again ?


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-12-30 07:29:09 -0500

PiMac gravatar image

The solution was simply to store returned boolen value from method:

boolean tempBool =;

The freezing stopped. I hope it will help somebody else.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-11-03 09:13:34 -0500

Seen: 286 times

Last updated: Dec 30 '16