use as a contrast sensor

Hi,
In my project, i am trying to use H7 sensor work like a contrast sensor, means i can minimise the capture area to set sensor.set_windowing((40, 10)) to detect black mark from rotating roller with in 1 milli second. image processing may took more time if any another function can use to achieve the result (black / white frame detection).

Thanks in advance

Use get_stats() or get_histogram().

import sensor, image, time

sensor.reset()                      # Reset and initialize the sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QQQVGA)
sensor.set_windowing((60, 10))      # Set frame size to QVGA (320x240)
sensor.skip_frames(time = 2000)     # Wait for settings take effect.
sensor.ioctl(sensor.IOCTL_SET_TRIGGERED_MODE, True)
clock = time.clock()                # Create a clock object to track the FPS.

while(True):
    clock.tick()                    # Update the FPS clock.
    img = sensor.snapshot()         # Take a picture and return the image.
    dd = img.get_stats().mean()
    #dd = img.get_histogram()
    #print(dd)
    if dd < 100:
        print("FPS:%d > %s"% (clock.fps(),dd))              # Note: OpenMV Cam runs about half as fast when connected

Hi Iwas trying to use above code for detect black frame with global shutter trigger mode, but it still detect black in very low FPS, with this approach can we get black or white detection with in 100-200 micro seconds?

You have to set the camera exposure to be a low value. See the Global Shutter example high FPS script.

That said, 100-200 microseconds isn’t happening except on an FPGA… That’s obscenely fast. You can get 400 FPS max. 100-200 microsecond is much faster than that. I do not know where you are getting this 100-200 microsecond number from.

Hi kwagyeman

I m capturing this black mark from moving conveyer which run in speed of 100 - 250 meter per minute (4000 mm /sec) means with in 250 micro second 1 mm mark will be move from sensor,

Understood, but, even if you set the resolution to be 80x60 and the exposure to be very low to get the 400fps rate this doesn’t get you up to 100 microseconds… You need a 10k fps camera to hit that.

Can you send an image of the problem? Maybe it’s possible to lower the frame rate.

Hi
I m planning to use TSL1401CL 128X1 Linear CCD Camera Sensor, which can read 128 pixel data with 38 micro seconds. I hv realised openmv will not meet my this requirement,

Thanks

Yeah, that kind of sensor would be more suited to your task.