Deepak123
Posts: 5
Joined: Mon Apr 13, 2015 12:14 pm

How to Capture image by every trigger less time

Thu Jun 25, 2015 12:29 pm

Hello everyone
I'm working on Image processing project where I need to capture the image after getting trigger by sensor and need to process the image. Trigger is coming very fast at 200ms. so I need to capture and process between 200ms where the next trigger arises. I have tried stream option also, but finally I need RGB image(.jpg).
In my program I have used video port, sequence function so current capture time is 80ms-100ms.
So please guide me how to capture the image in very short time(ms) after every trigger,
Thanks in Advance.

Program:

Code: Select all

import time
from picamera.array import PiRGBArray
import picamera
from PIL import Image
import RPi.GPIO as GPIO
import serial

port = serial.Serial("/dev/ttyAMA0", baudrate=9600, timeout=2.0)

GPIO.setmode(GPIO.BCM)  
GPIO.setup(17, GPIO.IN, GPIO.PUD_UP)

with picamera.PiCamera() as camera: 
    camera.start_preview()
    camera.framerate = 30
    camera.resolution = (700,150)
    time.sleep(2)
    cnt = 0
    while True:
        cnt = cnt + 1
        if (cnt>=101):
            break
        GPIO.wait_for_edge(17, GPIO.RISING)
        start = time.time()
        camera.capture_sequence([
            '/home/pi/tray' + str(cnt) + '.jpg'], use_video_port=True)
        if True:
            port.write("\r\n@T10LA10LA10LA#")
        print (time.time()-start)
    camera.stop_preview()

User avatar
davef21370
Posts: 897
Joined: Fri Sep 21, 2012 4:13 pm
Location: Earth But Not Grounded

Re: How to Capture image by every trigger less time

Thu Jun 25, 2015 5:00 pm

This link may be of some help http://raspberrypi.stackexchange.com/qu ... era-module and saving to a ramdisk would save a little time.

Dave.
Apple say... Monkey do !!

Deepak123
Posts: 5
Joined: Mon Apr 13, 2015 12:14 pm

Re: How to Capture image by every trigger less time

Fri Jun 26, 2015 6:54 am

I have tried that program what you have mentioned, but it will capture 40 images continuously if i make it frames=1 its taking 100ms time for capturing image, in my case I need only one image per trigger.
So is there any command to take image at less than 50ms for every GPIO high?

GillesPif
Posts: 1
Joined: Fri Feb 19, 2016 2:47 pm

Re: How to Capture image by every trigger less time

Fri Feb 19, 2016 3:38 pm

up.
Have you any idea about the best approach to realize a synchronization between frame trigger and led?
My subquestions are :
- how generate an output signal as indication of exposure active or frame active for synchronization with a led chaser for example? (first approach)
- how to use an external signal to capture a frame at each trigger? (second approach)
- do you know if another approach exists with pi camera?

thank you in advance for your clarification

Return to “Python”