0

I'm new here.

I'm having some problems with segmentating hands in OpenCV, Python from video. I looked over every topic I could, but I can't see my mistake in code I wrote.

Please, note I worked only once with Python and only with basics - it's my first OpenCV application ever.

My problem is that I'm getting output video as black with some white squares. I assume, I'm using wrong values in thresholds. I took colour from the middle of the hand, conversed it to HSV and set lower values to [99,100,100] and upper [119,255,255].

Can anyone help me?

Here is code, if anyone would like to look at it:

import numpy as np
import cv2
cap = cv2.VideoCapture('vid2.avi')

fourcc = cv2.cv.CV_FOURCC(*'MP4V')
out = cv2.VideoWriter('output.avi',fourcc, 29, (1920,1080))

while(1):
    ret, frame = cap.read()        
    if ret==True:
      hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)        
      blur = cv2.GaussianBlur(hsv, (15, 15), 0)
      lower = np.array([99,100,100])
      upper = np.array([119,255,255]) 
      mask = cv2.inRange(blur, lower, upper)
      res = cv2.bitwise_and(frame,frame, mask= mask)        
      out.write(res)

    if ret==False:
        break      
cap.release()
cv2.destroyAllWindows() 
out.release()
  • I see at least two things wrong: 1) GaussianBlur sigma can't be 0. A reasonable value can be 1. 2) With your bounds, your are segmenting basically_blue_ color. See [here](http://stackoverflow.com/a/31465462/5008845) for details – Miki Feb 11 '16 at 16:53
  • Thank you very much for help @Miki - indeed, due to your tips I managed to segmentate hand-ish shapes from my video. I'll try to use some operations to make it look more like hands. – Sad Engineer Feb 11 '16 at 18:05

0 Answers0