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.26k stars 1.11k forks source link

No Webcam detected on Ubuntu #837

Closed GivouDev closed 2 years ago

GivouDev commented 3 years ago

Hello Guys,

the API doesnt detect any Webcams on my Linux Machine.

The Code i use is not that important, because...its not doing really something but here: `package org.givou.ai;

import com.github.sarxos.webcam.Webcam; import com.github.sarxos.webcam.WebcamPanel; import com.github.sarxos.webcam.WebcamResolution;

import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.List; import java.util.concurrent.TimeUnit;

public class Main { static JFrame ui;

public static void main(String[] args) {
    ui = new JFrame();

    ui.setSize(600, 400);
    ui.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    ui.setVisible(true);
    ui.setTitle("HumaNET");

    Webcam webcam = Webcam.getDefault();
    if(webcam == null) { noCamError(); return; }

}

private static void noCamError() {
    JOptionPane.showMessageDialog(ui, "Keine Webcam", "Es wurde keine Webcam gefunden!", JOptionPane.INFORMATION_MESSAGE);
}

} `

I have installed all Libraries and slf4j-simple extra, because i got this StaticLoggerBinder error. Now when i try to fire up my project it shows me this: [main] INFO com.github.sarxos.webcam.Webcam - WebcamDefaultDriver capture driver will be used [main] WARN com.github.sarxos.webcam.Webcam - No webcam has been detected!

And Webcam.getDiscoveryService().getWebcams() is also showing 0 webcams. hwinfo --usb finds my webcam aswell, and i can access it with mplayer. 15: USB 00.0: 11200 TV Card [Created at usb.122] Unique ID: 2UT6.NYXLEyGue27 Parent ID: k4bc.tisqRJYDXEC SysFS ID: /devices/pci0000:00/0000:00:01.2/0000:02:00.0/usb1/1-3/1-3:1.0 SysFS BusID: 1-3:1.0 Hardware Class: tv card Model: "Microdia PC Camera (SN9C120)" Hotplug: USB Vendor: usb 0x0c45 "Microdia" Device: usb 0x613c "PC Camera (SN9C120)" Revision: "1.01" Driver: "sonixj" Driver Modules: "gspca_sonixj" Speed: 12 Mbps Module Alias: "usb:v0C45p613Cd0101dc00dsc00dp00icFFiscFFipFFin00" Driver Info #0: Driver Status: gspca_sonixj is active Driver Activation Cmd: "modprobe gspca_sonixj" Config Status: cfg=new, avail=yes, need=no, active=unknown Attached to: #20 (Hub)

Thanks to anybody who tries to help me :)

alexmao86 commented 2 years ago

hi @GivouDev, there indeed some cases camera can not be detect. The root cause is that default built-in camera driver depends on bridj which is a JNA solution from java to native code. Unfornaturely, bridj community stopped update for a long time so that can not work for new OS. What you can do is change other driver.

Alex