OpenMV for seeing and counting sheets in a stack of cardstock

I need to build something capable of viewing a stack of cardstock, as shown in the image below, and be able to identify the edges of each sheet, so as to be able to count the sheets in a given area. The sheets would be approximately the thickness of a greeting card. Would an OpenMV unit be capable of this?

It just depends on if the camera can see the card edges. You’ll have to buy a unit and test if that’s possible. If you can discern the edges with a camera then yes.

I guess the question really is, would a more complex (expensive) OpenCV solution have a significantly better chance of being able to do this, or would an OpenMV unit be as (or nearly as) capable?

Pretty much the same. The problem is just on if the camera can see the edges. If you capture the image with WQXGA2 (5MP) resolution then maybe.

Ok, certainly worth testing. So I’m looking to use this cam to send a count or a distance to a Teknic ClearCore unit that supports analog input similar to an Arduino. The ClearCore provides 24v power. So for the fastest capability, would my best bet be an H7 Plus cam with a CAN/RS232 shield? If I am understanding correctly, that setup would allow for accepting 24v power and outputting a 12-bit 0-5v analog signal that I could use to communicate the count or distance”.

Uh, yes, but, you can’t expect to actually read 12-bits reliably over 0-5V. You’ll want to send data from the OpenMV Cam to the ClearCore via the 5V UART. The CAN/RS232 shield though is going to output RS232 voltage levels which you can probably connect to the clear core with.

I purchased an RT1062 and my initial testing of the ability to identify the gaps (lines) between sheets of paper is not at all promising. I am using the find_lines example as a starting point. I have set the resolution to VGA and narrowed the window to 100x480 and the image that I am seeing from the camera seems quite good for me to identify the gaps by eye. But even lowering the threshold to 1, the find_lines function is only picking up a couple lines, and oddly not even seeing them as being nearly perfectly horizontal as they are. I have pasted in the image and code below. I have also tried find_line_segments, and while it does find a lot more little lines at the gaps, it does not seem to be lending itself to getting me to one line for each gap. Am I missing something that would allow for better identification of these lines?

import sensor
import time

ENABLE_LENS_CORR = False  # turn on for straighter lines...

sensor.reset()
sensor.set_pixformat(sensor.RGB565)  # grayscale is faster
sensor.set_framesize(sensor.VGA)
sensor.set_windowing((100,480))
sensor.skip_frames(time=2000)
clock = time.clock()

min_degree = 0
max_degree = 179

while True:
    clock.tick()
    img = sensor.snapshot()
    if ENABLE_LENS_CORR:
        img.lens_corr(1.8)  # for 2.8mm lens...

    for l in img.find_lines(threshold=1, theta_margin=25, rho_margin=25):
        if (min_degree <= l.theta()) and (l.theta() <= max_degree):
            img.draw_line(l.line(), color=(255, 0, 0))
            # print(l)

    print("FPS %f" % clock.fps())

Hi, you need to increase the contrast in the image.

Try using img.gamma() and playing with the gamma/contrast values. You can also use some of the filters like mean()/median() with the adaptive threshold values. These will pick the lines out too.

After applying these filters find_line_segments() should work well.