4

I was already searching through forums and this stack exchange but I couldn't find anything that helps.

So here is my problem. I have written a program in Java that analyzes pictures and outputs certain information, the algorithm itself certainly is fast enough, so there is no problem here. I am using hodping/jrpicam as my library, which is based on raspistill. I need to analyze multiple pictures per second, raspistill needs about .8s to take a picture which is just too long.

The pictures don't need to be of high quality and have a resoultion of 300x300. I have checked with other libraries and found nothing suitable in Java, but for Python. Picam apparently uses the videoport and raspivid, and with that is able to provide high FPS counts, as expected.

I would like to stick with Java since the program is quite complex. So is there an equivalent to picam in Java or any library that could provide the needed speed? If not do you guys have any other idea on how to get a higher framerate (10 FPS would be sufficient)?

4
  • Could you just run ffmpeg to take pictures? Jan 23, 2019 at 8:05
  • Technically I really don't care how exactly the picture is taken. Here are the requirements I have on the image: - 300x300 px - low quality - black and white is sufficient, otherwise RGB data - doesn't need to be encoded as PNG or JPEG, a BW or RGB array is sufficient whichever library or program can provide this output fast is ok with me, as long as its java
    – Clex
    Jan 23, 2019 at 8:12
  • Hi Vilho - Thanks for posting. You have actually posted an Answer with another question in it. If you feel this is a good answer please edit your answer and add some more details and explain. Otherwise this is more suited as a comment. Thanks
    – Piotr Kula
    Jan 23, 2019 at 8:55
  • Maybe you should look into how to use a live video stream and then capture the framebuffer.. instead of using the API to take pictures. That way you can achieve 60fps at lower frame rates and the only overhead will be how fast you can copy the frame buffer and analyse it. You can even start the stream in a much lower resolution which should mitigate any memoery problems.
    – Piotr Kula
    Jan 23, 2019 at 8:57

1 Answer 1

1

I'd take a look at the picam library. It provides direct access to the camera, as the native MMAL library is used without any external dependencies or processes or wrappers. It's still based loosely on the raspistill, but unlike JRPicam, doesn't wrap the native process, and therefore has much better performance.

Do note however that this does not use the video functionality of the camera. If you'd prefer to do so without the pain and suffering of figuring out internals of the picam's MMAL library, I'd recommend you wrap raspivid in a manner similar to the way JRPicam does using a ProccessBuilder. Not that it's good practice, but raspivid does include a -o option which allows you to output to stdout, which you could read from, as this library does (also using a ProccessBuilder.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.