File tree Expand file tree Collapse file tree 9 files changed +49
-21
lines changed Expand file tree Collapse file tree 9 files changed +49
-21
lines changed Original file line number Diff line number Diff line change 1
1
__pycache__
2
+ /venv
Original file line number Diff line number Diff line change
1
+ re-scale :
2
+ python3 src/re_scale.py
3
+
4
+ read-image :
5
+ python3 src/read_image.py
6
+
7
+
8
+ read-video :
9
+ python3 src/read_video.py
Original file line number Diff line number Diff line change 1
1
## Description
2
- > A computer program that will allow you to read and resize images and videos.
3
2
4
- <br />
5
-
6
- ## Technology Stack
7
- > [ Python3] ( https://docs.python.org/3.10/ ) • [ OpenCV Contrib Python] ( https://pypi.org/project/opencv-contrib-python/ )
3
+ > A sample Python program that read and resize an image and video.
8
4
5
+ <br />
9
6
<br />
10
7
11
8
## Setup
9
+
10
+ > - Setup a virtual environment.
11
+
12
+ ``` sh
13
+ python3 -m venv venv
14
+ ```
15
+
16
+ > - Activate the virtual environment.
17
+
18
+ ``` sh
19
+ source venv/bin/activate
20
+ ```
21
+
12
22
> Install the packages.
23
+
13
24
``` bash
14
- pip install opencv-contrib-python
25
+ pip3 install -r requirements.txt
15
26
```
16
27
> Run the programs.
28
+
17
29
``` bash
18
- python3 readImage.py
19
- python3 readVideo.py
20
- ```
30
+ # Run the re_scale.py program.
31
+ make re-scale
21
32
22
- <br />
33
+ # Run the read_image.py program.
34
+ make read-image
23
35
24
- ## Recording
25
- [ image-video-reader.webm] ( https://user-images.githubusercontent.com/69438999/202873086-4b0cdbf3-b161-4465-986e-ab9600d021c3.webm )
36
+ # Run the read_video.py program.
37
+ make read-video
38
+ ```
Original file line number Diff line number Diff line change
1
+ opencv-contrib-python == 4.10.0.84
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 1
1
import cv2 as cv
2
-
3
- import reScale
2
+ import os
3
+ import re_scale
4
4
5
5
# Takes the path of an image and returns it as a matrix of pixels.
6
- image = cv .imread ('photos/drone.jpg' )
6
+ file_path = os .path .join (os .path .dirname (__file__ ), 'files/image.jpg' )
7
+ image = cv .imread (file_path )
7
8
9
+ print (image .shape )
8
10
9
11
# Resized the image to 25% smaller.
10
- resized_frame = reScale .frame (image )
12
+ resized_frame = re_scale .frame (image )
11
13
12
14
# Display the image as a new window.
13
15
cv .imshow ('Drone' , resized_frame )
Original file line number Diff line number Diff line change 1
1
import cv2 as cv
2
- import reScale
2
+ import os
3
+ import re_scale
3
4
4
5
# You can pass integer (0/1/2) which will represent your machine webcam.
5
- videoCapture = cv .VideoCapture ('videos/video1.mp4' )
6
+ file_path = os .path .join (os .path .dirname (__file__ ), 'files/video.mp4' )
7
+ videoCapture = cv .VideoCapture (file_path )
6
8
7
9
while True :
8
10
# Read the video frame by frame.
9
11
isTrue , frame = videoCapture .read ()
10
12
11
13
# Resize the frame.
12
- resized_frame = reScale .frame (frame , 0.50 )
14
+ resized_frame = re_scale .frame (frame , 0.50 )
13
15
14
16
# Display an individual frame.
15
- cv .imshow ('Video' , resized_frame )
16
-
17
+ cv .imshow ('Video' , resized_frame )
18
+
17
19
# Stop the video from playing indefinitely.
18
20
if cv .waitKey (20 ) & 0xFF == ord ('d' ):
19
21
break
You can’t perform that action at this time.
0 commit comments