Opencv programming

this is the full code:

from imutils import face_utils, video, resize

import dlib

import numpy as np

import cv2

import argparse

import os

import glob

W = './shape_predictor_68_face_landmarks.dat'

P = 'C:/Users/CHINMAYEE/Pictures/Saved Pictures/facial-landmarks-master/deploy.prototxt'

M = 'C:/Users/CHINMAYEE/Pictures/Saved Pictures/facial-landmarks-master/res10_300x300_ssd_iter_140000.caffemodel'

T = 0.6

predictor = dlib.shape_predictor(W)

#image = cv2.imread("C:/Users/CHINMAYEE/Pictures/Saved Pictures/facial-landmarks-master/IMG2.PNG")

path= glob.glob("C:/Users/CHINMAYEE/Pictures/Saved Pictures/facial-landmarks-master/images/*.PNG")

for File in path:




# Converting the image to gray scale

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# This is based on SSD deep learning pretrained model

dl_detector = cv2.dnn.readNetFromCaffe(P, M)

# Facial landmarks with DL

#inputBlob = cv2.dnn.blobFromImage(cv2.resize(

    #img, (300, 300)), 1, (300, 300), (104, 177, 123))


detections = dl_detector.forward()

for i in range(0, detections.shape[1]):


    # Probability of prediction

    prediction_score = detections[0, 0, i, 2]

    if prediction_score < T:


    # Finding height and width of frame

    (h, w) = img.shape[:2]

    # compute the (x, y)-coordinates of the bounding box for the

    # object

    box = detections[0, 0, i, 3:7] * np.array([w, h, w, h])

    (x1, y1, x2, y2) = box.astype("int")

    y1, x2 = int(y1 * 1.15), int(x2 * 1.05)

    print(x1, y1, x2, y2)

    # Make the prediction and transfom it to numpy array

    shape = predictor(gray, dlib.rectangle(left=x1, top=y1, right=x2, bottom=y2))

    shape = face_utils.shape_to_np(shape)

    cv2.rectangle(img, (x1, y1), (x2, y2), (0, 0, 255), 2)

    # Draw on our image, all the finded cordinate points (x,y)

    for (x, y) in shape:, (x, y), 2, (0, 0, 255), -1)

img_height, img_width = img.shape[:2]

cv2.putText(img, "DL", (img_width - 100, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5,

            (0, 0, 255), 2)

# show the output frame

cv2.imshow("Facial Landmarks", img)


I have more than 1 image in the image folder but this code runs for only one image. can you please help me out with this

that’s the problem. since you are a beginner to programming, and the problem is fundamental programming (loops, variables), you should find a forum that is intended for general programming questions. this forum is specific to OpenCV issues and basic programming proficiency is expected.