Ask Your Question
1

Detect open door with traincascade?

asked 2015-03-04 14:21:44 -0600

NemoN gravatar image

Hello all,

i'm a opencv beginner. Currently i try to detect a door status (open/closed) under different light conditions (night, day, sunshine, ...). I'm unsure about the best approach. I experimented a little bit with the traincascade but without success. Maybe someone can point me in the right direction.

I attached some example images.

Closed garage door:

image description image description

Open:

image description image description

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2015-03-04 16:31:30 -0600

luketheduke gravatar image

There are multiple solutions:

  1. First You could try using a color mask to see if the black door is present.

  2. You could also wire a light connected to a switch which closes when the door is open. That would also use a color mask.

  3. Lastly you could just not use OpenCV at all and use a laser connected to a switch as described above and use a Arduino with a light sensor to see if the door is open.

Hope that helps!

edit flag offensive delete link more

Comments

Using color defined masks won't work since he clearly wants it to work in day and night conditions and also various lighting conditions. Setting a mask based on color will be to fixed to a certain situation. I would skip color information alltogether. The laser approach is better. If you want to use OpenCV, than cascade classifiers are not the way to go. Since your camera is fixed you could try adaptive background subtraction between frames or a classifier based on open and closed doors decribed by descriptors of the door region (which is known due to fixed camera setup)

StevenPuttemans gravatar imageStevenPuttemans ( 2015-03-06 02:42:43 -0600 )edit
0

answered 2016-01-06 02:13:31 -0600

rbs90 gravatar image

I was also interessted in detecting a door state with OpenCV. My best result was using the floodfill algorithm:

import cv2
from numpy import *

test_imgs = ['night_open.jpg', 'night_closed.jpg', 'day_open.jpg', 'day_closed.jpg']

for imgFile in test_imgs:
    img = cv2.imread(imgFile)
    height, width, channels = img.shape
    mask = zeros((height+2, width+2), uint8)

    #the starting pixel for the floodFill
    start_pixel = (510,110)
    #maximum distance to start pixel:
    diff = (2,2,2)

    retval, rect = cv2.floodFill(img, mask, start_pixel, (0,255,0), diff, diff)

    print retval

    #check the size of the floodfilled area, if its large the door is closed:
    if retval > 10000:
        print imgFile + ": garage door closed"
    else:
        print imgFile + ": garage door open"

    cv2.imwrite(imgFile.replace(".jpg", "") + "_result.jpg", img)

Programm output:

681
night_open.jpg: garage door open
19802
night_closed.jpg: garage door closed
639
day_open.jpg: garage door open
19847
day_closed.jpg: garage door closed

Result images:

day closed day open night closed night open

edit flag offensive delete link more

Comments

How to decide the retval area threshold for different image size?

pZ gravatar imagepZ ( 2019-05-13 03:17:19 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-03-04 14:21:44 -0600

Seen: 4,617 times

Last updated: Mar 04 '15