Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to use a dpm cascade model xml file in a Python script?

I was wondering if I can use the same code used to run a Haar Cascade xml file , to run the dpm cascade model xml file.

My code looks like this :

import numpy as np

import cv2

cow_cascade = cv2.CascadeClassifier('cow.xml')

img = cv2.imread('Cow3.bmp')

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

cows = cow_cascade.detectMultiScale(gray, 1.3, 5)

for (x,y,w,h) in cows:

cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)

roi_gray = gray[y:y+h, x:x+w]

roi_color = img[y:y+h, x:x+w]

cv2.imshow('img',img)

cv2.waitKey(0)

cv2.destroyAllWindows()

What are the modifications to be made to use a dpm cascade model xml file ?