def __findedge(self, filename): tmpimg = highgui.cvLoadImage (filename) self.img = cv.cvCreateImage(cv.cvSize(int(tmpimg.width * self.enlarge), int(tmpimg.height * self.enlarge)), 8, 3) cv.cvResize(tmpimg, self.img, cv.CV_INTER_LINEAR) if (self.drawimage): self.drawimg = cv.cvCloneImage(self.img) else: self.drawimg = cv.cvCreateImage(cv.cvGetSize(self.img), 8, 3) greyimg = cv.cvCreateImage(cv.cvSize(self.img.width, self.img.height), 8,1) cv.cvCvtColor(self.img, greyimg, cv.CV_BGR2GRAY) self.allcurve = [] for i in range(80, 200, 20): bimg = cv.cvCloneImage(greyimg) cv.cvSmooth(bimg, bimg, cv.CV_MEDIAN, 9) # cv.cvSmooth(bimg, bimg, cv.CV_BILATERAL, 9) # cv.cvSmooth(bimg, bimg, cv.CV_BLUR, 9) # cv.cvSmooth(bimg, bimg, cv.CV_BLUR, 9) cv.cvThreshold(greyimg, bimg, i, 255, cv.CV_THRESH_BINARY) self.__findcurve(bimg)
def DrawKeyPoints(self): if (not self.drawimg): self.drawimg = cv.cvCloneImage(self.img) myfont = cv.cvInitFont(cv.CV_FONT_HERSHEY_SIMPLEX, 0.5, 0.5) ic = 0 for c in self.points: cv.cvPutText(self.drawimg, str(ic), cv.cvPoint(int(c.x), int(c.y)), myfont, cv.cvScalar(255, 255, 0,0)) ic += 1 cv.cvDrawCircle(self.drawimg, c, 4, cv.cvScalar(255,255,0,0))
def DrawKeyPoints(self): if (not self.drawimg): self.drawimg = cv.cvCloneImage(self.img) myfont = cv.cvInitFont(cv.CV_FONT_HERSHEY_SIMPLEX, 0.5, 0.5) ic = 0 for c in self.points: cv.cvPutText(self.drawimg, str(ic), cv.cvPoint(int(c.x), int(c.y)), myfont, cv.cvScalar(255, 255, 0, 0)) ic += 1 cv.cvDrawCircle(self.drawimg, c, 4, cv.cvScalar(255, 255, 0, 0))
def __findedge(self, filename): tmpimg = highgui.cvLoadImage(filename) self.img = cv.cvCreateImage( cv.cvSize(int(tmpimg.width * self.enlarge), int(tmpimg.height * self.enlarge)), 8, 3) cv.cvResize(tmpimg, self.img, cv.CV_INTER_LINEAR) if (self.drawimage): self.drawimg = cv.cvCloneImage(self.img) else: self.drawimg = cv.cvCreateImage(cv.cvGetSize(self.img), 8, 3) greyimg = cv.cvCreateImage(cv.cvSize(self.img.width, self.img.height), 8, 1) cv.cvCvtColor(self.img, greyimg, cv.CV_BGR2GRAY) self.allcurve = [] for i in range(80, 200, 20): bimg = cv.cvCloneImage(greyimg) cv.cvSmooth(bimg, bimg, cv.CV_MEDIAN, 9) # cv.cvSmooth(bimg, bimg, cv.CV_BILATERAL, 9) # cv.cvSmooth(bimg, bimg, cv.CV_BLUR, 9) # cv.cvSmooth(bimg, bimg, cv.CV_BLUR, 9) cv.cvThreshold(greyimg, bimg, i, 255, cv.CV_THRESH_BINARY) self.__findcurve(bimg)
def mask_image( im, mask ): if mask.depth == 8: bim = cv.cvCreateImage( cv.cvSize(mask.width, mask.height), cv.IPL_DEPTH_32F, mask.nChannels ) cv.cvConvertScale( mask, bim, 1.0/255.0) if im.depth == 8: newim = cv.cvCreateImage( cv.cvSize(im.width, im.height), cv.IPL_DEPTH_32F, im.nChannels ) cv.cvConvertScale( im, newim, 1.0/255.0) print 'newim.depth = ',newim.depth print 'newim.nChannels = ',newim.nChannels print 'bim.depth = ',bim.depth print 'bim.nChannels = ',bim.nChannels if newim.nChannels == 3 and newim.depth == 32 and bim.nChannels == 3 and bim.depth == 32: outputIm = cv.cvCloneImage( bim ) cv.cvMul( bim, newim, outputIm, 1 ) return outputIm else: print 'oops problem with formats' return mask
def mask_image(im, mask): if mask.depth == 8: bim = cv.cvCreateImage(cv.cvSize(mask.width, mask.height), cv.IPL_DEPTH_32F, mask.nChannels) cv.cvConvertScale(mask, bim, 1.0 / 255.0) if im.depth == 8: newim = cv.cvCreateImage(cv.cvSize(im.width, im.height), cv.IPL_DEPTH_32F, im.nChannels) cv.cvConvertScale(im, newim, 1.0 / 255.0) print 'newim.depth = ', newim.depth print 'newim.nChannels = ', newim.nChannels print 'bim.depth = ', bim.depth print 'bim.nChannels = ', bim.nChannels if newim.nChannels == 3 and newim.depth == 32 and bim.nChannels == 3 and bim.depth == 32: outputIm = cv.cvCloneImage(bim) cv.cvMul(bim, newim, outputIm, 1) return outputIm else: print 'oops problem with formats' return mask
# right click on a location to see HSV thresholding result, left click anywhere to return to RGB image import sys sys.path.append('/usr/local/lib64/python2.6/site-packages') import stereo from opencv import highgui,cv if len(sys.argv) >= 2: imgorig = highgui.cvLoadImage(sys.argv[1]) img = cv.cvCloneImage(imgorig) cv.cvCvtColor(img,img,cv.CV_RGB2HSV) size = cv.cvGetSize(img) IMGW = size.width IMGH = size.height fromfile = True else: fromfile = False IMGW = 640 IMGH = 480 cap0 = highgui.cvCreateCameraCapture(0) highgui.cvSetCaptureProperty(cap0, highgui.CV_CAP_PROP_FRAME_WIDTH, IMGW) highgui.cvSetCaptureProperty(cap0, highgui.CV_CAP_PROP_FRAME_HEIGHT, IMGH) joined = cv.cvCreateImage(cv.cvSize(IMGW,IMGH), 8, 3) highgui.cvNamedWindow("Blob") tx = 100 ty = 100
def detect_squares(self, img): """ Find squares within the video stream and draw them """ N = 11 thresh = 5 sz = cv.cvSize(img.width & -2, img.height & -2) timg = cv.cvCloneImage(img) gray = cv.cvCreateImage(sz, 8, 1) pyr = cv.cvCreateImage(cv.cvSize(sz.width / 2, sz.height / 2), 8, 3) # create empty sequence that will contain points - # 4 points per square (the square's vertices) squares = cv.cvCreateSeq(0, cv.sizeof_CvSeq, cv.sizeof_CvPoint, self.storage) squares = cv.CvSeq_CvPoint.cast(squares) # select the maximum ROI in the image # with the width and height divisible by 2 subimage = cv.cvGetSubRect(timg, cv.cvRect(0, 0, sz.width, sz.height)) # down-scale and upscale the image to filter out the noise cv.cvPyrDown(subimage, pyr, 7) cv.cvPyrUp(pyr, subimage, 7) tgray = cv.cvCreateImage(sz, 8, 1) # find squares in every color plane of the image for c in range(3): # extract the c-th color plane channels = [None, None, None] channels[c] = tgray cv.cvSplit(subimage, channels[0], channels[1], channels[2], None) for l in range(N): # hack: use Canny instead of zero threshold level. # Canny helps to catch squares with gradient shading if (l == 0): # apply Canny. Take the upper threshold from slider # and set the lower to 0 (which forces edges merging) cv.cvCanny(tgray, gray, 0, thresh, 5) # dilate canny output to remove potential # holes between edge segments cv.cvDilate(gray, gray, None, 1) else: # apply threshold if l!=0: # tgray(x,y) = gray(x,y) < (l+1)*255/N ? 255 : 0 cv.cvThreshold(tgray, gray, (l + 1) * 255 / N, 255, cv.CV_THRESH_BINARY) # find contours and store them all as a list count, contours = cv.cvFindContours(gray, self.storage, cv.sizeof_CvContour, cv.CV_RETR_LIST, cv.CV_CHAIN_APPROX_SIMPLE, cv.cvPoint(0, 0)) if not contours: continue # test each contour for contour in contours.hrange(): # approximate contour with accuracy proportional # to the contour perimeter result = cv.cvApproxPoly( contour, cv.sizeof_CvContour, self.storage, cv.CV_POLY_APPROX_DP, cv.cvContourPerimeter(contours) * 0.02, 0) # square contours should have 4 vertices after approximation # relatively large area (to filter out noisy contours) # and be convex. # Note: absolute value of an area is used because # area may be positive or negative - in accordance with the # contour orientation if (result.total == 4 and abs(cv.cvContourArea(result)) > 1000 and cv.cvCheckContourConvexity(result)): s = 0 for i in range(5): # find minimum angle between joint # edges (maximum of cosine) if (i >= 2): t = abs( self.squares_angle(result[i], result[i - 2], result[i - 1])) if s < t: s = t # if cosines of all angles are small # (all angles are ~90 degree) then write quandrange # vertices to resultant sequence if (s < 0.3): for i in range(4): squares.append(result[i]) i = 0 while i < squares.total: pt = [] # read 4 vertices pt.append(squares[i]) pt.append(squares[i + 1]) pt.append(squares[i + 2]) pt.append(squares[i + 3]) # draw the square as a closed polyline cv.cvPolyLine(img, [pt], 1, cv.CV_RGB(0, 255, 0), 3, cv.CV_AA, 0) i += 4 return img
if __name__ == '__main__': argc = len(sys.argv) filename = "../c/stuff.jpg" if (argc == 2): filename = sys.argv[1] slider_pos = 70 # load image and force it to be grayscale image03 = highgui.cvLoadImage(filename, 0) if not image03: print "Could not load image " + filename sys.exit(-1) # Create the destination images image02 = cv.cvCloneImage(image03) image04 = cv.cvCloneImage(image03) # Create windows. highgui.cvNamedWindow("Source", 1) highgui.cvNamedWindow("Result", 1) # Show the image. highgui.cvShowImage("Source", image03) # Create toolbars. HighGUI use. highgui.cvCreateTrackbar("Threshold", "Result", slider_pos, 255, process_image) process_image(1)
random.randrange (0, 5) * 0.1, random.randrange (0, 10), line_type) cv.cvPutText (image, "Testing text rendering!", pt1, font, random_color (random)) highgui.cvShowImage (window_name, image) highgui.cvWaitKey (delay) # prepare a text, and get it's properties font = cv.cvInitFont (cv.CV_FONT_HERSHEY_COMPLEX, 3, 3, 0.0, 5, line_type) text_size, ymin = cv.cvGetTextSize ("OpenCV forever!", font) pt1.x = (width - text_size.width) / 2 pt1.y = (height + text_size.height) / 2 image2 = cv.cvCloneImage(image) # now, draw some OpenCV pub ;-) for i in range (255): cv.cvSubS (image2, cv.cvScalarAll (i), image, None) cv.cvPutText (image, "OpenCV forever!", pt1, font, cv.cvScalar (255, i, i)) highgui.cvShowImage (window_name, image) highgui.cvWaitKey (delay) # wait some key to end highgui.cvWaitKey (0)
def on_trackbar1(position): global pos1 global pos2 global pos3 global pos4 global pos5 global pos6 global pos7 global img global gray global edges print print position, pos2, pos3, pos4, pos5, pos6, pos7 temp = cv.cvCloneImage(img) gray = cv.cvCreateImage(cv.cvGetSize(temp), 8, 1) edges = cv.cvCreateImage(cv.cvGetSize(temp), 8, 1) dst = cv.cvCreateImage( cv.cvSize(256,256), 8, 3 ) src = cv.cvCloneImage(img) src2 = cv.cvCreateImage( cv.cvGetSize(src), 8, 3 ); cv.cvCvtColor(img, gray, cv.CV_BGR2GRAY) cv.cvCanny(gray, edges, position, pos2, 3) cv.cvSmooth(edges, edges, cv.CV_GAUSSIAN, 9, 9) storage = cv.cvCreateMat(50, 1, cv.CV_32FC3) cv.cvSetZero(storage) try: circles = cv.cvHoughCircles(gray, storage, cv.CV_HOUGH_GRADIENT, 1, float(pos3), float(pos2), float(pos4), long(pos5),long(pos6) ) #print storage for i in storage: print "Center: ", i[0], i[1], " Radius: ", i[2] center = cv.cvRound(i[0]), cv.cvRound(i[1]) radius = cv.cvRound(i[2]) cv.cvCircle(temp, (center), radius, cv.CV_RGB(255, 0, 0), 1, cv.CV_AA, 0 ) cv.cvCircle(edges, (center), radius, cv.CV_RGB(255, 255, 255), 1, cv.CV_AA, 0 ) if radius > 200: print "Circle found over 200 Radius" center_crop_topleft = (center[0]-(radius - pos7)), (center[1]-(radius - pos7)) center_crop_bottomright = (center[0]+(radius - pos7)), (center[1]+(radius - pos7)) print "crop top left: ", center_crop_topleft print "crop bottom right: ", center_crop_bottomright center_crop = cv.cvGetSubRect(src, (center_crop_topleft[0], center_crop_topleft[1] , (center_crop_bottomright[0] - center_crop_topleft[0]), (center_crop_bottomright[1] - center_crop_topleft[1]) )) #center_crop = cv.cvGetSubRect(src, (50, 50, radius/2, radius/2)) cvShowImage( "center_crop", center_crop ) print "center_crop created" #mark found circle's center with blue point and blue circle of pos 7 radius cv.cvCircle(temp ,(center), 2, cv.CV_RGB(0, 0, 255), 3, cv.CV_AA, 0 ) cv.cvCircle(temp ,(center), (radius - pos7), cv.CV_RGB(0, 0, 255), 3, cv.CV_AA, 0 ) #cvLogPolar(src, dst, (center), 48, CV_INTER_LINEAR +CV_WARP_FILL_OUTLIERS ) #this will draw a smaller cirle outlining the center circle #pos7 = int(pos7 /2.5) #cv.cvCircle(dst ,(img_size.width-pos7, 0), 2, cv.CV_RGB(0, 0, 255), 3, cv.CV_AA, 0 ) #cv.cvLine(dst, (img_size.width-pos7-1, 0), (img_size.width-pos7-1, img_size.height), cv.CV_RGB(0, 0, 255),1,8,0) #cvShowImage( "log-polar", dst ) #print radius, (radius-pos7) #cropped = cv.cvCreateImage( (pos7, img_size.height), 8, 3) #cropped2 = cv.cvCreateImage( (pos7, img_size.height), 8, 3) #coin_edge_img = cv.cvGetSubRect(dst, (img_size.width-pos7, 0, pos7 ,img_size.height )) #to create the center cropped part of coin #img_size = cvGetSize(scr) #cvCopy(coin_edge_img, cropped) #cvSaveImage("temp.png", cropped) #im = Image.open("temp.png").rotate(90) #print "pil image size = ", im.size[0], im.size[1] #im = im.resize((im.size[0]*2, im.size[1]*2)) #print "pil image size = ", im.size #im.show() #im.save("temp2.png") cropped2 = highgui.cvLoadImage("temp2.png") #cvShowImage( "cropped", cropped2) except: print "Exception:", sys.exc_info()[0] print position, pos2, pos3, pos4, pos5, pos6, pos7 pass highgui.cvShowImage("edges", edges) #cvShowImage( "log-polar", dst ) cvShowImage(wname, temp)
def atualizeVar(self, frameA, frameB, frameC, capture): frameA = cvCloneImage(frameB) frameB = cvCloneImage(frameC) frameC = cvQueryFrame(capture) return frameA, frameB, frameC
if __name__ == '__main__': argc = len(sys.argv) filename = "../c/stuff.jpg" if(argc == 2): filename = sys.argv[1] slider_pos = 70 # load image and force it to be grayscale image03 = highgui.cvLoadImage(filename, 0) if not image03: print "Could not load image " + filename sys.exit(-1) # Create the destination images image02 = cv.cvCloneImage( image03 ); image04 = cv.cvCloneImage( image03 ); # Create windows. highgui.cvNamedWindow("Source", 1); highgui.cvNamedWindow("Result", 1); # Show the image. highgui.cvShowImage("Source", image03); # Create toolbars. HighGUI use. highgui.cvCreateTrackbar( "Threshold", "Result", slider_pos, 255, process_image ); process_image( 1 );
break ################ traitement de l'image ################ cv.cvCvtColor(frame, frameGray, cv.CV_BGR2GRAY) # niveau de gris cv.cvSub(frameGray, frameGrayBg, framewithoutbg) # soustraction du background cv.cvMul(framewithoutbg, framewithoutbg, framemul, get_gain()) # amplification cv.cvSmooth(framemul, framelisser1, cv.CV_BLUR, param_liss[0], param2_liss[0]) # lissage if first == 0: # "moyenne" sur deux image cv.cvAnd(framelisser1, framelisser2, framelisser) if first == 1: framelisser = cv.cvCloneImage(framelisser1) framelisser2 = cv.cvCloneImage(framelisser1) cv.cvThreshold(framelisser, frameBin, get_seuil(), float(255), cv.CV_THRESH_BINARY) # binaristaion de l image ################ run detection ################ zone_active = zoneActivePremier(zone_active, frameBin) if len(zone_active) == 0: centrePointeur = [] info_size = [] if len(zone_active) != 0: for i in range(1, nb_div_zone[0] + 1): zone_active = zoneActive(zone_active, frameBin, i) pointeur = pointeurPrecision(zone_active, frameBin)
random.randrange (0, 100) * 0.05 + 0.01, random.randrange (0, 5) * 0.1, random.randrange (0, 10), line_type) cv.cvPutText (image, "Testing text rendering!", pt1, font, random_color (random)) highgui.cvShowImage (window_name, image) highgui.cvWaitKey (delay) # prepare a text, and get it's properties font = cv.cvInitFont (cv.CV_FONT_HERSHEY_COMPLEX, 3, 3, 0.0, 5, line_type) text_size, ymin = cv.cvGetTextSize ("OpenCV forever!", font) pt1.x = (width - text_size.width) / 2 pt1.y = (height + text_size.height) / 2 image2 = cv.cvCloneImage(image) # now, draw some OpenCV pub ;-) for i in range (255): cv.cvSubS (image2, cv.cvScalarAll (i), image, None) cv.cvPutText (image, "OpenCV forever!", pt1, font, cv.cvScalar (255, i, i)) highgui.cvShowImage (window_name, image) highgui.cvWaitKey (delay) # wait some key to end highgui.cvWaitKey (0)
def main(): print "OpenCV version: %s (%d, %d, %d)" % (cv.CV_VERSION, cv.CV_MAJOR_VERSION, cv.CV_MINOR_VERSION, cv.CV_SUBMINOR_VERSION) # create windows create_and_position_window('Thresholded_HSV_Image', 10, 10) create_and_position_window('RGB_VideoFrame', 10+cam_width, 10) create_and_position_window('Hue', 10, 10+cam_height) create_and_position_window('Saturation', 210, 10+cam_height) create_and_position_window('Value', 410, 10+cam_height) create_and_position_window('LaserPointer', 0,0) capture = setup_camera_capture() # create images for the different channels h_img = cv.cvCreateImage (cv.cvSize (cam_width,cam_height), 8, 1) s_img = cv.cvCreateImage (cv.cvSize (cam_width,cam_height), 8, 1) v_img = cv.cvCreateImage (cv.cvSize (cam_width,cam_height), 8, 1) laser_img = cv.cvCreateImage (cv.cvSize (cam_width,cam_height), 8, 1) cv.cvSetZero(h_img) cv.cvSetZero(s_img) cv.cvSetZero(v_img) cv.cvSetZero(laser_img) while True: # 1. capture the current image frame = highgui.cvQueryFrame (capture) if frame is None: # no image captured... end the processing break hsv_image = cv.cvCloneImage(frame) # temporary copy of the frame cv.cvCvtColor(frame, hsv_image, cv.CV_BGR2HSV) # convert to HSV # split the video frame into color channels cv.cvSplit(hsv_image, h_img, s_img, v_img, None) # Threshold ranges of HSV components. cv.cvInRangeS(h_img, hmin, hmax, h_img) cv.cvInRangeS(s_img, smin, smax, s_img) cv.cvInRangeS(v_img, vmin, vmax, v_img) # Perform an AND on HSV components to identify the laser! cv.cvAnd(h_img, v_img, laser_img) # This actually Worked OK for me without using Saturation. #cv.cvAnd(laser_img, s_img,laser_img) # Merge the HSV components back together. cv.cvMerge(h_img, s_img, v_img, None, hsv_image) #----------------------------------------------------- # NOTE: default color space in OpenCV is BGR!! # we can now display the images highgui.cvShowImage ('Thresholded_HSV_Image', hsv_image) highgui.cvShowImage ('RGB_VideoFrame', frame) highgui.cvShowImage ('Hue', h_img) highgui.cvShowImage ('Saturation', s_img) highgui.cvShowImage ('Value', v_img) highgui.cvShowImage('LaserPointer', laser_img) # handle events k = highgui.cvWaitKey (10) if k == '\x1b' or k == 'q': # user has press the ESC key, so exit break
def detect_squares(self, img_grey, img_orig): """ Find squares within the video stream and draw them """ cv.cvClearMemStorage(self.faces_storage) N = 11 thresh = 5 sz = cv.cvSize(img_grey.width & -2, img_grey.height & -2) timg = cv.cvCloneImage(img_orig) pyr = cv.cvCreateImage(cv.cvSize(sz.width/2, sz.height/2), 8, 3) # create empty sequence that will contain points - # 4 points per square (the square's vertices) squares = cv.cvCreateSeq(0, cv.sizeof_CvSeq, cv.sizeof_CvPoint, self.squares_storage) squares = cv.CvSeq_CvPoint.cast(squares) # select the maximum ROI in the image # with the width and height divisible by 2 subimage = cv.cvGetSubRect(timg, cv.cvRect(0, 0, sz.width, sz.height)) cv.cvReleaseImage(timg) # down-scale and upscale the image to filter out the noise cv.cvPyrDown(subimage, pyr, 7) cv.cvPyrUp(pyr, subimage, 7) cv.cvReleaseImage(pyr) tgrey = cv.cvCreateImage(sz, 8, 1) # find squares in every color plane of the image for c in range(3): # extract the c-th color plane channels = [None, None, None] channels[c] = tgrey cv.cvSplit(subimage, channels[0], channels[1], channels[2], None) for l in range(N): # hack: use Canny instead of zero threshold level. # Canny helps to catch squares with gradient shading if(l == 0): # apply Canny. Take the upper threshold from slider # and set the lower to 0 (which forces edges merging) cv.cvCanny(tgrey, img_grey, 0, thresh, 5) # dilate canny output to remove potential # holes between edge segments cv.cvDilate(img_grey, img_grey, None, 1) else: # apply threshold if l!=0: # tgray(x,y) = gray(x,y) < (l+1)*255/N ? 255 : 0 cv.cvThreshold(tgrey, img_grey, (l+1)*255/N, 255, cv.CV_THRESH_BINARY) # find contours and store them all as a list count, contours = cv.cvFindContours(img_grey, self.squares_storage, cv.sizeof_CvContour, cv.CV_RETR_LIST, cv.CV_CHAIN_APPROX_SIMPLE, cv.cvPoint(0,0)) if not contours: continue # test each contour for contour in contours.hrange(): # approximate contour with accuracy proportional # to the contour perimeter result = cv.cvApproxPoly(contour, cv.sizeof_CvContour, self.squares_storage, cv.CV_POLY_APPROX_DP, cv.cvContourPerimeter(contours)*0.02, 0) # square contours should have 4 vertices after approximation # relatively large area (to filter out noisy contours) # and be convex. # Note: absolute value of an area is used because # area may be positive or negative - in accordance with the # contour orientation if(result.total == 4 and abs(cv.cvContourArea(result)) > 1000 and cv.cvCheckContourConvexity(result)): s = 0 for i in range(5): # find minimum angle between joint # edges (maximum of cosine) if(i >= 2): t = abs(self.squares_angle(result[i], result[i-2], result[i-1])) if s<t: s = t # if cosines of all angles are small # (all angles are ~90 degree) then write quandrange # vertices to resultant sequence if(s < 0.3): for i in range(4): squares.append(result[i]) cv.cvReleaseImage(tgrey) return squares
def clone_image(self,image): return cv.cvCloneImage(image)
highgui.cvCreateTrackbar("Canny2", wname, 175, 250, on_trackbar2) highgui.cvCreateTrackbar("minDistance", wname, 40, 150, on_trackbar3) highgui.cvCreateTrackbar("accumThresh", wname, 55, 100, on_trackbar4) highgui.cvCreateTrackbar("minRadius", wname, 190, 500, on_trackbar5) highgui.cvCreateTrackbar("maxRadius", wname, 210, 1200, on_trackbar6) highgui.cvCreateTrackbar("SearchRadius", wname, 50, 100, on_trackbar7) pos1 = highgui.cvGetTrackbarPos("Canny1", wname) pos2 = highgui.cvGetTrackbarPos("Canny2", wname) pos3 = highgui.cvGetTrackbarPos("minDistance", wname) pos4 = highgui.cvGetTrackbarPos("accumThresh", wname) pos5 = highgui.cvGetTrackbarPos("minRadius", wname) pos6 = highgui.cvGetTrackbarPos("maxRadius", wname) pos7 = highgui.cvGetTrackbarPos("SearchRadius", wname) pos1 = int(pos2/2) highgui.cvSetTrackbarPos("Canny1", wname, pos1) on_trackbar1(pos1) #highgui.cvNamedWindow( "original",1 ); #highgui.cvNamedWindow( "log-polar", 1 ); #highgui.cvNamedWindow( "inverse log-polar", 1 ); dst = cv.cvCreateImage( cv.cvSize(256,256), 8, 3 ); src = cv.cvCloneImage(img) src2 = cv.cvCreateImage( cv.cvGetSize(src), 8, 3 ); #cvShowImage( "original", src ); highgui.cvSetMouseCallback( "original", on_mouse ); on_mouse( CV_EVENT_LBUTTONDOWN, src.width/2, src.height/2, None, None) highgui.cvWaitKey()