Take fast single frame pictures?

I’ve got an arducam with the imx477. I don’t want to take video, but rather still frame pictures like a snapshot camera. Right now i’m using python and opencv, and the gst pipeline api. It’s taking well over a second to capture each frame.

I’ve also tried gst-launch directly and same thing it’s taking over a second.
gst-launch-1.0 nvarguscamerasrc ! num-buffers=1 ! nvjpegenc ! filesink location=/tmp/test.jpg

how can i capture a fast snapshot in a python app? on a pi with a usb uvc cam i can capture an image in around 0.2 seconds, and i felt even that was a little slow…

hello JoelOz,

this pipeline involves several steps to capture a jpeg image, for example, camera initial, internal buffering, jpeg encoding…etc.
may I know what’s your actual use-case,
you may enable the camera in the preview stream if you would like to take a snapshot as soon as possible.
please enable the sensor with argus_camera, you’ll see an user-interface to capture a jpeg frame.

Running headless, so i dont think argus_camera will work?

I’m a pretty new programmer, I only know python. I’m more of a tinkerer so there may be obvious solutions I’m missing or things i flat out have conceptually wrong. I’m a manager at a small plant and I’m just trying to do this as a side project to help catch QC issues. It’s actually kind of working on a raspi right now, just running slowly.

It’s basically a parts inspection camera. Takes a picture of an object normal to the object, then run image classification against that picture to look for known defects.

I’m trying to do this with pictures vs video, because first off at this stage it’s easier for me to conceptualize. Also I imagine it’s more efficient to work with images, why waste processing power trying to analyze a part that’s not in position? I also want to save the analyzed image for later review, to feed back to the CNN for more training, etc.

I think i have an acceptable solution that i found late last night. Using opencv with the gst pipeline, and just leaving the capture open, instead of releasing the camera after each image. image capture time is now .05-.1 of a second. Only thing i’m not sure of is if opencv keeps a buffer that I have to worry about getting images that are lagging behind? The buffer is an issue i ran into previously on the pi with my uvc camera that i had to work around.

For using NVJPG, you need to get or send video frames into/from NVMM memory in I420 format.
You can get one frame with:

gst-launch-1.0 nvarguscamerasrc num-buffers=1 ! nvvidconv ! 'video/x-raw(memory:NVMM), format=I420' ! nvjpegenc ! filesink location=test.jpg

It may take some time depending on your camera/ISP/Argus settings to autotune, so you may record each frame and keep only the last 15 ones with:

gst-launch-1.0 -e nvarguscamerasrc ! nvvidconv ! 'video/x-raw(memory:NVMM), format=I420' ! nvjpegenc ! multifilesink location=test_%05d.jpg max-files=15

hello JoelOz,

yes, argus_camera could enabled in headless mode if you run $ xinit & to enable rendering;
there’s another application to get this done by default, you may execute $ nvgstcapture-1.0 to enable camera streaming, and using j key-events to capture a frame.
for example,

Image Captured

jpeg image will save to your local host, i.e. nvcamtest_11276_s00_00000.jpg