Ask Your Question

hoju's profile - activity

2019-08-11 23:34:03 -0600 received badge  Notable Question (source)
2017-01-12 12:11:12 -0600 received badge  Popular Question (source)
2016-09-05 14:03:56 -0600 received badge  Nice Question (source)
2016-06-27 09:50:27 -0600 received badge  Famous Question (source)
2016-06-22 20:23:15 -0600 received badge  Notable Question (source)
2016-06-22 20:23:15 -0600 received badge  Popular Question (source)
2015-06-08 06:45:14 -0600 commented answer Face detection (haarcascade) OpenCV Python

Loading the cascade can silently fail if the file is not found. Can check with: assert(not face_cascade.empty()). I would prefer this raised an Exception when not found because it tripped me up a few times.

2015-06-08 05:50:34 -0600 received badge  Nice Answer (source)
2015-06-08 04:45:16 -0600 received badge  Teacher (source)
2015-06-08 03:43:06 -0600 answered a question meanshift working only with .avi not with webcam why????

I tried your code and it worked for me - the box moved with a camera feed. Perhaps your lighting is poor so that the detection failed.

2015-06-08 03:38:24 -0600 answered a question Face detection (haarcascade) OpenCV Python

Your snippet tries to do more than detect the face. If just trying to get the box working I suggest you get a simple example working first, like this to put a box around the detected face:

import cv2

face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
assert(not face_cascade.empty())
cam = cv2.VideoCapture(0)

ret = True
while ret:
    ret, img = cam.read()
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    faces = face_cascade.detectMultiScale(gray, 1.3, 5)
    for (x,y,w,h) in faces:
        img = cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
    cv2.imshow('img',img)
    if 0xFF & cv2.waitKey(5) == 27:
        break

cv2.destroyAllWindows()
2015-06-08 03:26:14 -0600 answered a question Is c++ better suited than Python for real-time applications?

I find if the application can be built largely using the existing opencv methods, which wrap the C implementations, then no problem. However if I need to implement my own per pixel algorithms then much faster to drop down to the C interface.

2015-06-08 03:07:38 -0600 received badge  Editor (source)
2015-06-08 03:07:10 -0600 asked a question How to determine when CamShift failed?

How to determine when CamShift failed to confidently find the new location?

Previously with meanShift I checked the return value for the number of iterations to converge, and if it reached the maximum set in criteria then I assumed this was not a match:

>>> criteria = (cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, 10, 1)
>>> retval, window = cv2.meanShift(probImage, window, criteria)
>>> retval
10

However with CamShift the return value is no longer the number of iterations:

>>> retval, window = cv2.CamShift(probImage, window, criteria)
>>> retval
((327.0, 323.0), (205.42239379882812, 253.79466247558594), 19.084074020385742)

The documentation says this method returns:

(in old interfaces) Number of iterations CAMSHIFT took to converge

I am using version 3 so I guess is not the old version. Is there a way in version 3 to find the number of iterations to converge? Or a better way to determine whether camshift failed?

2015-06-08 02:50:13 -0600 commented answer Why do python bindings for v3 still use package name "cv2"?

got it - thanks!

2015-06-08 02:49:21 -0600 received badge  Scholar (source)
2015-06-08 02:49:19 -0600 received badge  Supporter (source)
2015-06-07 00:50:11 -0600 received badge  Student (source)
2015-06-07 00:25:18 -0600 asked a question Python bindings for OpenCV3 missing modules

I tried the Python examples in OpenCV3 and got some missing module errors:

$ python
>>> import cv2
>>> cv2.__version__
'3.0.0'

$ python asift.py
Traceback (most recent call last):
  File "asift.py", line 121, in <module>
    detector, matcher = init_feature(feature_name)
  File "/home/hoju/downloads/opencv-3.0.0/samples/python2/find_obj.py", line 28, in init_feature
    detector = cv2.xfeatures2d.SIFT_create()
AttributeError: 'module' object has no attribute 'xfeatures2d'

$ python feature_homography.py 
Traceback (most recent call last):
  File "feature_homography.py", line 94, in <module>
    App(video_src).run()
  File "feature_homography.py", line 75, in run
    draw_keypoints(vis, self.tracker.frame_points)
AttributeError: PlaneTracker instance has no attribute 'frame_points'

$ python gaussian_mix.py
Traceback (most recent call last):
  File "gaussian_mix.py", line 40, in <module>
    em = cv2.EM(cluster_n, cv2.EM_COV_MAT_GENERIC)
AttributeError: 'module' object has no attribute 'EM'

$ python letter_recog.py
Traceback (most recent call last):
  File "letter_recog.py", line 161, in <module>
    model = Model()
  File "letter_recog.py", line 61, in __init__
    self.model = cv2.RTrees()
AttributeError: 'module' object has no attribute 'RTrees'

The OpenCV bug page says to post problems here first, so here it is.

2015-06-07 00:25:18 -0600 commented question Error compiling opencv 3 with python 3.4 support

should put error in a code block so is readable

2015-06-07 00:25:18 -0600 commented question Installing OpenCV 3 alpha for python in windows?

for some reason still cv2...

2015-06-07 00:25:17 -0600 asked a question Why do python bindings for v3 still use package name "cv2"?

I compiled the python bindings for latest version and found the package name is still cv2:

>>> import cv3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named cv3
>>> import cv2
>>> cv2.__version__
'3.0.0'

Is the package name going to be updated to cv3?