Hi, sorry, this error is expected. I will update the error messages for this in the future. Just do this:
# OpenMV 10x10 data matrix decoder
# Added the Infrared LED'S to the project
# Removed the IR blocker on the camera lens, it can now read matrix codes in the dark
# Pi 3.14159265359
import sensor, image, time, math, pyb
from pyb import LED
red_led = LED(1)
green_led = LED(2)
blue_led = LED(3)
ir_led = LED(4)
def led_control(x):
# if (x&8)==8: ir_led.on()
if (x&1)==1: red_led.on()
# if (x&2)==2: green_led.on()
# if (x&4)==4: blue_led.on()
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE) # GrayScale runs faster
#sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQQVGA)
sensor.skip_frames(time = 2000)
sensor.set_auto_gain(False) # must turn this off to prevent image washout...
sensor.set_auto_whitebal(False) # must turn this off to prevent image washout...
clock = time.clock()
while(True):
clock.tick()
img = sensor.snapshot()
img.lens_corr(1.8) # strength of 1.8 is good for the 2.8mm lens.
for i in range(16):
led_control(i)
matrices =[]
try:
matrices = img.find_datamatrices()
except OSError:
pass
for matrix in matrices:
img.draw_rectangle(matrix.rect(), color = (255, 0, 0))
# print_args = (matrix.rows(), matrix.columns(), matrix.payload(), (180 * matrix.rotation()) / math.pi, clock.fps())
# print("Matrix [%d:%d], Payload \"%s\", rotation %f (degrees), FPS %f" % print_args)
# print("N"+ matrix.payload()+"X"+ str(matrix.x())+"Y"+ str(matrix.y())+"R"+ str(matrix.rotation()))
Cx = matrix.x() + (matrix.w()/2) # get the center of the matrix "X" value
Cy = matrix.y() + (matrix.h()/2) # get the center of the matrix "Y" value
Xoff = (img.width()/2) - Cx # Determine how much if any error is present for the X axis
Yoff = (img.height()/2) - Cy # Determine how much if any error is present for the Y axis
print("N"+ str(matrix.payload())+"X"+ str(int(math.ceil(Xoff)))+"Y"+ str(int(math.ceil(Yoff)))+"R"+ str(int(math.ceil((180 * matrix.rotation() / math.pi)))))
As of right now, the errors for running out of memory are all the same. If you look at a datamatrix code… you get the fb collision error when you don’t have any temporary allocated heap space left. The data matrix code is not particular amazing and allocates memory somewhat wastefully.
Um, the AprilTag code has the same issue internally, but, much harder to hit. You should always wrap your script with the try and catch stuff in general and handle any errors that are thrown.
Um, the largest AprilTag dictionary I provide is 2k sysmbols. However, if you put two tags right next to each other then you can have 2k^2 symbols. You may also make your own new AprilTag dictionary and edit our firmware for even more tags. However, it’s far easier to just have two codes or more in the same area.
Assuming you are locating a robot in a room… Use one tag for X and one for Y. Note that you could make the tags different colors and use binary to select for one or the other. Or, just use multiple OpenMV Cam’s and place the two tags in physically different areas. The cameras are cheap. No point in trying to make one do everything. Maybe a third camera to follow a line?
I’m now using the April tags and reading them at 85 FPS! I have this connected to the O droidXU4 running a program
Created in Xojo. Tonight I will perform an actual speed test on the camera in light and darkness and test just how fast it can read the April Codes. I’m hoping all the way up too maybe 3 meters pes second…
If successful, I can’t wait to get my hands on the H7! I ordered two more of the M7’s that makes 3 M7’s in total
for just the one bot…
I’ll post the information back here after the test.
Testing is still ongoing at this time, but I dare say it can see better in the dark than in the day! it’s performance excels at night, right where it needs to be. It will be on the bottom of the robot with a lot less light than normal…
As to how I got to that speed, just a fault on my part, an accident that works well… Also in the default code it turns gain and exposure to false, mine reads it better with fine adjustments to the
exposure and gain settings…
Just by toying around with those and the resolution, I was able to hit that number. As I speak right now from an hour of testing the camera, it can support 3 meters per second travel speed with April
tags.
This is much higher than the spec given to me by the company! what a nice camera! I would make a suggestion, make the IR leds adjustable via pwm. they are way to bright without the filter in place.
Hi, there’s no timer on the LED pins (it’s used to generate the clock for the camera). Maybe the M7/H7 have a timer now there though. I can ask Ibrahim to check. The original M4 did not have one to spare.
Anyway, if you’re willing please post your code for others to use. Or, if you feel this a valuable advantage don’t. I ask because quite a few other customers have asked to do this exact same thing and I’ve been unable to meet their needs. This example code would make them happy.
Hi there, I have no problem with posting that code, But since it was developed while working with this company, even by mistake I have to run it by the company boss first. I’m in China, so I’m going to say its a big no!
But no worries, It can come out as freeware? My email address is … a private address they know nothing about. Send me an email to reply to, I will send it to you… don’t share it, just make some changes with it to tweak the program… This way nobody comes out on the short end of the stick!
Robert
Anybody else asking for this will be a flat out no, so don’t bother…
Okay, that’s fine. I don’t actually need it. Anyone else reading this thread can work out what to do themselves if they put the time in to get the same performance.
I appreciate that you’ve actually put effort in to use the camera versus trying to run the algorithm at the highest resolution and saying it’s too slow. Everyone wants to run everything at crazy high resolutions and then complains when it’s slow. Not many folks actually try to work out what resolution they need to hit their target and then work from there.
Note, I removed your email address from the above post. Don’t publicly post that…
Well it’s still a work in progress, but yes, that just how it was played out, what can this camera do?
It works well enough to get the April tags at three meters per second on my end. giving the testing that was performed on my behalf… given that was not an in company test and performed at my lab in my house, but non the less valid… (it does work)
Now to integrate this into the, beating out of the major manufactures of Beijing here in China. your camera kills them, they just don’t know it as of yet!
Keep up the great work that you are doing, I will use your camera any day of the week, versus theirs!
Please email us offline about production. If you are serious about building we have a CM in China called Etonnet who’s able to build these things. Making 10k for this is not a problem. They actually do all of OmniVisions dev boards so that have this magic ability to get the camera chips.
Large orders potentially like yours are why they even entertain us. So, they been waiting for someone to build a commercial product using the cam. They will be happy to hear about what you are doing.
Note, since you’d be paying for a production order the prices will be a lot lower than retail.
It’s Saturday night here, I won’t be able to mess with this on the bot until Maybe Tuesday of this coming week. They want it running right away, but I still have to get the Beijing camera out of it, and install the OpenMV M7 into it, then change the programming to read it over the serial port…
The coolest thing about the OpenMV M7 is that we have control over how the camera works as far as programming. This is not the case with just purchasing one off the shelf from a major suppler
of higher end cameras…
They really like the fact it can be used in different ways.