-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
efb6180
commit 84b3230
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import cv2 | ||
from datetime import datetime | ||
import sys | ||
import numpy as np | ||
|
||
# create the VideoCapture inst | ||
cam = cv2.VideoCapture(0) | ||
input('Press Enter to capture') | ||
ret, img = cam.read() | ||
capture_image1_name = "test1_" + str(datetime.now()) + ".png" | ||
cv2.imwrite(capture_image1_name, img) | ||
cam.release() | ||
|
||
# Let me click one more pic | ||
cam = cv2.VideoCapture(0) | ||
input('Press Enter to capture another one') | ||
ret, img = cam.read() | ||
capture_image2_name = "test2_" + str(datetime.now()) + ".png" | ||
cv2.imwrite(capture_image2_name, img) | ||
cam.release() | ||
|
||
# Now we have captured the image let's create the collage out of it | ||
# with color | ||
img_read1_0 = cv2.imread(capture_image1_name, cv2.IMREAD_COLOR) | ||
img_read2_0 = cv2.imread(capture_image2_name, cv2.IMREAD_COLOR) | ||
|
||
# resize | ||
img_read1 = cv2.resize(img_read1_0, (250, 250)) | ||
img_read2 = cv2.resize(img_read2_0, (250, 250)) | ||
|
||
# Vertically stack up two images of first capture | ||
col1 = np.vstack([img_read1, img_read1]) | ||
|
||
# Vertically stack up two images of secodn capture | ||
col2 = np.vstack([img_read2, img_read2]) | ||
|
||
# Now horizontally put them side-by-side | ||
collage = np.hstack([col1, col2]) | ||
|
||
# Create the collage | ||
k = cv2.waitKey(0) | ||
cv2.imwrite("collage.png", collage) |