Go Down

Topic: Need help for an Arduino project (Read 297 times) previous topic - next topic

sungjung

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.

Any ideas is welcome !
Thanks in advance,
cheers.

PS : We are French, so sorry if there's mistakes.

MichaelEvans

Did u look on the internet ?
I'm sure there are plenty of arduino programs on the web

I hope u'll find ur progrm.

cheers


sungjung

Thank you for the reply.
Yes, we searched, we found some programs, but they're often too complex and doens't have the same goals as ours.

ardly

Bonjour,

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?
"Facts do not cease to exist because they are ignored" - Aldous Huxley

sungjung

Thanks for replying.
To answer your questions : no, no and no.  : :smiley-confuse:

ardly

Thanks for replying.
To answer your questions : no, no and no.  : :smiley-confuse:
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.



"Facts do not cease to exist because they are ignored" - Aldous Huxley

sungjung

We connected the camera to the Arduino, maybe we should bring a SD, you're right ;)

MichaelEvans

Very interesting idea u've just came out with.

I'll just suggest printing big and swole QR codes so that the camera can read them

ardly is right, u need to use a SD card to save the pictures, but u can erase them when u're done

Cheers

wvmarle

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.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

ardly

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;

1. how many of you are there?
2. How many PCs/laptops do you have access to?
3. What relevant skills do you have; programming, knowledge of image file formats, English (there is a French section on this website)?
4. Is this an assignment and, if so, what is the deadline for completion?
5. 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?



"Facts do not cease to exist because they are ignored" - Aldous Huxley

ardly

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;

1. The system will correctly decode 98% of QR code images.
2. The QR codes will all be Version 1 (21 x 21)
3.  The QR codes will all have the same orientation
4. The sides of the QR code will be parallel with the sides of the image
5. The QR code will be completely within the image
6. The QR code will be as large as possible within the image
7. The image will be in Black & White i.e. Grayscale (if possible)
8. The image will be at the most suitable resolution (probably the lowest resolution the camera can take)
9. The image will be in the simplest format possible (monochrome BMP ?)
10. 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.
"Facts do not cease to exist because they are ignored" - Aldous Huxley

ardly

This project breaks down into three sequential parts;

1. Capture good quality images of QR codes into files on SD
2. Read the SD file and generate the QR code in a small array in memory
3. 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.

"Facts do not cease to exist because they are ignored" - Aldous Huxley

ardly

#12
Jan 14, 2018, 08:09 pm Last Edit: Jan 14, 2018, 08:13 pm by ardly
Below are a gif of a QR code what does it say?
Also below is a 21 x 21 array which (unless I have made an error) should contain the same QR code.

The outcome of step 2 in my previous post should be an array like this.
For step 3 you just need to write code to extract the data from the array.

The code can be run online here;
https://www.tutorialspoint.com/compile_cpp_online.php
https://www.tutorialspoint.com/compile_cpp_online.php

Code: [Select]

#include <iostream>

using namespace std;

int main()
{
    
    bool qr[21][21]=
    {
        true ,true ,true ,true ,true ,true ,true ,false,true ,false,true ,true ,true ,false,true ,true ,true ,true ,true ,true ,true ,
        true ,false,false,false,false,false,true ,false,false,false,true ,true ,false,false,true ,false,false,false,false,false,true ,
        true ,false,true ,true ,true ,false,true ,false,true ,true ,false,true ,false,false,true ,false,true ,true ,true ,false,true ,
        true ,false,true ,true ,true ,false,true ,false,true ,true ,false,false,true ,false,true ,false,true ,true ,true ,false,true ,
        true ,false,true ,true ,true ,false,true ,false,true ,false,false,true ,false,false,true ,false,true ,true ,true ,false,true ,
        true ,false,false,false,false,false,true ,false,false,true ,true ,true ,true ,false,true ,false,false,false,false,false,true ,
        true ,true ,true ,true ,true ,true ,true ,false,true ,false,true ,false,true ,false,true ,true ,true ,true ,true ,true ,true ,
        false,false,false,false,false,false,false,false,false,false,false,true ,true ,false,false,false,false,false,false,false,false,
        true ,true ,true ,true ,false,false,true ,false,true ,true ,true ,true ,true ,true ,false,false,true ,true ,true ,false,true ,
        true ,false,true ,false,true ,false,false,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,false,true ,
        false,false,true ,false,false,true ,true ,false,true ,false,false,true ,false,true ,false,true ,false,false,false,true ,true ,
        false,false,true ,true ,true ,true ,false,false,true ,false,false,true ,false,false,false,true ,false,true ,false,true ,false,
        true ,true ,true ,true ,false,false,true ,true ,true ,false,true ,false,true ,true ,true ,false,false,false,false,false,true ,
        false,false,false,false,false,false,false,false,true ,true ,true ,true ,false,false,true ,true ,false,false,true ,false,true ,
        true ,true ,true ,true ,true ,true ,true ,false,false,false,true ,true ,true ,true ,true ,true ,true ,false,false,false,false,
        true ,false,false,false,false,false,true ,false,false,true ,false,false,false,true ,false,true ,false,true ,true ,true ,true ,
        true ,false,true ,true ,true ,false,true ,false,false,false,true ,false,true ,false,false,false,false,true ,true ,false,false,
        true ,false,true ,true ,true ,false,true ,false,true ,false,false,false,false,false,true ,false,false,true ,true ,true ,false,
        true ,false,true ,true ,true ,false,true ,false,true ,true ,false,false,true ,false,false,true ,false,false,true ,false,false,
        true ,false,false,false,false,false,true ,false,true ,true ,false,true ,false,true ,true ,true ,true ,false,false,false,true ,
        true ,true ,true ,true ,true ,true ,true ,false,true ,false,true ,true ,false,true ,true ,true ,false,false,true ,false,false
    };
  
   // C++ arrays are stored in row-major order. Row-major order means the last subscript varies the fastest.
   for(int irow=0;irow<21;++irow)
   {
       for(int icol=0;icol<21;++icol)
       {
           if(qr[irow][icol])
           {
               printf("X");
           }
           else
           {
               printf("O");
           }
       }
       printf("\n");
   }
  
   return 0;
}


Output;

$g++ -o main *.cpp
$main
XXXXXXXOXOXXXOXXXXXXX
XOOOOOXOOOXXOOXOOOOOX
XOXXXOXOXXOXOOXOXXXOX
XOXXXOXOXXOOXOXOXXXOX
XOXXXOXOXOOXOOXOXXXOX
XOOOOOXOOXXXXOXOOOOOX
XXXXXXXOXOXOXOXXXXXXX
OOOOOOOOOOOXXOOOOOOOO
XXXXOOXOXXXXXXOOXXXOX
XOXOXOOXXXXXXXXXXXXOX
OOXOOXXOXOOXOXOXOOOXX
OOXXXXOOXOOXOOOXOXOXO
XXXXOOXXXOXOXXXOOOOOX
OOOOOOOOXXXXOOXXOOXOX
XXXXXXXOOOXXXXXXXOOOO
XOOOOOXOOXOOOXOXOXXXX
XOXXXOXOOOXOXOOOOXXOO
XOXXXOXOXOOOOOXOOXXXO
XOXXXOXOXXOOXOOXOOXOO
XOOOOOXOXXOXOXXXXOOOX
XXXXXXXOXOXXOXXXOOXOO




"Facts do not cease to exist because they are ignored" - Aldous Huxley

TomGeorge

We connected the camera to the Arduino, maybe we should bring a SD, you're right ;)

Please describe by what you mean "connected"?
Have you got some code that works and proves you have the camera "connected"?
Thanks.. Tom.. :)
Everything runs on smoke, let the smoke out, it stops running....

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 !

Go Up