import cv2 as cv
- code:
import cv2 as cv
#resizing the image
img = cv.imread("resources/img1.jpeg")
img1 = cv.resize(img,(400,300))
cv.imshow("first image", img)
cv.imshow("first image", img1)
cv.waitKey(0)
cv.destroyWindow()*
- code:
gray_img = cv.cvtColor(img, cv.COLOR_BGR2GRAY)*
- code:
import cv2 as cv
#resizing the image
img = cv.imread("resources/img1.jpeg")
img1 = cv.resize(img,(400,300))
cv.imshow("first image", img)
cv.imshow("first image", img1)
cv.waitKey(0)
cv.destroyWindow()*
- code:
import cv2 as cv
from cv2 import imwrite
img = cv.imread("resources/img1.jpeg")
img = cv.resize(img,(400,300))
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
imwrite('resources/image_gray.png', gray)
cv.waitKey(0)
cv.destroyWindow()*
- code:
import cv2 as cv
cap = cv.VideoCapture('resources/video.mp4')
#indicator(are we reading video or not)
if (cap.isOpened() == False):
print("ERROR IN READING VIDEO")
#reading and playing video
while(cap.isOpened()):
ret,frame = cap.read()
if ret == True:
cv.imshow("video", frame)
#quiting form window by pressing 'q'
if cv.waitKey(1) & 0xFF == ord('q'):
break
else:
break
cap.release()
cv.destroyAllWindows()*
- code:
import cv2 as cv
cap = cv.VideoCapture('resources/video.mp4')
while(True):
ret, frame = cap.read()
grayframe = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
#(thresh, binary) = cv.threshold(gray, 127, 255, cv.THRESH_BINARY)
if ret == True:
cv.imshow("video", grayframe)
#quiting form window by pressing 'q'
if cv.waitKey(1) & 0xFF == ord('q'):
break
else:
break
cap.release()
cv.destroyAllWindows()*