Demo entry 6357589

python

   

Submitted by anonymous on Apr 23, 2017 at 11:56
Language: Python 3. Code size: 608 Bytes.

>Step 5: Bounding box around the detected vehicle
kernel = np.ones((10,10),np.uint8)
    dilation = cv2.dilate(fgmask,kernel,iterations = 1)
    erosion = cv2.erode(fgmask,kernel,iterations = 1)
    img,contours,hierarchy = cv2.findContours(fgmask,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)

    for i in range(0, len(contours)):
        if (i % 1 == 0):
            cnt = contours[i]
            x,y,w,h = cv2.boundingRect(cnt)
            cv2.drawContours(fgmask ,contours, -1, (255,255,0), 3)
            cv2.rectangle(fgmask,(x,y),(x+w,y+h),(255,0,0),2)
            cv2.imshow('frame',fgmask)

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).