0:00 this is Dr sadik and today we are
0:02 discussing how to collect imagery data
0:04 using Python opencv and your webcam as a
0:09 data scientist you need to have a very
0:12 huge amount of data for object detection
0:15 and pubg detection model implementation
0:17 in a specific application areas such as
0:20 driverless car emotion detection sign
0:23 language implementation and
0:25 optimizations if you are a deep learning
0:27 researcher and you are a data scientist
0:29 then today's topic is very important for
0:31 you you can easily collect imagery data
0:34 about different subjects in about
0:35 different classes like if you want to
0:38 work in emotions so you can collect data
0:40 about different emotions if you are
0:42 working in object detection in action
0:44 recognitions then you can easily collect
0:47 data at your home at your office in
0:49 through from your students and they can
0:52 give you different poses different
0:54 gestures different actions and they can
0:58 they can pretend to have different
1:00 emotion as well so it's very easy to
1:03 collect data about different emotions
1:05 and about different actions uh using
1:08 python code you can collect enough
1:10 amount of data for your model and you
1:12 can initiate object detection model at
1:14 your home so I will directly jump to the
1:17 to the coding because we already know
1:20 how to install tensorflow and how to
1:22 install different dependencies of
1:23 pythons and object detection
1:26 so if you are new here and you don't
1:28 know how to install tensorflow in other
1:31 dependencies then you can find my
1:34 lectures how to install tensorflow and
1:36 how to install Cuda in other
1:38 dependencies link is in the description
1:40 below so in this lecture we will cover
1:42 three types of actions one is like this
1:46 one like for example this is for like
1:48 this is for dislike and this is for no
1:53 this is for no so we will cover these
1:55 three types of actions in this lecture
1:58 so let's have a look
2:01 so let's start
2:02 create a folder with imagery data new
2:05 folder imagery data
2:08 so now go to the Anaconda prompt and I
2:11 will activate uh OTF obj
2:15 I have already created this environment
2:17 and installed the dependencies of FG
2:20 detection like Cuda Cubana and
2:23 tensorflow object detection so if you
2:26 want to learn about that I have already
2:28 provided the links in the description so
2:30 you can follow all these lectures
2:33 so I will directly go I will activate
2:35 this TF obj
2:38 so go to the D
2:40 and in the D you will have to open the
2:43 jupyter notebook
2:46 Jupiter notebook
2:49 so now go to the imagery data and in the
2:53 imagery data create a python like an
2:56 interpreter file
2:58 new python file
3:02 so now we are in the D and in the D we
3:04 are we we are in the folder images data
3:07 we have created a jupyter notebook file
3:09 and now import dependencies import
3:15 CV2
3:16 import
3:18 OS import
3:23 time import
3:26 uuid
3:29 so this is actually opencv
3:32 OS is for the file path
3:35 and the time we use this dependency for
3:39 to give some bread between the different
3:41 classes like for example if we have
3:43 three classes one is like dislike and no
3:45 so if if the system collected images for
3:50 like so time break a time is also for
3:53 time taken is also for the the time
3:56 between the two two images and lastly we
3:58 will use uuid to name our image file so
4:01 let's run this code
4:02 okay it's successfully implemented let's
4:06 move to the next step so next we will we
4:09 will have we will give a path to the to
4:10 that particular folder and in that
4:12 folder imagery imagery data we will
4:15 create another folder which uh name is
4:17 image folder okay so here you can see
4:20 this is the imagery data and in that
4:22 image data we don't have any folder here
4:24 you can see uh imagery data
4:28 and in the imagery data we will create
4:30 another folder and its name should be
4:32 image folder okay
4:34 so let's run this code
4:36 and now let's move to the next step and
4:40 in the next step we will provide labels
4:42 like we have three labels like this like
4:44 No And we want 10 picture for every
4:46 level like we are giving this this
4:48 command that collect 10 picture for
4:50 every every levels so let's run this
4:53 code and move to the next step so now we
4:55 have three labels like dislike and no
4:57 and we need 10 uh 10 images per level
5:01 and here in the next segment we are
5:04 giving birth and we are we are trying to
5:06 create a directory and next this one
5:10 will access your webcam and my webcam
5:15 device name is it's zero it's
5:17 independent your system then what what
5:19 what is your your it can be one two or
5:22 something like that so here this code
5:23 will will access our webcam and it will
5:25 initiate our webcam for my device it's
5:27 zero and it depends on your system
5:29 Network number uh should fit in your
5:32 device so here in the next step it will
5:36 print that we are collecting images for
5:39 a specific level it depends that what
5:42 label is like for every level it will
5:44 give you a message a print it will give
5:47 you a print message so next is time that
5:50 slip so it will give you five seconds to
5:52 to have another pose
5:54 so this is important because you can
5:57 give different poses of a different
6:00 action like if you are collecting images
6:02 for emotions so you can give different
6:04 poses different gestures about different
6:07 emotions and if you are giving some
6:09 different action like if you are working
6:10 for sign language then you can give
6:12 different actions as well so next we are
6:14 going to collect images and this code
6:16 will will give us the particular uh
6:21 objective we can we can achieve the
6:23 particular objective from this
6:24 particular code and here you can see the
6:27 total number of images and the total
6:30 number of images is 10 so we want 10
6:32 images per label this particular command
6:35 will give us a capture and we are most
6:37 interested in in the frame the next this
6:39 this is the entire path here we will
6:42 join the path here you can see image
6:45 image folder here we will give the this
6:48 particular path and it will create
6:51 and also label for because we want to we
6:55 want different folder for each label
6:57 because it will create different level
6:58 for like three it will create three
7:00 labels lying dislike and no and in each
7:02 level it will uh it will save the
7:05 particular actions like if we are giving
7:07 action for the uh for the like so it
7:10 will save it in the uh in in that in the
7:13 like folder and if we give a dislike so
7:16 it will save it in the dislike folder
7:17 and same is the No it will uh definitely
7:19 save it in the jpga format and it will
7:21 pass it through specific string which is
7:24 which means that it should be unique
7:25 here the CV2 will write that particular
7:27 image uh to that particular folder and
7:31 lastly it will show us on the screen as
7:34 well and lastly we will go to the uh it
7:38 will be the ability to second time for
7:40 sleep like between the two images and
7:42 lastly if there is any error so it will
7:44 go directly to break that particular uh
7:48 to stop that particular uh compilation
7:50 so let's run the code and see what is
7:54 going to happen
8:00 so there is an error so now let's run it
8:03 again uh I think it was uh because I
8:06 haven't initiated again because the uh
8:09 because the Canada was dead so whenever
8:12 your Canal is dead and you uh you
8:14 initiate it uh Jupiter notebooks so you
8:17 must
8:18 initiate the the all this code like
8:20 python image image path labels and next
8:24 then you can jump to this this
8:25 particular segments so let's start from
8:27 this run
8:29 okay next
8:31 next
8:32 and
8:34 finally
8:35 so let's wait for it it will take a few
8:37 few seconds
8:41 yeah it's collecting here you can see
8:43 collecting images for like so let's see
8:46 let's give pause for like
8:50 okay this is for like
8:53 here you can see
9:02 it will collect 10 images actually
9:05 so let's see
9:07 I'm giving different poses
9:11 now it will collect for dislike so I'm
9:14 giving D for uh
9:17 action for dislike so let's see
9:29 and the third folder will be no
9:40 okay now it's time to no collecting
9:42 images for no okay
10:05 so you can give different poses like we
10:09 we have done this for three
10:11 three classes and you can give so it's
10:14 all done so let's let's check and have a
10:16 look at
10:17 in the folder so it's already created
10:20 here you can see imagery
10:22 you can see imagery and in the imagery
10:24 we can have it's created we have created
10:27 for the image and in the image is
10:29 created image folder okay just like this
10:32 you can see here
10:34 here you can see it's created the image
10:36 folder like imagery and in the image we
10:39 have images and in the image folder uh
10:41 it created image folder here you can see
10:43 so we are in the image folder so for
10:46 each of the class it created different
10:48 folder like for the dislike it's
10:50 collected different images here you can
10:51 see it's
10:52 collected for dislike and
10:56 here is collected for like you can see
10:58 it's collected for likes and it's
11:02 collected for no actually we demanded 10
11:04 pictures per label so that's why it's
11:07 collected only 10 picture per label if
11:09 you want hundreds of thousands of
11:10 pictures so you can you you can you can
11:13 have very long experiment for that so
11:15 this is all about how to how to collect
11:17 image data using Python opencv and your
11:21 webcam so in the next slide we will
11:24 label the particular actions and in the
11:26 next lecture you will learn how to label
11:29 that particular images using python
11:32 coding and how to detect that that
11:35 action in real time thank you so much