Learn practical skills, build real-world projects, and advance your career
import cv2
import os
import glob
import numpy as np
import time
import jovian
paths = glob.glob("C:\\Users\\vsneh\\Udemy-notebooks\\X_CLASSIFIER\\n1\\*")
#print(paths)
count = 0
for i in paths:
    count = count+1
    frame = cv2.imread(i)
    #frame = np.rot90(frame)
    #frame = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
    cv2.resize(frame,(180,180))
    #cv2.imshow('test',frame)
    cv2.imwrite('C:\\Users\\vsneh\\Udemy-notebooks\\X_CLASSIFIER\\n\\%d.jpg'%count,frame)

import time
 
vidObj = cv2.VideoCapture("C:\\Users\\vsneh\\Udemy-notebooks\\pro_X_vid.mp4") 
count = 1
success = 1
  
while True: 
    success, image = vidObj.read()
    image = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
    image = np.rot90(image)
    cv2.resize(image,(180,180))
        # Saves the frames with frame-count 
    #time.sleep(0.7)
    cv2.imwrite('C:\\Users\\vsneh\\Udemy-notebooks\\X_CLASSIFIER\\p\\%d.jpg'%count, image) 
  
    count += 1
vidObj.release()
cv2.destroyAllWindows()
--------------------------------------------------------------------------- error Traceback (most recent call last) <ipython-input-7-b054b8014813> in <module> 7 while True: 8 success, image = vidObj.read() ----> 9 image = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY) 10 image = np.rot90(image) 11 cv2.resize(image,(180,180)) error: OpenCV(4.1.1) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'
classifier = cv2.CascadeClassifier('C:/Users/vsneh/Udemy-notebooks/DATA/haarcascades/custom-hand-cascade.xml')
cap = cv2.VideoCapture(0)
while True:
    _,frame = cap.read()
    location = classifier.detectMultiScale(frame,scaleFactor = 1.3,minNeighbors = 1)
    for x,y,w,h in location:
        cv2.rectangle(frame,(x,y),(x+w,y+h),[0,255,0],6)
        cv2.imshow('Final Testing',frame)
    if(cv2.waitKey(1) == ord('q')):
        break
cap.release()
cv2.destroyAllWindows()
classifier = cv2.CascadeClassifier('C:/Users/vsneh/Udemy-notebooks/DATA/haarcascades/custom-hand-cascade.xml')
paths = glob.glob('C:/Users/vsneh/Udemy-notebooks/X_Pics/*')
count = 0
for i in paths:
    count = count+1
    img = cv2.imread(i)
    img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
    img = cv2.resize(img,(180,180))
    cv2.imwrite('C:/Users/vsneh/Udemy-notebooks/X_Pics/%d.jpg'%count,img)
#img = cv2.imread('C:/Users/vsneh/Udemy-notebooks/X_Pics')