eduramiba / webcam-capture-driver-native

Native driver for Webcam Capture API
25 stars 8 forks source link

All black image on OSX #27

Open salamanders opened 2 months ago

salamanders commented 2 months ago

I'm trying for the first time on OSX, and getting an all-black image. Macbook M1 Pro, Sonoma (14.5)

// Mac OSX
Webcam.setDriver(NativeDriver())
Webcam.getWebcams().forEach { webcam ->
    println(webcam)
    println(" ${webcam.viewSizes.joinToString { "${it.size.width}x${it.size.height}" }}")
}
val webcam = Webcam.getDefault()
webcam.open()
repeat(20) {
   // warm up, or allow auto-levels
    webcam.image
}
val img = webcam.image
println("Image: ${img.width}x${img.height}")
ImageIO.write(img, "PNG", File("hello-world.png"))
webcam.close()

Build with

    implementation("com.github.sarxos:webcam-capture:0.3.13-SNAPSHOT")
    implementation("org.slf4j:slf4j-api:2.0.12")
    implementation("org.slf4j:slf4j-simple:2.0.13")

    // Getting it working on Mac OSX
    implementation("io.github.eduramiba:webcam-capture-driver-native:1.0.0")
slawalata commented 1 month ago

I get same result in M1 Sonoma. I get a blank image.

    implementation("com.github.sarxos:webcam-capture:0.3.13-SNAPSHOT")
    implementation("io.github.eduramiba:webcam-capture-driver-native:1.0.0")
eduramiba commented 1 month ago

Not sure what can be wrong, does the readme example work correctly? https://github.com/eduramiba/webcam-capture-driver-native?tab=readme-ov-file#simple-example-with-javafx