1
00:00:00,150 --> 00:00:07,500
Hi and welcome back to Section 22, where we take a look at barcode and QR generation as well as reading.

2
00:00:08,040 --> 00:00:11,580
So it's a pretty fun and useful chapter depending on your application.

3
00:00:11,940 --> 00:00:14,830
So let's go ahead and open that notebook.

4
00:00:15,780 --> 00:00:21,360
So let's firstly load an important libraries and actually before I even see we've been putting all libraries.

5
00:00:21,780 --> 00:00:23,400
Let's take a look at the libraries we're installing.

6
00:00:23,730 --> 00:00:30,330
We're installing something called Python Barcode Area, specifying images here and the brackets QR code

7
00:00:30,900 --> 00:00:36,630
Lib Zeba, which is a very powerful barcode and QR code reading library as well as possible.

8
00:00:36,960 --> 00:00:38,730
So we have to install all of these here.

9
00:00:39,180 --> 00:00:40,100
So let's run this.

10
00:00:40,110 --> 00:00:44,310
It may take a little while to install because it's four different packages that we're installing right

11
00:00:44,310 --> 00:00:44,550
now.

12
00:00:45,240 --> 00:00:47,700
So let's wait for this to finish.

13
00:00:48,000 --> 00:00:49,440
Should, shouldn't take that long.

14
00:00:55,280 --> 00:00:55,710
There we go.

15
00:00:55,730 --> 00:00:58,040
So it took twenty six seconds to complete.

16
00:00:58,760 --> 00:00:59,720
So that's not too bad.

17
00:00:59,930 --> 00:01:05,840
So now we can use our barcode and QR code reading and decoding libraries.

18
00:01:06,440 --> 00:01:09,530
So the first one we're going to take a look at is barcode generation.

19
00:01:10,010 --> 00:01:19,580
So barcodes, as you know, barcodes are just line representations of symbol of what it's coded information

20
00:01:20,000 --> 00:01:27,030
that we can decode and basically be a text or digits or any sort of information relative to store barcodes.

21
00:01:27,050 --> 00:01:29,030
Or we we can store information effectively.

22
00:01:29,480 --> 00:01:31,490
So it's type of like coding system.

23
00:01:32,690 --> 00:01:36,110
So you can see this is the barcode every generated here.

24
00:01:36,110 --> 00:01:41,120
So let's just run this website and you can put any number you want here.

25
00:01:41,150 --> 00:01:42,230
This is an entity.

26
00:01:42,710 --> 00:01:44,630
So that's 15 digit number, I believe.

27
00:01:45,260 --> 00:01:47,440
So you can store this number here.

28
00:01:47,450 --> 00:01:47,720
It can.

29
00:01:47,720 --> 00:01:52,030
You can create any number you want here, and it generates the barcode representing that number.

30
00:01:52,030 --> 00:01:58,760
I can see the backwards, depending on the thickness of the line represents that represents some bits

31
00:01:58,760 --> 00:02:02,100
of information gaps as well.

32
00:02:02,120 --> 00:02:07,730
Thin Line So it's a coding system, as I said, for including information here.

33
00:02:07,790 --> 00:02:12,530
And the reason we use barcodes in the real world is because we have this little infrared scanners,

34
00:02:12,530 --> 00:02:16,190
which you see in groceries everywhere there was able to read barcodes.

35
00:02:16,420 --> 00:02:19,400
They're quite effective at decoding that information quickly.

36
00:02:19,410 --> 00:02:24,800
So it's a very useful way to store information that that that is tied to the data.

37
00:02:26,120 --> 00:02:27,830
So now let's take a look at QR codes.

38
00:02:28,340 --> 00:02:30,140
So QR codes are a bit different.

39
00:02:30,230 --> 00:02:32,660
They're abbreviated to short for quick response.

40
00:02:32,660 --> 00:02:32,960
Good.

41
00:02:33,410 --> 00:02:38,810
And it's sort of like a matrix like barcodes, a two dimensional barcode that was developed in the automotive

42
00:02:38,810 --> 00:02:39,740
industry in Japan.

43
00:02:39,920 --> 00:02:45,110
And there are different types of QR codes, lots of different epic QR codes, as you can see with barcodes,

44
00:02:45,110 --> 00:02:49,940
or lots of different types of barcodes as well, and specify the type you want to include by using the

45
00:02:49,940 --> 00:02:52,100
function here would have one, whichever one you're looting.

46
00:02:53,240 --> 00:02:56,270
So your codes follows similar suit.

47
00:02:56,630 --> 00:02:59,990
However, there's a standard generic type of QR code that we all use.

48
00:03:00,470 --> 00:03:01,570
So it doesn't.

49
00:03:01,590 --> 00:03:04,580
There's not as much variety of QR codes.

50
00:03:04,850 --> 00:03:12,050
However, there are configurations we can do in QR codes that affect the area, coding in it or decoding.

51
00:03:12,620 --> 00:03:18,250
There's some redundant information or coded information of checksums.

52
00:03:18,680 --> 00:03:23,750
I'm not sure if you know a checksums are because you're taught to make undergrad computer science and

53
00:03:23,750 --> 00:03:30,710
engineering, but in a way you can sum up information to see if that sum is corresponds to the correct

54
00:03:30,710 --> 00:03:32,000
sum in parts of information.

55
00:03:32,000 --> 00:03:34,580
That's a we of error checking your information.

56
00:03:35,270 --> 00:03:42,290
So using the input your QR code library that we import here, we're declaring this here.

57
00:03:42,290 --> 00:03:45,980
We're creating this object here, which is the vision error correction.

58
00:03:47,150 --> 00:03:48,560
You can take a look at this problem to see it.

59
00:03:48,560 --> 00:03:50,330
This is what these parameters stand for.

60
00:03:50,840 --> 00:03:51,710
Error correction.

61
00:03:52,490 --> 00:03:54,530
This means that only seven percent of errors can be corrected.

62
00:03:54,530 --> 00:03:59,540
But if we use each hire correction, you can correct about 30 percent of errors, which makes it quite

63
00:03:59,540 --> 00:04:00,200
resilient.

64
00:04:00,350 --> 00:04:03,310
So you can read it for angles, for lighting.

65
00:04:03,350 --> 00:04:07,910
So it's probably better to encode your QR codes with that once information can fit.

66
00:04:08,540 --> 00:04:13,670
Because just remember, every time you increase the error correction, you reduce the amount of information

67
00:04:13,670 --> 00:04:16,100
that you can store in your QR code.

68
00:04:16,460 --> 00:04:19,880
So to make the QR code all you do, it's quite simple.

69
00:04:19,890 --> 00:04:24,090
Once you create this object, when you define the parameters here, you just add data.

70
00:04:24,110 --> 00:04:26,740
This is the string data we want to put up in the fog.

71
00:04:27,980 --> 00:04:32,750
We just added QR added to cure or make rapid 50 go through.

72
00:04:33,410 --> 00:04:36,200
And then we just make the image here as well.

73
00:04:36,200 --> 00:04:42,770
And then we save the images using pill collaborative model image processing library, which is similar

74
00:04:42,770 --> 00:04:49,230
to open TV, but not as in-depth, but it has some quite some very useful functions in pill.

75
00:04:49,340 --> 00:04:56,180
So it's a good library to use, and this is how we just read, then displayed a QR code at the end here.

76
00:04:56,420 --> 00:04:58,970
So let's run this quite quick generate.

77
00:05:00,080 --> 00:05:02,330
And you can see this is of a QR code we generated here.

78
00:05:02,930 --> 00:05:05,780
So that's it for generating QR codes.

79
00:05:05,840 --> 00:05:07,280
What about decoding them, though?

80
00:05:07,640 --> 00:05:12,500
So to decode Akira, could this just decoded what we we included before?

81
00:05:13,010 --> 00:05:15,020
It gives us the output here, which is openness.

82
00:05:15,020 --> 00:05:18,620
In order to do that, you just open the image.

83
00:05:18,620 --> 00:05:22,250
You use the decoded function from Bob Paisley, Boss Lab.

84
00:05:22,250 --> 00:05:25,910
We know we're going to use to read or decode our QR codes.

85
00:05:26,450 --> 00:05:32,150
And it's quite simple in this how the results you are created a result to specifying what type of data

86
00:05:32,150 --> 00:05:34,250
you want to decode, which is UTF eight.

87
00:05:34,820 --> 00:05:36,110
And it just gives us the outputs.

88
00:05:36,110 --> 00:05:37,520
It's quite simple to use.

89
00:05:37,940 --> 00:05:43,760
Now let's test this decoder on a different image, an image that is a real image like this.

90
00:05:44,060 --> 00:05:48,470
So and you see, we have a robust function here, robust bit of good.

91
00:05:48,920 --> 00:05:53,630
That's because of what we're doing with this code is that we're plotting the bounding box that we extract

92
00:05:53,630 --> 00:05:54,680
from the decode function.

93
00:05:54,910 --> 00:06:01,320
So they could call it backwards, but it's really the QR codes of achieving the change of codes.

94
00:06:01,720 --> 00:06:02,020
Sure.

95
00:06:03,790 --> 00:06:05,680
So we look over codes here.

96
00:06:06,550 --> 00:06:09,670
We see it's live music for no good excuse not to function.

97
00:06:10,330 --> 00:06:11,440
Get two rectangles.

98
00:06:11,440 --> 00:06:16,090
Print the there are tango bounding box polygon here just for information.

99
00:06:16,100 --> 00:06:19,900
That's what this is here, so we can take a look at it.

100
00:06:20,800 --> 00:06:27,700
Then we draw the bounding box here using the open TV poly lines function, and then we just extract

101
00:06:27,700 --> 00:06:29,230
the text, which you've seen before.

102
00:06:30,320 --> 00:06:36,780
Get the text type so we can actually format it properly in the image because we need to do that for

103
00:06:36,780 --> 00:06:44,020
open TV to put the text in the string of the text as a string into the image, and then we just generate

104
00:06:44,020 --> 00:06:44,860
the file image.

105
00:06:44,980 --> 00:06:48,610
In the end, looks barcode data isn't defined.

106
00:06:49,030 --> 00:06:51,190
Let's take a look and see what that is.

107
00:06:56,420 --> 00:06:58,400
That should be ball context here.

108
00:07:01,290 --> 00:07:05,430
And Barbara Typekit, so let's run this function again.

109
00:07:06,270 --> 00:07:07,080
Get the output.

110
00:07:09,210 --> 00:07:09,690
There we go.

111
00:07:10,020 --> 00:07:15,220
So you can see we drew a bounding box exactly because around the image, because if you were to use

112
00:07:15,220 --> 00:07:18,180
their normal bounding box, we would have to use it would just be a box to us.

113
00:07:18,180 --> 00:07:21,030
We have been completely in gaps that are good.

114
00:07:21,480 --> 00:07:27,570
So by using lines, we actually get the lines, the exact angle that lines, that includes the QR code.

115
00:07:28,020 --> 00:07:29,210
We put the website.

116
00:07:29,220 --> 00:07:30,030
So it's is written.

117
00:07:30,030 --> 00:07:33,120
I suppose that's an image QR code image.

118
00:07:33,120 --> 00:07:34,860
I found the Google images that I'm using here.

119
00:07:35,700 --> 00:07:38,100
And this tells us where the QR code is, obviously.

120
00:07:38,760 --> 00:07:41,430
So let's take a look at reading barcodes now.

121
00:07:41,730 --> 00:07:45,360
So let's load a barcode image here and now.

122
00:07:45,360 --> 00:07:50,850
Let's use the same possible function to almost the exact same court here, except slightly different

123
00:07:51,270 --> 00:07:54,330
to read the barcode and plot the barcode data.

124
00:07:54,660 --> 00:07:56,310
So again, I have the data

125
00:07:58,980 --> 00:08:01,350
don't have the TypeScript and variable names correct?

126
00:08:03,560 --> 00:08:10,430
So let's take a look at the output now, and you can see Ta DA said, read, read this barcode, you

127
00:08:10,940 --> 00:08:12,240
didn't read this barcode here.

128
00:08:12,260 --> 00:08:14,330
Maybe we can inspected food to see why.

129
00:08:15,200 --> 00:08:18,500
Actually, no, it's the same different barcode twice.

130
00:08:19,040 --> 00:08:21,500
So this is the output right here.

131
00:08:21,650 --> 00:08:22,500
So that's pretty cool.

132
00:08:22,940 --> 00:08:28,340
So you can see now we can read barcodes in real life images as well as your codes.

133
00:08:28,670 --> 00:08:35,600
So that's it for this lesson will now move on to YOLO, which is an object detector state of the art

134
00:08:35,600 --> 00:08:36,410
object detector.

135
00:08:36,800 --> 00:08:41,900
We're going to look at using the Eurovision treat this Eurovision five now Eurovision five and your

136
00:08:41,930 --> 00:08:43,040
vision for almost the same.

137
00:08:43,490 --> 00:08:49,800
Since it's a visionary, it's still quite good, and we can use a pre-trained model directly in open

138
00:08:49,800 --> 00:08:53,540
TV, and it's quite effective, quite fast and quite easy to use.

139
00:08:53,930 --> 00:08:55,220
So stay tuned for that lesson.

140
00:08:55,370 --> 00:08:55,790
Thank you.
