Go Down

Topic: Need help for an Arduino project (Read 1 time) previous topic - next topic

wvmarle

Bluetooth or WiFi come to mind as easy solutions.

If you go for WiFi look into the WeMOS and NodeMCU boards (based on the ESP8266 processor with built-in WiFi).
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

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

sungjung

So, we changed our minds AGAIN because you said some good arguments :) The code looks very hard but not impossible. Let's try this !

ardly

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;
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?

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

ardly

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]
Code: [Select]
    Serial.println(sizeof(bool));
    Serial.println(sizeof(boolean));
    Serial.println(sizeof(unsigned char));
    Serial.println(sizeof(unsigned int));
    Serial.println(sizeof(unsigned long));



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

ardly

Here is the same QR code as before but stored in an unsigned long array. This saves memory, since the bool actually uses a byte. However it will also make masking and extracting groups of bits easier. Try to add code to decode the QR code. I suggest this is done on a PC as you will develop the code much faster, then port it onto an Arduino.

Code: [Select]
#include <iostream>

using namespace std;

int main()
{
    unsigned int line,bit;// instead of unsigned int use unsinged long on the Arduino (32 bits)
    
    /*
        The bits of a QR code could be stored in the array elements in various way.
        I decided to store them in the high order bits of elements because I felt it
        made converting the hex numbers into a QR image by hand easier
    */
    
    unsigned int qr[21]=
    {
        0xFEBBF800,
        0x82320800,
        0xBAD2E800,
        0xBACAE800,
        0xBA92E800,
        0x827A0800,
        0xFEABF800,
        0x00180000,
        0xF2FCE800,
        0xA9FFE800,
        0x26951800,
        0x3C915000,
        0xF3AE0800,
        0x00F32800,
        0xFE3F8000,
        0x82457800,
        0xBA286000,
        0xBA827000,
        0xBAC92000,
        0x82D78800,
        0xFEB72000
    }; // Each element stores a 21 bit row of the QR code in its highest order bits i.e. lowest 11 bits of the 32 bit elements are zero
    
    for(int irow=0;irow<21;++irow)// process each row in the QR code
    {
        line=qr[irow];// copy the row
        for(int icol=0;icol<21;++icol)// process each bit in the QR code row
        {
            bit=line&0x80000000;// get the highest order bit
            line=line<<1;// shift all the bits left by one
            
            // Display 'X' if the highest order bit was 1 and O if it was 0
            if(bit!=0)
            {
                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

ardly

Have you had any success in capturing imaged to SD using the OV7670 ?
It has 640 x 480 resolution and supports RAW RGB which may be the way to go.


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

sungjung

Hi, just a question :
in our project, the QR codes are useful because they allow us to associate each book with a subject. There's 6 books and 6 QR codes, so we think that we could put the 6 QR codes in the Arduino, and with the camera, compare the "basic" QR codes with the recognized QR codes. We think it would be easier to translate a QR code from nothing. How we should code this ?

Thanks again for everything you did for us, much appreciated !

lastchancename

Is there a specific need in the target application for QR codes?
Sure they bring flexibility and additional symbol complexity, but your project may run a lot faster, easier and simpler with simple 2D barcodes...?
And it will easily fit in a small Arduino.
When posting - use the toolbar and read the stickies if you're not sure!  </code> tags are our friend!
You can lead a plug to an outlet, but you can't make them turn it on.

ardly

Hi, just a question :
in our project, the QR codes are useful because they allow us to associate each book with a subject. There's 6 books and 6 QR codes, so we think that we could put the 6 QR codes in the Arduino, and with the camera, compare the "basic" QR codes with the recognized QR codes. We think it would be easier to translate a QR code from nothing. How we should code this ?

Thanks again for everything you did for us, much appreciated !

Six QR codes could be easily stored in memory in an array, just as I did with my example code in post #20.
It would then be possible to take a photograph of a QR code and compare it against the stored codes to find a match. You would need to convert the image into an array but you would not need to actually decode the QR code.

However that is a very crude way of doing things and is not scaleable. It will work for six books but not for six thousand (too slow, too much memory needed). It also means you need to know in advance every QR code that you might photograph, which seems an unrealistic situation.

Consider a library. The books will all have International Standard Book Numbers (ISBN). They will also have a classification number such as Dewey Decimal Classification (DDC). These numbers could be held in QR codes. There will be thousands of books though with new books arriving all the time. In that situation you really need to be able to read the codes.

Why don't you post images of the six QR codes you have, then have a go at writing a sketch to decode them. In this situation you really just need to get your head down and work at it. Take it a bit at a time. Write a function that reads the QR code version and when that works add a function to read the QR code mask used and so on.

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

ardly

I think post #22 was the first time you mentioned books and you have not answered earlier questions.
You will need to check that a Version1 QR code can store sufficient information for your application.
"Facts do not cease to exist because they are ignored" - Aldous Huxley

sungjung

Thanks again for your reply, sorry if we came to you as ungrateful.
The thing is that it's the first time we work with Arduino, and we have limited knowledge about this stuff, so your explications, while useful, are still pretty complex for us. We understand what the process should be, but it's when we have to write the code that we have some problems.

ardly

Thanks again for your reply, sorry if we came to you as ungrateful.
The thing is that it's the first time we work with Arduino, and we have limited knowledge about this stuff, so your explications, while useful, are still pretty complex for us. We understand what the process should be, but it's when we have to write the code that we have some problems.
That is why questions were asked about how many of you there are and what your knowledge and experience is, so that answers and suggestions given were appropriate to you.

You described yourselves as "young electronics students", does that mean you are University students or School students?
Since you are studying electronics you must already know about logical bit operations such as AND, OR and XOR is that correct?

Do you have a deadline for this project?
Have you attempted to write any code ?

Copy the program given in reply #20
Go to the website;
https://www.tutorialspoint.com/compile_cpp_online.php
Execute the code

Do you understand the program and what it is doing, if not ask questions.
Then modify the program by adding a function to extract the QR code version number and display it.

If you get stuck post your code and ask questions.
People will get help if you make an effort yourself.









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

sungjung

To answer your questions :

- We are students in High School
- Yes, we know those logical operations
- The deadline is in early May, but there's not only the programming, there's a lot of things to do
- Yes we wrote other codes to control a LCD screen, motor drivers, buzzers, etc...

So we will test your code and see how it will work. Thank you !

ardly

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 !
Although you said "young" because you said "electronics students" I thought you might be at University.
Since you know about logic operations and have done some programming this should still be possible.
Your first post was in Jan though so you have wasted 4 weeks, unless other things have been happening.

How many of you are there?

Have you managed to take a photograph of a QR code with the Arduino meeting the restrictions in reply #10 ?
"Facts do not cease to exist because they are ignored" - Aldous Huxley

Go Up