Repository navigation
Expand file tree
/
Copy path011-pyimagesearch.vtt
More file actions
2333 lines (1555 loc) · 70.7 KB
/
Copy path011-pyimagesearch.vtt
File metadata and controls
2333 lines (1555 loc) · 70.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
WEBVTT
00:00:00.001 --> 00:00:02.540
Does a computer see in color or black and white?
00:00:02.540 --> 00:00:06.700
It's time to find out on episode 11 of Talk Python To Me
00:00:06.700 --> 00:00:08.960
with our guest, Adrian Rosebrock,
00:00:08.960 --> 00:00:12.040
recorded Thursday, May 20th, 2015.
00:00:12.040 --> 00:00:42.020
Welcome to Talk Python To Me.
00:00:42.020 --> 00:00:45.160
A weekly podcast on Python, the language, the libraries,
00:00:45.160 --> 00:00:47.000
the ecosystem, and the personalities.
00:00:47.000 --> 00:00:48.840
This is your host, Michael Kennedy.
00:00:48.840 --> 00:00:51.380
Follow me on Twitter where I'm @mkennedy
00:00:51.380 --> 00:00:54.000
and keep up with the show and listen to past episodes
00:00:54.000 --> 00:00:55.900
at talkpythontome.com.
00:00:55.900 --> 00:00:58.820
This episode, we'll be talking with Adrian Rosebrock
00:00:58.820 --> 00:01:03.240
about computer vision, OpenCV, and PyImage Search.
00:01:03.240 --> 00:01:05.740
Hello, everyone.
00:01:05.740 --> 00:01:08.780
I have a bunch of cool news and announcements for you this week.
00:01:08.940 --> 00:01:11.960
First, this show on PyImage Search
00:01:11.960 --> 00:01:13.760
is a listener-suggested show.
00:01:13.760 --> 00:01:16.180
Thank you to J.I. Lorenzetti
00:01:16.180 --> 00:01:18.660
for reaching out to me and suggesting this topic.
00:01:18.660 --> 00:01:21.100
You can find his contact details in the show notes.
00:01:21.100 --> 00:01:24.900
As always, I'm also excited to be able to tell you
00:01:24.900 --> 00:01:27.680
that this episode is brought to you by CodeShip.
00:01:27.680 --> 00:01:30.980
CodeShip is a platform for continuous integration
00:01:30.980 --> 00:01:33.060
and continuous delivery as a service.
00:01:33.060 --> 00:01:36.000
Please take a moment and check them out at codeship.com
00:01:36.000 --> 00:01:38.440
or follow them on Twitter where they're at codeship.
00:01:38.440 --> 00:01:42.020
Did you know that most of our shows come with full transcripts
00:01:42.020 --> 00:01:43.900
and a cool little search filter feature?
00:01:43.900 --> 00:01:46.480
If you're looking for something you hear in an episode,
00:01:46.480 --> 00:01:49.000
just click the full transcript button on the episode page
00:01:49.000 --> 00:01:49.960
and search for it.
00:01:49.960 --> 00:01:52.360
Also, I want to say thank you to everyone
00:01:52.360 --> 00:01:55.180
who has been participating in the conversation on Twitter
00:01:55.180 --> 00:01:56.840
where we're at Talk Python.
00:01:57.580 --> 00:02:00.140
It's a great feeling to see all the feedback and thoughts
00:02:00.140 --> 00:02:01.700
every week when we release a new show.
00:02:01.700 --> 00:02:04.420
But if you have something more nuanced to say
00:02:04.420 --> 00:02:06.380
that doesn't fit in 140 characters
00:02:06.380 --> 00:02:09.420
or you want it to be more permanent than Twitter,
00:02:09.420 --> 00:02:13.560
every episode page has a Discus comment section at the bottom.
00:02:13.560 --> 00:02:15.140
I encourage you to post your thoughts there.
00:02:15.140 --> 00:02:18.880
This week, I ran across a really awesome GitHub project
00:02:18.880 --> 00:02:20.520
called Python-Patterns.
00:02:20.520 --> 00:02:22.700
You can find it at GitHub.com
00:02:22.700 --> 00:02:26.460
slash f-a-i-f slash python dash patterns.
00:02:26.460 --> 00:02:29.900
It's a collection of really crisp design patterns
00:02:29.900 --> 00:02:31.760
implemented in a Pythonic manner.
00:02:31.760 --> 00:02:34.060
For example, you'll find patterns such as
00:02:34.060 --> 00:02:37.100
the adapter, builder, chain, decorator, facade,
00:02:37.100 --> 00:02:39.260
and flyweight patterns, just to name a few.
00:02:39.260 --> 00:02:41.180
It's really extensive and pretty cool.
00:02:41.180 --> 00:02:42.860
I think you'll learn something if you check it out.
00:02:42.860 --> 00:02:45.900
Finally, I put together a cool YouTube playlist.
00:02:45.900 --> 00:02:50.620
This is a series of nine lectures from Dr. Philip Gao,
00:02:50.620 --> 00:02:53.240
a professor at the University of Rochester, New York.
00:02:53.240 --> 00:02:58.520
Find him on Twitter where he's at P-G-B-O-V-I-N-E, P-G-Bovine.
00:02:58.520 --> 00:03:01.960
The video series is entitled C Internals,
00:03:01.960 --> 00:03:05.800
a 10-hour code walk through the Python interpreter source code.
00:03:05.800 --> 00:03:10.520
You can find it at bit.ly.com slash cpythonwalk,
00:03:10.520 --> 00:03:12.720
all lowercase, no spaces.
00:03:12.720 --> 00:03:15.580
Also, you'll find all these links in the show notes.
00:03:16.520 --> 00:03:18.780
Now, let's get to the interview with Adrian.
00:03:18.780 --> 00:03:23.800
Let me introduce Adrian.
00:03:23.800 --> 00:03:28.460
Adrian Rosebrock is an author and blogger at pyimagesearch.com.
00:03:28.460 --> 00:03:32.800
He has a PhD in computer science with a focus on computer vision and machine learning
00:03:32.800 --> 00:03:36.020
and has been studying computer vision his entire adult life.
00:03:36.020 --> 00:03:41.720
He has consulted for the National Cancer Institute to develop methods to predict breast cancer risks
00:03:41.720 --> 00:03:48.080
using breast histology images and authored a book, Practical Python and OpenCV,
00:03:48.080 --> 00:03:52.400
on utilizing Python and OpenCV to build real-world computer vision applications.
00:03:52.400 --> 00:03:56.200
Adrian, welcome to the show.
00:03:56.200 --> 00:03:57.060
Oh, thank you.
00:03:57.060 --> 00:03:58.000
It's great to be here.
00:03:58.180 --> 00:04:04.420
I'm very excited about computer vision and sort of merging the real world with computer science,
00:04:04.420 --> 00:04:05.320
with robotics.
00:04:05.320 --> 00:04:07.920
And I think there's just some really neat stuff going on.
00:04:07.920 --> 00:04:10.320
And you're doing a very cool part in that.
00:04:10.320 --> 00:04:11.120
Oh, thank you.
00:04:11.120 --> 00:04:13.340
So we're going to talk about PyImageSearch.
00:04:13.340 --> 00:04:18.600
We're going to talk about OpenCV and some of the challenges and even the future of these types of technologies.
00:04:18.600 --> 00:04:22.940
But before we get there, you know, everyone's interested in how people got started in programming and Python.
00:04:22.940 --> 00:04:23.680
What's your story?
00:04:23.680 --> 00:04:27.400
I started programming when I was in high school.
00:04:27.400 --> 00:04:33.380
I started out with the basics of HTML, JavaScript, CSS, did some basic programming.
00:04:33.380 --> 00:04:36.140
And, you know, I'm probably getting a lot of hate mail about this.
00:04:36.140 --> 00:04:41.960
But when I first started learning how to program, I did not like the Python programming language that much.
00:04:41.960 --> 00:04:45.560
And this was around the early version 2 of Python.
00:04:45.740 --> 00:04:47.760
I didn't like the syntax.
00:04:47.760 --> 00:04:49.420
I didn't like the white space.
00:04:49.420 --> 00:04:52.880
And for a long time, I was really, really put off by Python.
00:04:52.880 --> 00:04:55.640
And that was a huge mistake on my part.
00:04:55.640 --> 00:04:57.120
I don't know what was wrong with me back then.
00:04:57.120 --> 00:04:59.340
I guess it was just high school ignorance or something.
00:04:59.340 --> 00:05:04.620
But by the time I got to college, I started working in Python a lot more.
00:05:04.620 --> 00:05:07.500
And that's especially true in the scientific area.
00:05:07.500 --> 00:05:15.340
You see all these incredible packages in Python like NumPy and SciPy that just integrate with computer vision and machine learning.
00:05:15.660 --> 00:05:17.480
And all other types of libraries.
00:05:17.480 --> 00:05:25.060
And more and more people were transitioning over from languages like MATLAB to languages like Python.
00:05:25.060 --> 00:05:26.440
And that's so cool.
00:05:26.440 --> 00:05:30.580
And it really wasn't until college that I got into Python.
00:05:30.580 --> 00:05:32.740
And I remember this one girl.
00:05:32.740 --> 00:05:34.260
She was in my machine learning class.
00:05:34.260 --> 00:05:38.740
And she had a sticker on the back of her laptop that said, Python will save the world.
00:05:38.900 --> 00:05:40.780
I don't know how, but it will.
00:05:40.780 --> 00:05:42.460
And that resonated with me.
00:05:42.460 --> 00:05:44.600
I'm like, that sticker's true.
00:05:44.600 --> 00:05:46.540
That is absolutely true.
00:05:46.540 --> 00:05:48.520
It's such a great language.
00:05:48.520 --> 00:05:52.060
So unfortunately, I did not have the best first experience with Python.
00:05:52.060 --> 00:05:55.900
It took me four or five years later to actually come around.
00:05:56.120 --> 00:05:58.560
But now that I'm here, I love it.
00:05:58.560 --> 00:06:01.200
And I can't imagine programming in any other language.
00:06:01.200 --> 00:06:07.320
It's almost a freeing feeling, a relaxing zen when you're coding in Python.
00:06:07.320 --> 00:06:09.560
Yeah, that's a funny story.
00:06:09.560 --> 00:06:11.360
It really is a wonderful language.
00:06:11.940 --> 00:06:13.840
I also took a while to get there.
00:06:13.840 --> 00:06:16.960
But looking back, I would have enjoyed being there sooner.
00:06:16.960 --> 00:06:21.020
I went from MATLAB to C++ on Silicon Graphics machines.
00:06:21.020 --> 00:06:23.960
So I had a bit of a torturous introduction.
00:06:23.960 --> 00:06:24.760
But it was all good.
00:06:24.760 --> 00:06:41.120
CodeShip is a hosted, continuous delivery service focused on speed, security, and customizability.
00:06:41.260 --> 00:06:46.920
You can set up continuous integration in a matter of seconds and automatically deploy when your tests have passed.
00:06:46.920 --> 00:06:50.160
CodeShip supports your GitHub and BitBucket projects.
00:06:50.160 --> 00:06:52.940
You can get started with CodeShip's free plan today.
00:06:52.940 --> 00:06:55.080
Should you decide to go with a premium plan,
00:06:55.080 --> 00:07:01.460
Talk Python listeners can save 20% off any plan for the next three months by using the code TALKPYTHON.
00:07:01.460 --> 00:07:03.160
All caps, no spaces.
00:07:03.160 --> 00:07:05.800
Check them out at CodeShip.com.
00:07:05.800 --> 00:07:10.500
And tell them thanks for sponsoring the show on Twitter where they're at CodeShip.
00:07:10.580 --> 00:07:24.200
So you're focused on computer vision and image processing.
00:07:24.200 --> 00:07:25.900
Where did that story begin?
00:07:25.900 --> 00:07:29.120
That story also started in high school.
00:07:29.360 --> 00:07:33.680
Originally, I had this idea that I wanted to go work for Adobe.
00:07:33.680 --> 00:07:37.740
And I wanted to work on developing Photoshop and Illustrator.
00:07:37.740 --> 00:07:42.660
I love the idea of being able to write code that could analyze an image.
00:07:42.660 --> 00:07:46.820
And for whatever reason, that just like really captured my imagination.
00:07:47.240 --> 00:07:49.920
I could see these algorithms running in Photoshop.
00:07:49.920 --> 00:07:52.860
And I was like, you know, what's really going on behind the scenes?
00:07:52.860 --> 00:07:54.520
Like, how are they manipulating these images?
00:07:54.520 --> 00:07:56.020
What does this code look like?
00:07:56.020 --> 00:08:01.880
So for the longest time, I really wanted to develop these graphic editing applications.
00:08:02.280 --> 00:08:07.080
But I didn't have the math experience.
00:08:07.080 --> 00:08:11.600
This may surprise some people, given that I have a PhD in computer science.
00:08:11.600 --> 00:08:16.760
But up until late high school, I did not do well in mathematics courses.
00:08:17.320 --> 00:08:22.400
I got C's in algebra and geometry.
00:08:22.400 --> 00:08:27.180
And it really wasn't until I kind of really put my back against the wall.
00:08:27.180 --> 00:08:28.480
And I said, you know what?
00:08:28.480 --> 00:08:30.780
I got to learn calculus and statistics.
00:08:30.780 --> 00:08:33.420
So I did a self-study in AP Calc.
00:08:33.420 --> 00:08:34.600
And I took AP statistics.
00:08:34.600 --> 00:08:36.280
And I did well with those.
00:08:36.360 --> 00:08:38.080
I'm like, man, math is fun now.
00:08:38.080 --> 00:08:40.040
Like, I understand this.
00:08:40.040 --> 00:08:41.980
So I got to college.
00:08:41.980 --> 00:08:47.920
And I only took one computer vision course at the, because the school I went to didn't really
00:08:47.920 --> 00:08:49.380
have a computer vision focus.
00:08:49.380 --> 00:08:53.220
They had a wonderful machine learning focus, but not really a computer vision focus.
00:08:53.220 --> 00:09:00.200
And what I found out was that, you know, you don't need a mathematical background to get
00:09:00.200 --> 00:09:01.280
started in computer vision.
00:09:01.280 --> 00:09:05.480
And I think this is true in a lot of areas of computer science, whether or not people want
00:09:05.480 --> 00:09:06.140
to admit it.
00:09:06.140 --> 00:09:11.260
A lot of people talk themselves out of getting started and stuff, especially challenging things,
00:09:11.260 --> 00:09:13.320
because they're just scared of it.
00:09:13.320 --> 00:09:14.180
They don't want to fail.
00:09:14.180 --> 00:09:17.700
And that's the cool thing about Python.
00:09:17.700 --> 00:09:20.140
Like, you almost don't have to worry about the code.
00:09:20.140 --> 00:09:23.260
You get to focus on learning a new skill.
00:09:23.260 --> 00:09:25.300
And for me, that was computer vision.
00:09:25.300 --> 00:09:30.680
And that was the OpenCV library, an open source library that makes working with computer vision
00:09:30.680 --> 00:09:31.520
a lot easier.
00:09:31.520 --> 00:09:36.120
So again, it really wasn't until college that I really started to get into it.
00:09:36.120 --> 00:09:37.020
getting interested.
00:09:37.020 --> 00:09:38.680
Or not necessarily getting interested.
00:09:38.680 --> 00:09:42.320
More so being able to take action on what I wanted to do.
00:09:42.320 --> 00:09:43.060
Right.
00:09:43.060 --> 00:09:45.660
Maybe, you know, it felt a little unattainable.
00:09:45.660 --> 00:09:48.480
Like, I'm going to go be an engineer, but I don't know math.
00:09:48.480 --> 00:09:49.860
And so there's no way I can do this.
00:09:49.860 --> 00:09:53.120
But once you kind of got over that hump, then it was no big deal, right?
00:09:53.120 --> 00:09:53.820
Right.
00:09:53.820 --> 00:09:54.720
Yeah.
00:09:54.720 --> 00:09:55.760
That's very freeing.
00:09:55.860 --> 00:10:00.000
So you mentioned OpenCV and your project is PyImageSearch.
00:10:00.000 --> 00:10:01.260
What's the relationship there?
00:10:01.260 --> 00:10:08.640
So OpenCV, again, it's a computer vision library that makes working with images a lot easier.
00:10:08.640 --> 00:10:14.920
You know, it abstracts the code that loads an image off of disk or does edge detection or
00:10:14.920 --> 00:10:19.720
thresholding or any other simple image processing function like that.
00:10:19.780 --> 00:10:23.580
allows you to actually build complicated computer vision programs.
00:10:23.580 --> 00:10:28.580
You can do things like tracking objects and images or video streams, for example.
00:10:28.580 --> 00:10:29.460
Detecting faces.
00:10:29.460 --> 00:10:31.480
Recognizing whose face it is.
00:10:31.480 --> 00:10:34.960
And OpenCV really facilitates this process.
00:10:35.940 --> 00:10:41.900
And OpenCV really is like the de facto library for computer vision and image processing.
00:10:41.900 --> 00:10:44.820
And you have bindings for it in countless languages.
00:10:44.820 --> 00:10:52.480
The library itself is written in C and C++, but you can get bindings and access it in Java
00:10:52.480 --> 00:10:55.620
and any of the .NET frameworks in Python.
00:10:57.240 --> 00:11:03.820
So again, while you can access it in a programming language, I have this love for Python now.
00:11:03.820 --> 00:11:10.000
And when I took the course, the computer vision course in college, I realized, man, like, people
00:11:10.000 --> 00:11:14.180
are spending a lot of time writing their class projects in C and C++.
00:11:14.180 --> 00:11:15.320
Why are they doing that?
00:11:15.320 --> 00:11:18.980
Like, you're fighting over these weird compile time errors.
00:11:18.980 --> 00:11:21.180
And, you know, you're not really learning anything.
00:11:21.680 --> 00:11:24.680
And that's kind of the tenet behind PyImageSearch.
00:11:24.680 --> 00:11:30.220
It's a blog that I run dedicated to teaching computer vision, image processing, and OpenCV using
00:11:30.220 --> 00:11:31.600
the Python programming language.
00:11:31.600 --> 00:11:32.140
That's great.
00:11:32.140 --> 00:11:36.040
And I think that, you know, using Python seems like the perfect choice.
00:11:36.040 --> 00:11:41.920
You're sort of orchestrating these high-level functions that are calling down into C++, doing
00:11:41.920 --> 00:11:43.740
high-performance stuff, and then giving you the answer.
00:11:43.740 --> 00:11:46.740
And that seems like the right way to be using Python.
00:11:46.740 --> 00:11:48.820
So what's the actual package I use?
00:11:48.860 --> 00:11:51.920
If I were to say pip install something, what do I type to get started?
00:11:51.920 --> 00:11:56.480
So unfortunately, OpenCV is not pip installable.
00:11:56.480 --> 00:11:58.980
I wish it was, but it is not.
00:11:58.980 --> 00:12:04.480
And it is not the easiest package to get installed on your system.
00:12:04.480 --> 00:12:14.280
If you're using Ubuntu or any Debian-based operating system, you technically can do an app git install.
00:12:14.280 --> 00:12:17.680
But that's going to pull down a previous version of OpenCV.
00:12:18.100 --> 00:12:22.180
You're going to run into a lot of problems with the Python bindings, and it's not a very
00:12:22.180 --> 00:12:22.720
good experience.
00:12:22.720 --> 00:12:28.220
So what you actually have to do is compile it from source, download the code from their
00:12:28.220 --> 00:12:32.720
GitHub or the SourceForge account, and manually compile it and install it.
00:12:32.720 --> 00:12:37.980
And in fact, that's really the only way to do it if you're interested in using virtual environments,
00:12:37.980 --> 00:12:44.720
which, as most Python developers are interested in, sequestering their packages.
00:12:45.400 --> 00:12:45.840
Yeah, absolutely.
00:12:45.840 --> 00:12:46.300
Okay.
00:12:46.300 --> 00:12:47.940
So I go and I download that.
00:12:47.940 --> 00:12:51.800
And then what packages are in there that I would work with?
00:12:51.800 --> 00:12:53.700
Is that CV2?
00:12:53.700 --> 00:12:55.080
Is that the one I would import?
00:12:55.080 --> 00:12:55.720
Yep.
00:12:55.780 --> 00:13:01.440
So if you were to open up your favorite editor, you would just type in import CV2, and I'll
00:13:01.440 --> 00:13:04.100
give you access to all of your OpenCV bindings.
00:13:04.100 --> 00:13:04.900
Okay, great.
00:13:04.900 --> 00:13:11.440
And now I looked at some samples on your blog about how I might go and grab like an image
00:13:11.440 --> 00:13:13.780
from a camera hooked to an Adreno.
00:13:14.640 --> 00:13:20.220
Maybe we could talk a little bit about the type of hardware that you need and the spectrum
00:13:20.220 --> 00:13:24.500
of devices you can interact with and that kind of stuff before we get into the more theoretical
00:13:24.500 --> 00:13:24.880
bits.
00:13:24.880 --> 00:13:25.700
Sure.
00:13:25.700 --> 00:13:31.760
So that's kind of the cool thing about OpenCV is that it's meant to be run in real time.
00:13:31.760 --> 00:13:38.800
So you can easily process video files, raw video streams without too much of a problem,
00:13:38.900 --> 00:13:41.780
again, depending on the complexity of your algorithm.
00:13:41.780 --> 00:13:46.800
And OpenCV is meant to run on a variety of different devices.
00:13:46.800 --> 00:13:54.660
I personally develop applications on my MacBook, but I also own a Raspberry Pi and a camera module
00:13:54.660 --> 00:13:55.760
for the Raspberry Pi.
00:13:55.760 --> 00:14:02.960
And using OpenCV, I can access the Raspberry Pi video stream and then actually build like
00:14:02.960 --> 00:14:08.000
a home surveillance system using nothing but OpenCV and a Raspberry Pi.
00:14:08.480 --> 00:14:14.900
I built this one project where I had a Raspberry Pi camera mounted on my kitchen cabinets looking
00:14:14.900 --> 00:14:17.000
over the front door of my apartment.
00:14:17.000 --> 00:14:22.280
And it would detect motion, such as when you're opening the door and somebody's walking inside.
00:14:22.280 --> 00:14:27.980
So once it detected motion, it would snap a photo of whoever was walking inside, try and identify
00:14:27.980 --> 00:14:33.320
their face, and then it would take that screenshot or the screen capture and then upload it to my
00:14:33.320 --> 00:14:34.260
personal Dropbox.
00:14:34.260 --> 00:14:37.340
So I had like this real-time home surveillance system.
00:14:37.940 --> 00:14:39.940
That was really, really cool to develop.
00:14:39.940 --> 00:14:43.140
And again, like this is using simple hardware.
00:14:43.140 --> 00:14:48.480
The Raspberry Pi is not a powerful machine, but you could still build some really cool computer
00:14:48.480 --> 00:14:49.760
vision applications with it.
00:14:49.760 --> 00:14:50.420
Yeah.
00:14:50.420 --> 00:14:51.680
And it's cheap too, right?
00:14:51.680 --> 00:14:52.700
Yeah.
00:14:52.700 --> 00:14:58.460
The Pi itself is, I think, $35 and probably another $20 for the camera module.
00:14:58.460 --> 00:14:59.460
Yeah.
00:14:59.460 --> 00:15:01.240
That's really easy to get started.
00:15:01.240 --> 00:15:02.920
So very cool.
00:15:02.920 --> 00:15:03.360
Very cool.
00:15:03.360 --> 00:15:05.620
How does computer vision work?
00:15:05.620 --> 00:15:10.600
I mean, I have a little bit of a background in trying to identify things and images.
00:15:11.280 --> 00:15:18.240
I worked at this place called eye tracking, E-Y-E, tracking, not I, the letter I, tracking.
00:15:18.240 --> 00:15:22.380
And we did a lot of stuff with image recognition and detecting eyes.
00:15:22.380 --> 00:15:26.560
And I know enough to know that it seems really hard, but how does it work?
00:15:27.600 --> 00:15:34.500
So computer vision as a field is really just encompassing methods on acquiring, processing,
00:15:34.500 --> 00:15:38.860
analyzing, and just understanding and interpreting the contents of an image.
00:15:38.860 --> 00:15:41.080
For humans, this is really, really easy.
00:15:41.440 --> 00:15:43.860
We see a picture of a cat, and we know, like, oh, that's a cat.
00:15:43.860 --> 00:15:46.660
And we see a picture of a dog, and we obviously know that's a dog.
00:15:46.660 --> 00:15:48.820
But a computer, it doesn't have a clue.
00:15:48.820 --> 00:15:53.260
It just sees a bunch of pixels, just a big matrix of pixels.
00:15:53.260 --> 00:15:58.080
And the challenging part, as you suggested, is writing code and creating these algorithms
00:15:58.080 --> 00:16:00.660
that can understand the contents of an image.
00:16:00.660 --> 00:16:06.520
You can't open up your Python source file and then write if statements that say,
00:16:06.740 --> 00:16:12.620
if this pixel equals, you know, whatever RGB code, you know, then this is a cat, right?
00:16:12.620 --> 00:16:15.040
If it equals this pixel value, then it's a dog.
00:16:15.040 --> 00:16:16.080
Like, you can't do that.
00:16:16.080 --> 00:16:21.700
So what happens is computer vision really leverages machine learning as well.
00:16:21.700 --> 00:16:26.300
So we can take this data-driven approach and say, here's a ton of examples of a cat,
00:16:26.300 --> 00:16:28.660
and here's a ton of examples of a dog.
00:16:28.660 --> 00:16:35.100
Let's see how we can abstractly quantify and represent this huge image.
00:16:35.640 --> 00:16:37.780
And just like a small, what they call feature vector.
00:16:37.780 --> 00:16:40.860
It's a fancy academic way of saying a list of numbers.
00:16:40.860 --> 00:16:49.100
I'm going to quantify this big 3,000 by 3,000 pixel image into a feature vector that's 128 numbers long.
00:16:49.100 --> 00:16:50.860
And then I can compare them to each other.
00:16:50.860 --> 00:16:52.160
I can rank them for similarity.
00:16:52.160 --> 00:16:56.020
I can pass them to machine learning algorithms to actually classify them.
00:16:57.020 --> 00:17:00.420
So the field of computer vision is very large.
00:17:00.420 --> 00:17:06.020
And again, it spans so many different areas of processing and analyzing images.
00:17:06.020 --> 00:17:10.980
But if we're talking strictly about classifying an image and detecting objects in an image,
00:17:10.980 --> 00:17:14.900
then we're most likely leveraging some machine learning at some point.
00:17:14.900 --> 00:17:15.800
Okay, and cool.
00:17:15.800 --> 00:17:21.900
And when you say machine learning, is that like neural networks or what's going on back there?
00:17:21.900 --> 00:17:25.560
The machine learning algorithm you would use really depends on your application.
00:17:25.560 --> 00:17:31.180
Deep learning has gotten so much attention over the past few years.
00:17:31.180 --> 00:17:34.260
And deep learning has its roots in neural networks.
00:17:34.260 --> 00:17:36.340
So we see a lot of that.
00:17:36.340 --> 00:17:44.000
You also see very simple machine learning methods like support vector machines, logistic aggression.
00:17:44.000 --> 00:17:46.220
You see that a lot as well.
00:17:46.220 --> 00:17:57.440
And these methods, while simple, they're actually – the bulk of the work is actually happening on describing the image itself, you know, quantifying it.
00:17:57.440 --> 00:18:06.220
So if you have a really good quantification of an image, it's a lot easier for the machine learning algorithm to take that and perform the classification.
00:18:06.880 --> 00:18:07.520
Right, sure.
00:18:07.520 --> 00:18:16.340
And so how much of this exists in external libraries like scikit-learn or OpenCV or something like this?
00:18:16.340 --> 00:18:23.700
And how much of that is like I've got to create that system for myself when I'm getting started based on my application?
00:18:24.580 --> 00:18:35.580
So OpenCV does include some machine learning components, but I really don't recommend that people use them just because they're a little finicky and they're not that fun to use.
00:18:35.580 --> 00:18:38.820
And especially in the Python ecosystem, you have scikit-learn.
00:18:38.820 --> 00:18:41.920
So you should be defaulting to that.
00:18:42.460 --> 00:18:52.240
And to give an example, I wrote my entire dissertation, gathered all the examples using OpenCV and scikit-learn.
00:18:52.240 --> 00:18:59.140
I took the results that OpenCV was giving me and I passed them on to the machine learning methods and scikit-learn.
00:18:59.140 --> 00:18:59.760
Right.
00:18:59.760 --> 00:19:01.620
Oh, that sounds very useful.
00:19:01.620 --> 00:19:12.420
I think a lot of the challenging aspects of getting started in something new like this, if you're not already involved in it, is just knowing what exists, what you can reuse, and what you have to write yourself.
00:19:12.420 --> 00:19:14.520
So knowing that that's out there is really nice.
00:19:14.520 --> 00:19:15.720
Yeah, for sure.
00:19:15.720 --> 00:19:20.560
And some of these algorithms you definitely don't want to be implementing yourself.
00:19:20.560 --> 00:19:22.180
No, I'm sure you don't.
00:19:22.180 --> 00:19:29.820
Unless you're really, really into high-performance matrix multiplication and other types of processing that make your day, right?
00:19:29.820 --> 00:19:30.680
Exactly.
00:19:31.000 --> 00:19:34.520
I have some sort of mental models of how I might use computer vision.
00:19:34.520 --> 00:19:37.180
And then you have the Hollywood models, right?
00:19:37.180 --> 00:19:39.140
Like Minority Report and so on.
00:19:39.140 --> 00:19:41.420
But what's the current state of the art?
00:19:41.420 --> 00:19:44.720
Like where do you see computer vision really prominently being used in the world?
00:19:44.720 --> 00:19:51.500
So computer vision is used in your everyday life, whether you realize it or not.
00:19:51.500 --> 00:19:55.140
And it's kind of scary, but it's also kind of cool.
00:19:56.840 --> 00:20:07.980
Back about a year ago, I was traveling back and forth between Maryland and Connecticut on the East Coast of the United States constantly for work-related activities.
00:20:07.980 --> 00:20:10.820
And one day I was exhausted.