Hi everyone !
We are young students making an electronic project, but we have very basic skills in Arduino programming.
We bought a OV7670 Camera module, and we want it to read QR code and send an information to the Arduino MEGA.
Have you managed to take pictures with the camera?
Are you storing them onto an SD card in the Arduino?
Did the camera come with any kind of library that recognises QR codes?
sungjung:
Thanks for replying.
To answer your questions : no, no and no. :
Ah
Okay. I would start by saying that the Arduino is not ideal for processing images, and I also have not used the camera myself.
How are you going to photograph the QR codes. Are you just going to hold the camera in your hand and will there be other things in the picture as well as the QR code? Also what resolution of QR code will you be photographing (the lower the resolution the better)?
Your first step is going to have to be to connect the camera to the Arduino.
Then you are going to have to take a picture and save it, do you have an SD card?
Then you are going to have to process the image to read the QR code.
Arduinos are generally not suitable for image recognition. You only have 2 kB of RAM to work with so that's very small images at best.
A quick Google search returned several projects that combine an arduino with a phone and Android app, where the phone app reads the QR code, then sends the decoded data to the Arduino. I didn't see any QR decoding libraries for Arduinos.
You may be able to find QR scanners that work like traditional bar code scanners. Those are more likely compatible with Arduino, as they would output the decoded string rather than produce the image.
If you really want to do your own QR code decoding, look into the RPi or similar devices instead. They do have the horsepower and memory to do image processing.
sungjung:
We connected the camera to the Arduino, maybe we should bring a SD, you're right
You do need an SD card because of the Arduino memory limitations. This project is interesting and, if you can set some limits on the goals, practical. First though some information about you;
how many of you are there?
How many PCs/laptops do you have access to?
What relevant skills do you have; programming, knowledge of image file formats, English (there is a French section on this website)?
Is this an assignment and, if so, what is the deadline for completion?
Can you set the objectives of the project so that you set targets that you can achieve e.g. the type of QR codes you will read, their orientation, how they will be photographed?
QR codes were developed for use on assembly lines. To ensure a successful project I would assume that my camera was mounted on an assembly line and I would have these limitations on the scope;
The system will correctly decode 98% of QR code images.
The QR codes will all be Version 1 (21 x 21)
The QR codes will all have the same orientation
The sides of the QR code will be parallel with the sides of the image
The QR code will be completely within the image
The QR code will be as large as possible within the image
The image will be in Black & White i.e. Grayscale (if possible)
The image will be at the most suitable resolution (probably the lowest resolution the camera can take)
The image will be in the simplest format possible (monochrome BMP ?)
The lighting will be good and the same for all images
The above limits on the project scope result in something achievable that can be done on an Arduino.
Without such limits the project could involve complex rules, maths, geometery, and even AI and neural nets and be well beyond what an Arduino can do.
This project breaks down into three sequential parts;
Capture good quality images of QR codes into files on SD
Read the SD file and generate the QR code in a small array in memory
Extract the data from the QR code in the array
These three steps are independent and can be programmed simultaneously.
Steps 2 & 3 can be done fastest by programming them in C++ on a PC and then integrating the code on an Arduino later.
Hi !
In fact, we changed our minds. Apparently, the Arduino is very bad to recognize images, so what we will do is to analyse the QR codes with a mobile app and then send the information to the Arduino card. It will be much more easier for us ! Now we just have to search how to send the information to the Arduino...
Anyway, thanks a lot for all your precise and great anwsers, much appreciated !
sungjung:
Hi !
In fact, we changed our minds. Apparently, the Arduino is very bad to recognize images, so what we will do is to analyse the QR codes with a mobile app and then send the information to the Arduino card. It will be much more easier for us ! Now we just have to search how to send the information to the Arduino...
Anyway, thanks a lot for all your precise and great anwsers, much appreciated !
It would have been an interesting project and you would have learned a lot doing it. I did think it might have been a bit of a challenge though depending on what your skills and timescales are.
It is not a particularly easy project, but it should be possible if you can make the image recognition as simple as possible.
As well as saying you will use Version 1 codes it would be a good idea to further restrict things by specifying the data type and the mask.
It would help you gave some background about yourselves;
how many of you are there?
How many PCs/laptops do you have access to?
What relevant skills do you have; programming, knowledge of image file formats, English (there is a French section on this website)?
Is this an assignment and, if so, what is the deadline for completion?
Can you set the objectives of the project so that you set targets that you can achieve e.g. the type of QR codes you will read, their orientation, how they will be photographed?
In post #12 I included a QR code as a boolean array in some C++ code. On a PC try to add your own code to decode the array (I may have made errors in initialising the array so check it matches the image). If you think you can tackle that then you can probably manage the other two aspects of the project - a lot depends on timescales.
P.S. although I put the QR code in a boolean array to make it obvious it was a 21 x 21 array of binary values it is possible it might be easier to manipulate in another data type
As i though storing the QR code in a bool array is probably not going to be the easiest way to process it. This is because the booleans, although binary values, are actually going to be stored in 8 bits.
Try this code on an Arduino (I don't have one to hand);
Code: [Select]
I expect the output to be 1, 1, 1, 2, 4.
Since your QR codes are going to be 21 bit wide it might be best to store them in in an array of 21 longs i.e. 32 bits x 21.
That should make masking quicker and easier.