1

I would like to know, how to name the captured images with a sequence of numbers instead of its frame numbers by using Raspistill command and also could anyone suggest me the typical skipping frame pattern.

Since I need to capture and process each and every image simultaneously, I don't understand how to load the image if I don't know how its named.

This is the command to capture images with a time lapse of 5msec till 1second in burst mode

sudo raspistill -o img%d.jpg -w 640 -h 480 -tl 5 -t 1000 -bm

I tested this command for two times and I observed the following results

what I'm interested to get is :

img1.jpg , img2.jpg, img3.jpg ….etc

But what I'm getting is :

SAMPLE 1: img1.jpg, img144.jpg, img194.jpg, img243.jpg, img294.jpg, img344.jpg, img393.jpg, img443.jpg.........etc

SAMPLE 2: img1.jpg, img151.jpg, img200.jpg, img299.jpg, img349.jpg, img399.jpg, img449.jpg, img499.jpg, img548.jpg, img598.jpg, img649.jpg........etc

I couldn't find the exact similar frame pattern.

As in the Raspberry Raspistill camera documentation it mentions that :

“ -t 30000 -tl 2000 -o image%04d.jpg

will produce a capture every 2 seconds, over a total period of 30s, named image0001.jpg, image0002.jpg..image0015.jpg. Note that the %04d indicates a 4 digit number with leading zero's added to pad to the required number of digits. So, for example, %08d would result in an 8 digit number.

Source : https://www.raspberrypi.org/documentation/raspbian/applications/camera.md

But I 'm not able to get the image names with the sequence of numbers as they mentioned (such as img1.jpg,img2.jpg, img3.jpg, ....img20.jpg)

Though the documentation provides the “date,month,year & time stamp” features for naming the image files, I couldn't find it for the sequence naming.

I would really appreciate if someone could suggest me, how to modify the command to ensure that I get the name of the images in a sequence number order instead of its frame number. And also I would be glad to know the specific skipping frame pattern for the images captured.

If both the above options cannot be solved, I would request you to suggest me how to accomplish the following task. Actually I'm working on a project based on Real time image processing using Raspberrypi. Using the raspistill command with a specific time lapse and duration, I could capture 'n' (may be 10 or 20 images per second) images, later simultaneously I have to do simple image processing using CImg library and write the output data to a file.

But for image processing , I need to load and process all the images (using CImg library), since the image names are mentioned with a different frame numbers, its becoming a difficult job to load the images for processing Instantly.

I would love to know how can we resolve the above problem, but with the following conditions.

Please don't refer me to use Raspicam C++ API(it lacks some inbuilt features for my job) or V4L2 driver (difficult to understand and perform operations) or OpenCv (Since my Image processing task is a very simple one, just to detect a blink of LED) etc, since I tried out many options and none of the above platforms could not satisfy my project requirements and conditions.

If the above task could be performed by programming, it has to be either c or c++ but not python or Java (since processing performance matters !)

For more background information about this question, please refer to one of my posts in the following link: https://stackoverflow.com/questions/37013039/how-do-i-capture-and-process-each-and-every-frame-of-an-image-using-cimg-library

Thanks in advance.

1

You're not going to get 30fps out of raspistill without modifying it. This is because it captures images from the camera's "still" port; the MMAL camera component which raspistill and raspivid use provides 3 virtual ports: preview, video, and still. When images are captured via the still port, the camera is forced to mode-switch to its highest resolution mode (2 or 3 depending on the requested frame-rate). Mode switches are expensive and result in at least one frame being dropped (as the first frame returned by the sensor after a mode switch is typically corrupt). More information can be found in the Camera Hardware chapter of the picamera docs.

The reason you're getting big gaps in your numbering is simply this: it's saving frame 144, then frame 194, then frame 243, etc. The frames in between are lost as the camera's busy mode switching, writing out data, or waiting for 5ms.

You'll need to deal with the video port to get near 30fps and that means either modifying raspistill (or more likely some combination or raspivid & raspiyuv since you want to process the unencoded video frames), or using something else that can already do video-port captures or processing like picamera.

Here's a trivial example of grabbing the middle pixel from unencoded RGB output from the camera and just printing it out (bear in mind that printing is slow). It also blinks a LED on GPIO17 so you can point the camera at it and see the RGB value of the middle pixel changing (this works best in a dark environment):

from picamera import PiCamera
from picamera.array import PiRGBAnalysis
from gpiozero import LED
from time import sleep

class DetectRedLight(PiRGBAnalysis):
    def analyse(self, a):
        # Pick the middle(ish) pixel and print its RGB values
        r, g, b = a[50, 50, :]
        print(r, g, b)

led = LED(17)
# Use a low resolution to reduce memory bandwidth requirements
camera = PiCamera(resolution=(100, 100), framerate=30)
# Start a transparent preview so we can see what the camera's pointing at
camera.start_preview(alpha=128)
# Set the target blinking
led.blink()
# Give the camera's AGC and AWB some time to warm up
sleep(2)
# Run our analysis class for 60 seconds
output = DetectRedLight(camera)
camera.start_recording(output, 'rgb')
camera.wait_recording(60)
camera.stop_recording()

Now some gentle criticism:

I know you stated a desire to avoid Java or Python. Frankly, your reason for doing so, speed, is invalid. Algorithms and critical paths will have a great deal more to do with the execution speed of your code than language selection will. I note that the code above easily manages 30fps on my Pi3 despite being Python and raspistill being written in C ... because I'm using the video port and raspistill is using the still port (this is what I mean about critical paths mattering more).

That's not to say you couldn't go faster still in C - I'm sure you could - but getting your code fast requires more than simply deciding to use C: you need to understand the system you're dealing with (and coders that do will typically be able to generate fast code in whatever language they use; I know C pretty well, but it's extremely rare that I have to resort to it for more speed).

Furthermore, I wouldn't characterise this as a "very simple" problem either; almost nothing in computer vision is trivial. For example, if you wanted to detect your red light in all conditions, e.g. during daylight as well as darkness (something the human eye has absolutely no problem with), you'd quickly run into all sorts of fun and games with white balance and auto-gain control (something human eyes still do infinitely better than the current generation of cameras).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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