c++ - How can I detect TV Screen from an Image with OpenCV or Another Library? -
i've working on time now, , can't find decent solution this.
i utilize opencv image processing , workflow this:
took image of tv. split image in r, g, b planes - i'm starting test using h, s, v , seems bit promising. for each plane, threshold image range values in 0 255 reduce noise, observe edges canny, find contours , approximate it. select contours contains center of image (i can assume center of image within tv screen) use convexhull , houglines filter , refine invalid contours. select contours area (area between 10%-90% of image). keep contours have 4 points.but slow (loop on each channel (rgb), loop threshold, etc...) , not enought not detects many tv's.
my base of operations code squares.cpp illustration of opencv framework.
the main problems of tv screen detection, are:
images half dark , half bright or have many dark/bright items on screen. elements on screen have same color of tv frame. blurry tv edges (in cases).i have searched many questions/answers on rectangle detection, detecting white page on dark background or fixed color object on contrast background.
my final goal implement on android/ios near-real time tv screen detection. code takes 4 seconds on galaxy nexus.
hope help . in advance!
update 1: using canny , houghlines, not work, because there can many many lines, , selecting right ones can difficult. think sort of "cleaning" on image should done first.
update 2: question 1 of close problem, tv screen, didn't work.
hopefully these points provide insight:
1)
if can segment image via foreground , background, can set bounding box around foreground. graph cuts powerful methods of segmenting images. appears opencv provides easy utilize implementations it. so, example, provide brush strokes cover "foreground" , "background" pixels, , image converted digraph sliced optimally split two. here fun example:
http://docs.opencv.org/trunk/doc/py_tutorials/py_imgproc/py_grabcut/py_grabcut.html
this quick set illustrate effectiveness:
2)
if decide go on downwards border detection route, consider using mathematical morphology "clean up" lines observe before trying fit bounding box or contour around object.
http://en.wikipedia.org/wiki/mathematical_morphology
3)
you train across dataset containing tvs , utilize viola jones algorithm object detection. traditionally used face detection can adapt tvs given plenty data. illustration script downloading images of living rooms tvs positive class , living rooms without tvs negative class.
http://en.wikipedia.org/wiki/viola%e2%80%93jones_object_detection_framework http://docs.opencv.org/trunk/doc/py_tutorials/py_objdetect/py_face_detection/py_face_detection.html
4)
you perform image registration using cross correlation, nice matlab illustration demonstrates:
http://www.mathworks.com/help/images/examples/registering-an-image-using-normalized-cross-correlation.html
as template tv image slid across search image, obtain bunch of pictures of tvs , create "eigenscreens" similar how eigenfaces used facial recognition , generate average tv image:
http://jeremykun.com/2011/07/27/eigenfaces/
5)
it appears opencv has plenty of fun tools describing shape , construction features, appears you're interested in. worth if haven't seen already:
http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html
best of luck.
c++ image opencv image-processing
No comments:
Post a Comment