Posts

Showing posts from December, 2022
Image
  Computer vision: Run your code on your phone camera + Face bluring  import numpy as np  import cv2  import os  os.chdir(r"E:\faceeyedetection") cap =cv2.VideoCapture(0) address = 'put your address here' cap.open(address) face_cascade =cv2.CascadeClassifier("haarcascade_frontalface_default.xml") #eyes_cascade =cv2.CascadeClassifier("haarcascade_eye.xml") while(cap.isOpened()):     ret ,frame =cap.read()                      gray =cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)                          faces =face_cascade.detectMultiScale(gray ,1.3 , 4)                     for (x,y,h,w) in faces :                        img = cv2.rectangle(frame ,(x,y),(x+w ,y+h),(0,255,0),3)            ...
Image
  Computer vision:eye detection using open CV  import numpy as np  import cv2  import os  os.chdir(r"E:\faceeyedetection") cap =cv2.VideoCapture(0) face_cascade =cv2.CascadeClassifier("haarcascade_frontalface_default.xml") eyes_cascade =cv2.CascadeClassifier("haarcascade_eye.xml") while(cap.isOpened()):     ret ,frame =cap.read()                    gray =cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)                     faces =face_cascade.detectMultiScale(gray ,1.3 , 4)     for (x,y,h,w) in faces :         cv2.rectangle(frame ,(x,y),(x+w ,y+h),(0,255,0),3)                roi_gray=gray[y:y+h ,x:x+w]                roi_color=frame[y:y+h ,x:x+w]                eyes =eyes_cascade.detectMultiScale(roi_gray)...
Image
Computer vision:Face Detection using Haar Cascade Classifiers  import numpy as np  import cv2  import os  os.chdir(r"E:\faceeyedetection") cap =cv2.VideoCapture(0) face_cascade =cv2.CascadeClassifier("haarcascade_frontalface_default.xml") eyes_cascade =cv2.CascadeClassifier("haarcascade_eye.xml") while(cap.isOpened()):     ret ,frame =cap.read()          gray =cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)          faces =face_cascade.detectMultiScale(gray ,1.3 , 4)     for (x,y,h,w) in faces :         cv2.rectangle(frame ,(x,y),(x+w ,y+h),(0,255,0),3)                roi_gray=gray[y:y+h ,x:x+w]                roi_color=frame[y:y+h ,x:x+w]                eyes =eyes_cascade.detectMultiScale(roi_gray)                for(ex,ey,eh,ew)...
Image
Computer Vision: image Histograms and contrast stretching using OpenCV Python  import numpy as np import cv2 as cv from matplotlib import pyplot as plt img = cv.imread("lena.jpg") #img = np.zeros((200,200), np.uint8) #cv.rectangle(img, (0, 100), (200, 200), (255), -1) #cv.rectangle(img, (0, 50), (100, 100), (127), -1) b, g, r = cv.split(img) cv.imshow("img", img) cv.imshow("b", b) cv.imshow("g", g) cv.imshow("r", r) plt.hist(b.ravel(), 256, [0, 256]) plt.hist(g.ravel(), 256, [0, 256]) plt.hist(r.ravel(), 256, [0, 256]) hist = cv.calcHist([img], [0], None, [256], [0, 256]) plt.plot(hist) plt.show() cv.waitKey(0) cv.destroyAllWindows() ============================== Data used in this video   ============================= if  you faced any issue contact me via  what 's app : +201210894349 or   facebook
Image
Computer vision: Detect Simple Geometric Shapes using OpenCV in Python | arabic   import numpy as np import cv2 img = cv2.imread('shapes.jpg') imgGrey = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) _, thrash = cv2.threshold(imgGrey, 240, 255, cv2.THRESH_BINARY) contours, _ = cv2.findContours(thrash, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE) cv2.imshow("img", img) for contour in contours:     approx = cv2.approxPolyDP(contour, 0.01* cv2.arcLength(contour, True), True)               cv2.drawContours(img, [approx], 0, (0, 0, 0), 5)               x = approx.ravel()[0]               y = approx.ravel()[1] - 5                if len(approx) == 3:                   cv2.putText(img, "Triangle", (x, y), cv2.FONT_HERSHEY_COMPLEX, 0.5, (0, 0, 0))            ...
Image
Computer vision:Vehicle detection and  counting using openCV | Arabic import cv2 import numpy as np from time import sleep largura_min = 80 altura_min = 80 offset = 6 pos_linha = 550 # FPS to vĂ­deo delay = 60 detec = [] carros = 0 def pega_centro(x, y, w, h):     x1 = int(w / 2)     y1 = int(h / 2)     cx = x + x1     cy = y + y1     return cx, cy # video source input cap = cv2.VideoCapture('video.mp4') subtracao = cv2.bgsegm.createBackgroundSubtractorMOG() while True:     ret, frame1 = cap.read()             tempo = float(1/delay)              sleep(tempo)              grey = cv2.cvtColor(frame1, cv2.COLOR_BGR2GRAY)              blur = cv2.GaussianBlur(grey, (3, 3), 5)               img_sub = subtracao.apply(blur)        ...
Image
  Computer vision: detect , track and count car and moto in video using openCV  computer vision  import cv2 from tracker import * import os os.chdir("D:\object traking\object_tracking") result = cv2.VideoWriter('ahmedd.mp4',                           cv2.VideoWriter_fourcc(*'XVID'),                          20, (250,250)) # Create tracker object tracker = EuclideanDistTracker() cap = cv2.VideoCapture("highway.mp4") # Object detection from Stable camera object_detector = cv2.createBackgroundSubtractorMOG2(history=100, varThreshold=50) # if history is big number it will be hight  while True:     ret, frame = cap.read()             if ret is not True:                 break                   height, w...