Pythonlanguagecode

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

for File in path:
    #print(File)
    img=cv2.imread(File)
    #cv2.imshow('image',img)

I have 30 images in the images name folder but it shows only one image can anyone help me with this.

where’s the waitKey? you haven’t disclosed some important pieces of the 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:

#print(File)

img=cv2.imread(File)

#cv2.imshow('image',img)

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))

dl_detector.setInput(img)

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:

    continue

# 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:

    cv2.circle(img, (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)
cv2.waitKey(0)

cv2.destroyAllWindows()
this is the full code
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.

the formatting of your second post is very broken. I can’t read it.

I fixed the formatting of your first post. please look at (“edit”) your first post to see how code formatting is used.

if you need help with general python programming, this is not the best forum for that.