8

The quality of capture from Pi Camera varies when captured to numpy array and when captured directly to a path. The former has more pinkish tint to it than the later.

Why is that.?
The code I used for capturing the images:

from picamera import PiCamera
import cv2
import time

camera = PiCamera()
camera.resolution = (1280, 720)
img = np.empty((720, 1280, 3), dtype=np.uint8)

start = time.time()
camera.capture(img, "bgr")
print("Trigger time: " + str(time.time() - start))
cv2.imwrite("array_capture.png", img)

start = time.time()
camera.capture("normal_capture.png")
print("Trigger time: " + str(time.time() - start))

The time taken to capture the image to numpy array is half that of direct path capture. So, Is it related to de-noising of image.?

Image Captured to numpy array: 0.71 sec Image Captured to numpy array

Image captured to a path: 1.52 sec Image captured to a path

  • Put trigger time for numpy after write. Then you can really compare. I am curious – jaromrax Mar 16 '17 at 16:06
  • @jaromrax Doing so increases the trigger time to around 0.925 sec. But its still less than that for the path capture. – harshatech2012 Mar 16 '17 at 17:24
  • Could it be a compression issue? For example, maybe cv2 doesn't use filtering but picamera does. What are the sizes of the output files? You can check with du normal_capture.png and du array_capture.png – Hunter Akins Apr 26 '18 at 19:37
1
+50

According to the Picamera Documentation in part 3.5 of the basic recipes section:

You may wish to capture a sequence of images all of which look the same in terms of brightness, color, and contrast (this can be useful in timelapse photography, for example). Various attributes need to be used in order to ensure consistency across multiple shots. Specifically, you need to ensure that the camera’s exposure time, white balance, and gains are all fixed:

To fix exposure time, set the shutter_speed attribute to a reasonable value. Optionally, set iso to a fixed value. To fix exposure gains, let analog_gain and digital_gain settle on reasonable values, then set exposure_mode to 'off'. To fix white balance, set the awb_mode to 'off', then set awb_gains to a (red, blue) tuple of gains.

It can be difficult to know what appropriate values might be for these attributes. For iso, a simple rule of thumb is that 100 and 200 are reasonable values for daytime, while 400 and 800 are better for low light. To determine a reasonable value for shutter_speed you can query the exposure_speed attribute. For exposure gains, it’s usually enough to wait until analog_gain is greater than 1 before exposure_mode is set to 'off'. Finally, to determine reasonable values for awb_gains simply query the property while awb_mode is set to something other than 'off'. Again, this will tell you the camera’s white balance gains as determined by the auto-white-balance algorithm.

The following script provides a brief example of configuring these settings:

from time import sleep
from picamera import PiCamera

camera = PiCamera(resolution=(1280, 720), framerate=30)
# Set ISO to the desired value
camera.iso = 100
# Wait for the automatic gain control to settle
sleep(2)
# Now fix the values
camera.shutter_speed = camera.exposure_speed
camera.exposure_mode = 'off'
g = camera.awb_gains
camera.awb_mode = 'off'
camera.awb_gains = g
# Finally, take several photos with the fixed settings
camera.capture_sequence(['image%02d.jpg' % i for i in range(10)])

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.