WEBVTT

00:00.510 --> 00:00.780
No.

00:00.810 --> 00:04.680
We are sure that the camera is correctly enabled and that we can use it.

00:04.890 --> 00:10.980
So let's open funny by an E so we can write some python code.

00:11.370 --> 00:14.490
And let's start with this line.

00:19.220 --> 00:25.310
So we give the interpreter spike in three and then, well, there is a module, there is a Python module

00:25.310 --> 00:27.740
that is already installed on a Raspberry Pi voice.

00:28.190 --> 00:31.850
Then you're going to do from by camera.

00:32.000 --> 00:37.760
So this is the bite camera module and you're going to do so from by camera.

00:37.760 --> 00:45.440
All lowercase input by camera like this will be uppercase C uppercase.

00:45.830 --> 00:54.650
And then what we are going to do is we are going to create a camera from right camera like this with

00:54.650 --> 00:55.400
parentheses.

00:55.970 --> 01:02.900
And from that camera object here we will be able to take some photos and we can add some settings.

01:02.900 --> 01:10.880
For example, camera dot resolutions and it is a great input on setting and let's give, for example,

01:11.630 --> 01:17.360
1008 by 720.

01:17.900 --> 01:18.080
Okay.

01:18.080 --> 01:21.200
So this is an HD photo for the resolution.

01:21.200 --> 01:22.910
Make sure you give a tuple like this.

01:22.960 --> 01:24.140
Okay, parentheses.

01:24.560 --> 01:28.370
And then we need to choose where we want to save the photos actually.

01:28.700 --> 01:33.050
So in let's open phi manager here then.

01:33.050 --> 01:38.270
When we are in our own directory here, maybe we could create a camera folder.

01:38.600 --> 01:43.540
So instead of just creating the camera folder here, it's from the python call.

01:43.880 --> 01:56.450
So we are going to do import OS and then let's provide image folder name is equal to slash home slash

01:56.720 --> 01:57.170
by.

01:57.200 --> 02:01.100
Okay, this is where we are here and then slash camera.

02:02.210 --> 02:07.310
Then we're going to check if this folder doesn't exist, then we are going to create it.

02:07.310 --> 02:09.320
So if not voice.

02:10.740 --> 02:14.460
But baths don't exist.

02:15.000 --> 02:18.450
This is how to check that something exists.

02:19.570 --> 02:20.950
If it doesn't exist.

02:20.950 --> 02:30.500
We do voice notes and keep the I like in the terminal with the image folder.

02:31.990 --> 02:37.690
So if we run that, this is going to create a camera folder here the first time and then the second

02:37.690 --> 02:47.710
time is going to skip it because it already exists and then let's do it time that slick too.

02:48.190 --> 02:48.550
Okay.

02:48.700 --> 02:49.930
So why is that?

02:50.260 --> 02:53.260
Let's do first import time because we use time here.

02:53.890 --> 02:54.600
So why is that?

02:54.700 --> 02:59.870
Simply because the camera needs a bit of time to adjust to the luminosity.

02:59.890 --> 03:00.190
Okay.

03:00.430 --> 03:06.760
So if you want to have a correct picture, when you take a picture, make sure you wait at least, let's

03:06.760 --> 03:07.650
say two segments.

03:07.660 --> 03:07.960
Okay?

03:08.260 --> 03:14.170
So you create the camera, you set the settings, you create a folder, and you wait for 2 seconds and

03:14.170 --> 03:16.330
then you can take a photo.

03:16.690 --> 03:21.250
So in order to take your photo, we need to provide a file name.

03:21.280 --> 03:21.610
Okay.

03:21.940 --> 03:26.110
So let's do image file name is equal to.

03:26.290 --> 03:30.450
So let's use the image folder name and let's arg.

03:31.250 --> 03:35.200
So let's name each new image.

03:36.800 --> 03:37.120
Okay.

03:37.390 --> 03:42.990
We are going to use this extension and then you can do camera.

03:43.030 --> 03:50.200
So the camera we have created here, that capture image file name.

03:50.830 --> 03:53.410
Let's now run that code.

03:54.770 --> 03:58.520
So we see it as it's a test.

03:59.250 --> 04:06.230
Cameron Presenter And you can see now the program has grown.

04:06.650 --> 04:08.270
We have not printed anything.

04:09.200 --> 04:14.570
We could have printed some load here to say that we have actually taken a photo.

04:15.140 --> 04:19.460
And you can see here on this monument, we have a new fold of camera.

04:20.110 --> 04:26.090
I go on the camera folder and we have a new image and well, that's the current image.

04:26.090 --> 04:26.480
Not actually.

04:26.480 --> 04:27.550
It's quite dark in here.

04:27.560 --> 04:32.450
I'm going to turn on the light and let's take the photo again.

04:33.970 --> 04:34.330
Okay.

04:35.020 --> 04:36.670
So let's wait just 2 seconds.

04:36.670 --> 04:38.050
Maybe we can out of print here.

04:38.320 --> 04:38.770
Print.

04:40.000 --> 04:41.480
Take photo.

04:43.510 --> 04:43.960
Okay.

04:44.560 --> 04:45.550
So we can see.

04:47.660 --> 04:47.950
Okay.

04:48.140 --> 04:52.910
But take four so we know when we have the photo, let's just check the photo again.

04:52.910 --> 04:59.570
So you can see that's actually when you take a photo with the finding it's going to replace any other

04:59.570 --> 05:02.240
photo was taken before we the same thing here okay.

05:03.050 --> 05:05.330
And you can see whether that's a photo.

05:05.360 --> 05:10.400
And we have one problem here is that the photo is upside down.

05:10.910 --> 05:19.460
So what I'm going to do is I'm going to add a new sitting here, which is camera.

05:19.490 --> 05:24.410
That rotation is equal to 180 degrees.

05:24.650 --> 05:27.020
So this depends actually on the photo.

05:27.020 --> 05:31.940
You see that if you see the photo is upside down, then you can use this setting.

05:32.120 --> 05:36.980
And then if you change the position of the camera, you can just adjust this to make sure that you have

05:36.980 --> 05:37.890
a correct image.

05:37.910 --> 05:39.860
So let's do photo again.

05:42.230 --> 05:45.410
Take photo, and now the photo is correctly.

05:46.670 --> 05:47.390
Orientated.

05:48.260 --> 05:54.350
One thing I'm going to do also now is to test a difference of resolution because, well, when you take

05:54.350 --> 05:59.060
a photo with a big resolution like this, so this is not the biggest, but it's quite big.

05:59.450 --> 06:04.550
Then let's say here you see the file is 562 kilobytes.

06:04.790 --> 06:07.430
Okay, so 500 kilobytes.

06:07.940 --> 06:15.410
Now, let's take a photo with 640 and 480.

06:15.410 --> 06:17.030
So this is a lower resolution.

06:17.360 --> 06:19.610
Let's name it a new image, too.

06:19.910 --> 06:20.080
Okay.

06:20.090 --> 06:24.320
So we're going to have the image on the side and it's run again, the same photo.

06:26.320 --> 06:26.610
Okay.

06:26.620 --> 06:28.330
And let's check this image.

06:29.320 --> 06:29.620
Okay.

06:29.980 --> 06:33.220
The resolution is smaller, as you can see, but we still see clearing.

06:33.670 --> 06:36.130
And now the photo is just 200 kilobytes.

06:36.220 --> 06:38.050
So we have 500.

06:38.380 --> 06:41.140
And we went from 500 to 200 kilometres.

06:41.410 --> 06:48.850
And it is quite important because then when we take photo and we send photos to the Internet, it's

06:48.850 --> 06:55.060
better actually to try to have a size that is quite small so it goes faster and it doesn't take too

06:55.060 --> 06:55.780
much space.

06:56.140 --> 06:56.500
All right.

06:56.500 --> 06:59.290
And that's pretty much it from now for the camera.

06:59.590 --> 07:05.200
We are going to come back to it in the following practice activities and not so in the final project

07:05.200 --> 07:05.890
of the course.
