Controlling USB web camera photo capture time on Raspberry Pi and Python

Emiel Steerneman

I am taking pictures on my Raspberry Pi using an usb webcam and Pygame. These images will be used to track movement of an object, then rotate a motor. Therefore, a constant framerate would be nice. Unfortunately, taking pictures of dark object seem to take up almost 4x as much time as with bright objects. I suspect this is the result of a longer exposure time.

If this is indeed the problem, is there any way to set the exposure time to a fixed number? If not, what else can i do?

result of code below:

Dark: (aimed at a black wall)
- Duration: 14213 ms
- Min: 12 ms
- Max: 387 ms
- Avg: 142 ms

Bright: (aimed at a white wall)
- Duration: 3550 ms
- Min: 12 ms
- Max: 67 ms
- Avg: 35 ms

print "importing.."

import time
import pygame
import pygame.camera
from pygame.locals import *

# INITIALIZE CAMERA
print "\ninitializing.."
pygame.init()
pygame.camera.init()
camlist = pygame.camera.list_cameras()
cam = pygame.camera.Camera("/dev/video0", (320,240))
cam.start()

time.sleep(1)

# MEASURE TIME
print "running.."
begin = int(round(time.time() * 1000))

min = 1000
max = 0

for i in range(1, 100):
        start = int(round(time.time() * 1000))    
        img = cam.get_image()        
        stop = int(round(time.time() * 1000)) - start

        if(stop > max):
                max = stop
        if(stop < min):
                min = stop

        print "{}\t{} ms".format(i, stop)

duration = int(round(time.time() * 1000)) - begin

print "Duration: {} ms".format(duration)
print "Min:\t{} ms".format(min)
print "Max:\t{} ms".format(max)
print "Avg:\t{} ms".format(duration / 100)
davidc

As long as your required frame rate is low enough to accommodate the slowest exposure, you can sleep after processing each frame until it's time for a new frame. You've already got the time that you started the first frame. When the first frame is done, add the required interval to get the next start and calculate the sleep time to the next frame.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Controlling USB web camera photo capture time on Raspberry Pi and Python

From Dev

Raspberry Pi Camera auto capture python script

From Dev

OpenCV multiple USB camera on Raspberry Pi 3

From Dev

Raspberry Pi 1B, mjpg-streamer and USB web camera

From Dev

Raspberry Pi 1B, mjpg-streamer and USB web camera

From Dev

Capture video from camera on Raspberry Pi and filter in OpenGL before encoding

From Dev

Controlling OpenHAB using Amazon Echo on Raspberry Pi

From Dev

Raspberry Pi camera writing permissions

From Dev

Pi camera preview with GUI - Raspberry Pi

From Dev

How capture photo of camera periodically from service?

From Dev

Python/Raspberry Pi guaranty about interrupt response time

From Dev

time.sleep(1) error -- python on Raspberry Pi

From Dev

Accepting sound input all the time in raspberry pi with python

From Dev

Access Live Stream with Raspberry Pi Camera Module on Web Browser using NodeJS?

From Dev

Controlling a servo with raspberry pi using the hardware PWM with wiringPi

From Dev

controlling windows machine from raspberry pi 2 over network

From Dev

Raspberry Pi Python ValueError?

From Dev

Integrating Raspberry Pi Camera with Qt application

From Dev

Handle Raspberry Pi camera via Apache

From Dev

Ubuntu Server with Raspberry Pi Motion Camera

From Dev

Integrating Raspberry Pi Camera with Qt application

From Dev

Ubuntu Server with Raspberry Pi Motion Camera

From Dev

Which camera to connect with Raspberry pi2

From Dev

Get Raspberry Pi Camera Feed into Darknet and Yolo

From Dev

Can Raspberry PI capture HDMI input

From Dev

Web browser memory on Raspberry Pi

From Dev

Web browser memory on Raspberry Pi

From Dev

Ball tracker using OpenCV, Python and Raspberry Pi 3 w/ camera module

From Dev

Raspberry Pi is not recording from USB Microphone

Related Related

  1. 1

    Controlling USB web camera photo capture time on Raspberry Pi and Python

  2. 2

    Raspberry Pi Camera auto capture python script

  3. 3

    OpenCV multiple USB camera on Raspberry Pi 3

  4. 4

    Raspberry Pi 1B, mjpg-streamer and USB web camera

  5. 5

    Raspberry Pi 1B, mjpg-streamer and USB web camera

  6. 6

    Capture video from camera on Raspberry Pi and filter in OpenGL before encoding

  7. 7

    Controlling OpenHAB using Amazon Echo on Raspberry Pi

  8. 8

    Raspberry Pi camera writing permissions

  9. 9

    Pi camera preview with GUI - Raspberry Pi

  10. 10

    How capture photo of camera periodically from service?

  11. 11

    Python/Raspberry Pi guaranty about interrupt response time

  12. 12

    time.sleep(1) error -- python on Raspberry Pi

  13. 13

    Accepting sound input all the time in raspberry pi with python

  14. 14

    Access Live Stream with Raspberry Pi Camera Module on Web Browser using NodeJS?

  15. 15

    Controlling a servo with raspberry pi using the hardware PWM with wiringPi

  16. 16

    controlling windows machine from raspberry pi 2 over network

  17. 17

    Raspberry Pi Python ValueError?

  18. 18

    Integrating Raspberry Pi Camera with Qt application

  19. 19

    Handle Raspberry Pi camera via Apache

  20. 20

    Ubuntu Server with Raspberry Pi Motion Camera

  21. 21

    Integrating Raspberry Pi Camera with Qt application

  22. 22

    Ubuntu Server with Raspberry Pi Motion Camera

  23. 23

    Which camera to connect with Raspberry pi2

  24. 24

    Get Raspberry Pi Camera Feed into Darknet and Yolo

  25. 25

    Can Raspberry PI capture HDMI input

  26. 26

    Web browser memory on Raspberry Pi

  27. 27

    Web browser memory on Raspberry Pi

  28. 28

    Ball tracker using OpenCV, Python and Raspberry Pi 3 w/ camera module

  29. 29

    Raspberry Pi is not recording from USB Microphone

HotTag

Archive