#!/usr/bin/env python2 import numpy as np import cv2 as cv def FCD( src, mask ): A_THRESH = [ 2, 1 ] sobel_x = cv.Sobel( src, cv.CV_32F, 1, 0, ksize = 5 ) sobel_y = cv.Sobel( src, cv.CV_32F, 0, 1, ksize = 5 ) magnitude, angle = cv.cartToPolar( sobel_x, sobel_y, angleInDegrees = True ) angle = np.around( angle, 0 ) # v = [[]]*360 # for x, y in np.transpose( np.nonzero( magnitude > mask ) ) : # ag = angle.item( x, y ) # if ag == 360: ag = 0 # v[int(ag)].append( ( x, y ) ) for a in range(180) : for b in range( a + 180 - A_THRESH[0], ( a + 180 + A_THRESH[0] ) % 360 ) : #v[a], v[b] # ??? where did the code go # cv.imshow( "j", edges ) cam = cv.VideoCapture(0) cv.namedWindow( "i" ) cv.namedWindow( "j" ) while True: rval, src = cam.read() src_hsv = cv.cvtColor( src, cv.COLOR_BGR2HSV ) blurred = cv.GaussianBlur( src_hsv[...,2], (7,7), 5 ) FCD( blurred, 1000 ) cv.imshow( "i", blurred ) if cv.waitKey(20) == 27 : break