forked from DivyanshMalhotra/HashHacks3_jsk1961998935
-
Notifications
You must be signed in to change notification settings - Fork 0
/
both_image_stich.py
71 lines (56 loc) · 1.9 KB
/
both_image_stich.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import numpy as np
import cv2
# Capture video from file
cap = cv2.VideoCapture(1)
cap1 = cv2.VideoCapture(0)
outpath1=r"C:\Users\PIYUSH\Desktop\piyush.jpeg"
outpath2=r"C:\Users\PIYUSH\Desktop\piyush2.jpeg"
outpath3=r"C:\Users\PIYUSH\Desktop\piyush3.jpeg"
while True:
ret, frame = cap.read()
ret1, frame1 = cap1.read()
if ret == True:
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('frame',frame)
cv2.imwrite(outpath1,gray)
cv2.waitKey(1)
cap.release()
if ret1 == True:
gray1 = cv2.cvtColor(frame1, cv2.COLOR_BGR2GRAY)
cv2.imshow('frame1',frame1)
cv2.imwrite(outpath2,frame1)
cv2.waitKey(1)
cap1.release()
if cv2.waitKey(30) & 0xFF == ord('q'):
break
else:
break
cv2.destroyAllWindows()
from Stitcher import stitcher
# import the necessary packages
import argparse
import imutils
import cv2
# construct the argument parse and parse the arguments
'''ap = argparse.ArgumentParser()
ap.add_argument("-f", "--first", required=True,
help="path to the first image")
ap.add_argument("-s", "--second", required=True,
help="path to the second image")
args = vars(ap.parse_args())'''
# load the two images and resize them to have a width of 400 pixels
# (for faster processing)
imageA = cv2.imread(r'C:\Users\PIYUSH\Desktop\piyush.jpg')
imageB = cv2.imread(r'C:\Users\PIYUSH\Desktop\piyush2.jpg')
imageA = imutils.resize(imageA, width=400)
imageB = imutils.resize(imageB, width=400)
# stitch the images together to create a panorama
stitcher = stitcher()
(result, vis) = stitcher.stitch([imageA, imageB], showMatches=True)
# show the images
#cv2.imshow("Image A", imageA)
#cv2.imshow("Image B", imageB)
cv2.imshow("Keypoint Matches", vis)
cv2.imwrite(outpath3,vis)
#cv2.imshow("Result", result)
cv2.waitKey(0)