sarxos / webcam-capture

The goal of this project is to allow integrated or USB-connected webcams to be accessed directly from Java. Using provided libraries users are able to read camera images and detect motion. Main project consist of several sub projects - the root one, which contains required classes, build-in webcam driver compatible with Windows, Linux and Mac OS, which can stream images as fast as your camera can serve them (up to 50 FPS). Main project can be used standalone, but user is able to replace build-in driver with different one - such as OpenIMAJ, GStreamer, V4L4j, JMF, LTI-CIVIL, FMJ, etc.
http://webcam-capture.sarxos.pl
MIT License
2.25k stars 1.11k forks source link

Pomijanie klatek przy streamowanie z kamery IP #642

Open adelanteDev opened 6 years ago

adelanteDev commented 6 years ago

Cześć, mam następujący problem. Wykorzystałem Twój przykład odnośnie ipcam tj. FoscamJpegPullExample.java https://github.com/sarxos/webcam-capture/blob/master/webcam-capture-drivers/driver-ipcam/src/examples/java/FoscamJpegPullExample.java oraz przykład związany z live-streaming tj. webcam-capture-live-streaming https://github.com/sarxos/webcam-capture/tree/master/webcam-capture-examples/webcam-capture-live-streaming

public class FoscamJpegPullExample {

    static {
        Webcam.setDriver(new IpCamDriver());
    }

    public static void main(String[] args) throws MalformedURLException {

        String name = "Test #255";
        String url = "http://ce3014.myfoscam.org:20054/snapshot.cgi";
        IpCamMode mode = IpCamMode.PULL;
        IpCamAuth auth = new IpCamAuth("user", "user");

        IpCamDeviceRegistry.register(name, url, mode, auth);

        WebcamPanel panel = new WebcamPanel(Webcam.getWebcams().get(0));
        panel.setFPSLimit(1);
        panel.setFPSLimited(true);
        JFrame f = new JFrame("Test #255 PULL");
        f.add(panel);
        f.pack();
        f.setVisible(true);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}

oraz

public class StreamServer {

    /**
     * @author kerr
     * @param args
     */
    public static void main(String[] args) {
        Webcam.setAutoOpenMode(true);
        Webcam webcam = Webcam.getDefault();
        Dimension dimension = new Dimension(320, 240);
        webcam.setViewSize(dimension);

        StreamServerAgent serverAgent = new StreamServerAgent(webcam, dimension);
        serverAgent.start(new InetSocketAddress("localhost", 20000));
    }

}

I stworzyłem coś takiego :

 static {
        Webcam.setDriver(new IpCamDriver());
    }

    public static void main(String[] args) throws MalformedURLException {

        String name = "Test #255";
        String url = "http://ce3014.myfoscam.org:20054/snapshot.cgi";
        IpCamMode mode = IpCamMode.PULL;
        IpCamAuth auth = new IpCamAuth("user", "user");

        IpCamDeviceRegistry.register(name, url, mode, auth);

        Webcam webcam = Webcam.getWebcams().get(0);
        Dimension dimension = new Dimension(320, 240);
    webcam.setViewSize(dimension);

    StreamServerAgent serverAgent = new StreamServerAgent(webcam, dimension);
    serverAgent.start(new InetSocketAddress("localhost", 20000));
    }

Ustawiam liczbę FPS na 1. Problem jest taki, że co jakiś czas (dosyć często np co 3s) jest pomijana jakaś klatka.

sarxos commented 6 years ago

Cześć @adelanteDev,

Niestety ten przykład do którego się odwołujesz (live streaming example) nie był napisany przeze mnie i nie za bardzo jestem w stanie z głowy powiedzieć co tam jest nie tak i czemu niektóre klatki są pomijane. Podejrzewam, że gdyby podpiąc tam się debuggerem i zobaczyć co się dzieje, to można zobaczyć czy to jakieś timing issue, czy może sieć albo kamera zamula, niestety nie mogę tego zrobić ze względu na brak czasu. Sugeruję w pierwszej kolejności włączyć bardzo dokładne logi (najlepiej poziom trace) i dokładnie przeanalizować aby zrozumieć co się dzieje pod spodem.

ghost commented 5 years ago

wy jesteście polakami xDDD

sarxos commented 5 years ago

@Mikilis Właśnie zdobyłeś tytuł geniusza oczywistości. :smile: