1. Homepage
  2. Programming
  3. 159731 Studies in Computer Vision - Assignment 2: 2D barcode

159731 Studies in Computer Vision - Assignment 2: 2D barcode

Engage in a Conversation
Massey159731Studies in Computer VisionC++OpenCV2D barcode

Due: 24/4/2024 CourseNana.COM

159731 Assignment 2 CourseNana.COM

Your task is to write a program that reads a colour 2D barcode. CourseNana.COM

The 2D barcodes may be rotated, scaled and slightly distorted and use a simple encoding with 8 colours. The colours are black, blue, green, cyan, red, magenta, yellow, and white. These colours represent three bits. Notice that there is a relationship with the RGB colour space (e.g., black is 0 (0,0,0), blue is 1 (0,0,255), and green is 2 (0,255,0) etc). CourseNana.COM

There are 64 characters that can be encoded: the digits 0~9, the lower case a~z, the upper case A~Z, a full stop '.' and space. The encoding table can be found on Stream. The encoding of text is done top-left to bottom-right (just like scanning an image) on a 47*47 grid of small squares with 3 6*6 squares missing from the data. The missing squares are used for blue circular registration markers. Every two squares of colours represents one of the 64 characters (3bits + 3bits). The maximum number of characters in one barcode is 1050. The last square (bottom right) is left unused. CourseNana.COM

An example of encoding: char 'a' is 1. Therefore, it’s bit representation is 000001. Dividing this 6 bit group into two groups, we have 000 and 001. The first square should be black (0,0,0) for R=0, G=0 and B=0 and the second square should be blue (0,0,1) for R=0, G=0 and B=255. Each square block of colour represents 3 bits, and a pair of squares represent a single character. CourseNana.COM

An example of decoding: two squares red and yellow. Red is represented by (255,0,0) and yellow is (255,255,0) in RGB. So red is 100 and yellow is 110. Putting the two together, 100110 (38 in decimal) is 'L' in the table. Therefore, red/yellow is decoded as 'L'. CourseNana.COM

Figure 1. a) an empty 2D bar showing the concentric circles.
b) an example of encoding all possible characters in order (see table 1 on the next page).
CourseNana.COM

In figure 1 two examples of the 2D bar are shown. The concentric circles can be used for aligning the 2D bar when the image is rotated. The centres of the concentric circles can also be used to locate the squares properly when the image is scaled and rotated. The lines between the squares could also be used to rotate the 2D bar to a horizontal position. CourseNana.COM

CourseNana.COM

Notes: CourseNana.COM

  1. 1)  Initially, work with an unrotated and unscaled barcode. It will be easier to debug decoding problems. CourseNana.COM

  2. 2)  Use a combination of Hough transforms for circles and/or lines to find the circular markers and re-orient the image. The triangle formed by the markers should be a right angle triangle with the right angle bottom left. You can use the distance between the marker points to figure out which of them should be the right angle. CourseNana.COM

  3. 3)  You may want to use some of the following opencv functions - getRotationMatrix2D(), getAffineTransform() and warpAffine(). CourseNana.COM

  4. 4)  Once you have the image properly positioned, start reading the colours from upper-left to bottom-right, reading two squares at a time. For example, A is encoded as 27 (011011) and G as 33 (100001). Therefore A is encoded with 011 (cyan) 011 (cyan) and G is encoded as 100 (red) 001 (blue). CourseNana.COM

  5. 5)  Figure 1-b shows the following pattern: <space>abcd...zABCD...Z12..9<stop> repeating and ending with the character ‘y’. This is the same order in which the characters are encoded ('space' is 000000, '.' is 111111, 'a' is 000001 etc). CourseNana.COM

  6. 6)  Remember that the last square (bottom-right of the 2D bar) does not encode anything, as it cannot pair up with any other square. CourseNana.COM

  7. 7)  The encoding/decoding table is: (use the array available on Stream) CourseNana.COM

  8. 8)  The colours present in the barcode are: CourseNana.COM

    black (0,0,0), red (255,0,0), green (0,255,0), blue (0,0,255), white (255,255,255), cyan (0,255,255), magenta (255,0,255) and yellow (255,255,0). Notice that the eight colours give all the possible states for a 3 bit word. CourseNana.COM

  9. 9)  There are many ways to re-orient, scale and align the image, so each colour can be extracted. Try to make your code as robust as possible. I will test your code on images that are not available to you. CourseNana.COM

Your code must be in C++, you must use OpenCV version 4 or later. Use the CMake example provided to make sure I can compile your code. Submit a single .cpp file on stream (no zip files), if your solution does not compile and run on my machine, you will lose marks. Your program should take a single parameter, the name of the file containing the barcode image and print the text of the barcode. CourseNana.COM

You can test your solution using the images available on Stream. The assignment is worth 10 marks. CourseNana.COM

5 marks for correctly decoding static upright test images. CourseNana.COM

5 marks for correctly decoding rotated, noisy, scaled and slightly distorted images. CourseNana.COM

3 bonus marks: for dynamic detection and interpretation (e.g. using the camera). CourseNana.COM

(there is a maximum of 10 marks available, the bonus marks won’t give you more than 10/10 but could help you get 10/10 if for example your algorithm fails on some rotated barcodes) CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
Massey代写,159731代写,Studies in Computer Vision代写,C++代写,OpenCV代写,2D barcode代写,Massey代编,159731代编,Studies in Computer Vision代编,C++代编,OpenCV代编,2D barcode代编,Massey代考,159731代考,Studies in Computer Vision代考,C++代考,OpenCV代考,2D barcode代考,Masseyhelp,159731help,Studies in Computer Visionhelp,C++help,OpenCVhelp,2D barcodehelp,Massey作业代写,159731作业代写,Studies in Computer Vision作业代写,C++作业代写,OpenCV作业代写,2D barcode作业代写,Massey编程代写,159731编程代写,Studies in Computer Vision编程代写,C++编程代写,OpenCV编程代写,2D barcode编程代写,Masseyprogramming help,159731programming help,Studies in Computer Visionprogramming help,C++programming help,OpenCVprogramming help,2D barcodeprogramming help,Masseyassignment help,159731assignment help,Studies in Computer Visionassignment help,C++assignment help,OpenCVassignment help,2D barcodeassignment help,Masseysolution,159731solution,Studies in Computer Visionsolution,C++solution,OpenCVsolution,2D barcodesolution,