-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonkey_compact.py
More file actions
33 lines (25 loc) · 957 Bytes
/
monkey_compact.py
File metadata and controls
33 lines (25 loc) · 957 Bytes
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
import cv2
import os
import subprocess
# File to shrink down the sizes of the captures images
W = 100.
subprocess.run("rm -rf neg", shell=True)
subprocess.run("mkdir neg", shell=True)
subprocess.run("rm -rf pos", shell=True)
subprocess.run("mkdir pos", shell=True)
# resize negatives
for filename in os.listdir('negative'):
image = cv2.imread('negative/' + filename)
height, width, depth = image.shape
imgScale = W / width
newX, newY = image.shape[1] * imgScale, image.shape[0] * imgScale
newImage = cv2.resize(image, (int(newX), int(newY)))
cv2.imwrite("neg/" + filename, newImage)
# resize positives
for filename in os.listdir('positive'):
image = cv2.imread('positive/' + filename)
height, width, depth = image.shape
imgScale = W / width
newX, newY = image.shape[1] * imgScale, image.shape[0] * imgScale
newImage = cv2.resize(image, (int(newX), int(newY)))
cv2.imwrite("pos/" + filename, newImage)