caprica / picam

Unofficial Java API library for the Raspberry Pi camera.
GNU General Public License v3.0
49 stars 11 forks source link

Captures a black rectangle even if no error messages #8

Closed d01010101 closed 5 years ago

d01010101 commented 5 years ago

raspistill works on this raspberry as expected

I do not use maven in the particular app to which I would add camera functionality, thus I copied manually jna-4.2.2 and slf4j to my app from what picam put into .m2

all compiles without errors, the code

CameraConfiguration config = cameraConfiguration()
    .width(1920)
    .height(1080)
    .encoding(Encoding.JPEG)
    .quality(85)
   .delay(5);

try (Camera camera = new Camera(config)) {
    camera.takePicture(new FilePictureCaptureHandler(new File("picam.jpg")));
}

reports no exceptions, prints out:

[main] INFO uk.co.caprica.picam.Camera - >>> Begin Take Picture >>>
[main] INFO uk.co.caprica.picam.Camera - Preparing to capture...
[main] INFO uk.co.caprica.picam.Camera - Capture started
[main] INFO uk.co.caprica.picam.Camera - Capture completed
[main] INFO uk.co.caprica.picam.Camera - <<< End Take Picture <<<

What i get is a black jpg of size 58800.

I know that I do not use picam in a standard way, but otherwise it would be limited to maven only apps. Nevertheless, I attach the right jna-4.2.2 library, compile all on the same raspberry pi system and there are neither compiler nor runtime exceptions reported.

Possibly a small demo directly in picam would help, so that it could be tested if picam works at all on the system and check for differences between the working demo and a non-working user app. mvn test passes, but produces no image for a visual inspection.

System details:

Raspberry Pi 3 B+

java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) Client VM (build 25.65-b01, mixed mode)
caprica commented 5 years ago

Try increasing the delay to more than 5 milliseconds.

I'm no camera sensor expert, but it seems like the sensor needs some time to settle/adjust before you actually take the capture. I would start with maybe 5000 until you get a working picture and then dial it down.

caprica commented 5 years ago

By the way, you definitely don't need to use Maven, adding the jars manually as you've done is perfectly fine.

d01010101 commented 5 years ago

I finally made run BasicTest within the library. it has a delay of 5 and produces good images. In my app, I need at least ~50 for an image to be produced. I need one image per second so it is not a problem, but the disrepancy seems a bit strange to me. Anyway, it works for now, thanks.

caprica commented 5 years ago

Well that's good to hear but that discrepancy indeed seems odd.