Hi there,
As i’m newbie to openmv, I wanna know how to capture an image when an external trigger is given via gpio pin. I wanna capture an image when a buzor is pressed and find the qrcodes in that image and share those data via uart to a pc. I’m using openmv m7. Thanks in advance.
CODE:
import sensor, image, time
from pyb import *
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
i=0
def callback():
i=1
ext = ExtInt(Pin('P7'), ExtInt.IRQ_RISING, Pin.PULL_DOWN, callback)
if(i==1):
print('trigerred')
img=sensor.snapshot()
else:
print('no signal')
this code doesn’t works actually.
import sensor, image, time
from pyb import Pin, ExtInt
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
cap = 0
def callback (line):
cap = 1
ext = ExtInt(Pin('P7'), ExtInt.IRQ_RISING, Pin.PULL_DOWN, callback)
while(True):
if (cap == 1):
img = image.snapshot()
cap = 0
Hi,
Thanks for your reply, Actually this is what the code which is in the example. I already tried this code, what happens when i run this code is exactly after 2000 frames the camera stops capturing. But the external interrupt on pin 7 doesn’t capture any image. I want to capture when the 5V supply interrupts the pin p7 when pressing the buzor. I hope will get a perfect solution. Thanks in advance.
I need to see your schematics and a picture of the setup.
Actually I gave +5V to pin Vin, -5V to gnd and then i gave +5V interrupt to pin p7.
Um, can you also share the code or other details? I don’t have an idea what’s wrong still. You are putting 10V across the device power supply which is out of spec.
So is this issue fixed or not ?
Actually, I have shared the code already i think. Is there anything wrong with my power supply.? lemme have a suggestion for external interrupt supply. I have tried connecting -5V to gnd and +5V interrupt to pin p7 also.
Hi, +5v to the pin and -5v to gnd is 10V across the camera’s I/O pin. That will destroy the camera. Can you post a schematic of what you are doing?
I am having the same issue. Connected via USB to windows 10.
Locks up after about 2 seconds
my code
import sensor, image, time
from pyb import Pin, ExtInt
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
cap = 0
def callback (line):
cap = 1
ext = ExtInt(Pin('P5'), ExtInt.IRQ_RISING, Pin.PULL_DOWN, callback)
ext.enable()
#uart = pyb.UART(3, 115200, timeout_char = 1000)
while(True):
if (cap == 1):
#img = sensor.snapshot()
#img = img.compressed(quality=35)
#uart.write(img)
print("cap_found")
cap = 0
Can you repost your code with code tags? Also, I notice you are not using global in your callback method. Python methods do not have scope of variables like C unless you say a variable is global before hand.
def callback (line):
cap = 1
Is not valid python code. You have to do:
def callback (line):
global cap
cap = 1
Thank you for the suggestion. Unfortunately it still did not work. No at big issue at this time, I decided to trigger via a serial port command.