def establecer_colores(imagen): global pixel_rojo, pixel_azul, pixel_verde,color, teclado if (teclado == 1 or teclado == 2): nombre_color = 'Seleccionar una de las Pelotas' colors(imagen, nombre_color) pixel_rojo = color cv.DestroyWindow('Seleccionar una de las Pelotas') nombre_color = 'Seleccionar la marca central del robot' colors(imagen, nombre_color) pixel_verde = color cv.DestroyWindow('Seleccionar la marca central del robot') nombre_color = 'Seleccionar la marca frontal del robot' colors(imagen, nombre_color) pixel_azul = color cv.DestroyWindow('Seleccionar la marca frontal del robot') cv.DestroyWindow('Seleccionando pixeles') guardarcolores(pixel_rojo, pixel_verde, pixel_azul) elif (teclado == 3 or teclado == 4): pixel_rojo, pixel_verde, pixel_azul = cargarcolores()
def show_images(images): """ Shows all images in a window""" if images == None: logging.error('Cannot Show Images (No image saved). Image-Type: %s (tools.py)' % str(type(images).__name__)) elif type(images).__name__=='list': for i in range(len(images)): print type(images[i]) if type(images[i]).__name__=='ndarray': tmpimage = [] tmpimage[i] = array2cv(images[i]) cv.ShowImage("Image", tmpimage[i]) if cv.WaitKey() == 27: cv.DestroyWindow("Image") else: cv.ShowImage("Image", images[i]) if cv.WaitKey() == 27: cv.DestroyWindow("Image") elif type(images).__name__=='cvmat': cv.ShowImage("Image", images) if cv.WaitKey() == 27: cv.DestroyWindow("Image") elif type(images).__name__=='iplimage': cv.ShowImage("Image", images) if cv.WaitKey() == 27: cv.DestroyWindow("Image") elif type(images).__name__=='ndarray': images = array2cv(images) cv.ShowImage("Image", images) if cv.WaitKey() == 27: cv.DestroyWindow("test") elif type(images).__name__=='str': logging.error('TypeError: Cannot Show Images (No image saved?). Image-Type: %s (tools.py)' % str(type(images).__name__)) else: logging.error('TypeError: Cannot Show Images. Image-Type: %s (tools.py)' % str(type(images).__name__))
def handleEvents(self, event, x, y, flags, param): (x, y) = self.snap((x, y)) if event == cv.CV_EVENT_LBUTTONUP: self.pts.append((x, y)) self.t.append(True) self.highlight((x, y), True) self.showImage() if len(self.pts) >= self.num_pts: self.writeAnno() cv.DestroyWindow("Annotator") self.open = False elif event == cv.CV_EVENT_RBUTTONUP: if len(self.pts) > 0: self.pts = self.pts[0:len(self.pts) - 1] self.t = self.t[0:len(self.t) - 1] self.clearImage() for i, pt in enumerate(self.pts): self.highlight(pt, self.t[i]) self.showImage() elif event == cv.CV_EVENT_MBUTTONUP: self.pts.append((x, y)) self.t.append(False) self.highlight((x, y), False) self.showImage() if len(self.pts) >= self.num_pts: self.writeAnno() cv.DestroyWindow("Annotator") self.open = False else: self.temp_highlight((x, y), False)
def on_mouse(event, x, y, flag, param): global usercount global demo_mode global saved_list if (event == cv.CV_EVENT_LBUTTONDOWN): #print x,y # runCapture = False # print imagefile + str(param) + '.jpg' if not demo_mode: apenom = get_guest("Introduzca nombre") else: apenom = "" if demo_mode or apenom: usercount = usercount + 1 user_id = user_id_base + str(usercount) if apenom: os.rename(imagefile + str(param) + '.jpg', user_id + '.jpg') with open(user_id + ".jpg", "rb") as handle: binary_data = xmlrpclib.Binary(handle.read()) handle.close() if server.put_file(USERNAME, PASSWORD, datastore_space, user_id + '.jpg', binary_data): #print "foto subida" #put in database try: # connect db = MySQLdb.connect(host=dbhost, user=dbuser, passwd=dbpass, db=dbname) cur = db.cursor() # try: cur.execute( "INSERT INTO fotos_jornadas (foto, user_id, nombre_comp) VALUES ('%s', '%s', '%s');" % (user_id + ".jpg", user_id, apenom)) db.commit() # except: # # Rollback in case there is any error # db.rollback() cur.close() db.close() info_dialog("Foto de " + apenom + " grabada correctamente") saved_list.append(user_id) except: #print dbhost+ " - "+ dbuser + " - "+ dbpass + " - "+ dbname error_dialog("Error grabando foto") else: error_dialog("Error mandando foto") else: os.rename(imagefile + str(param) + '.jpg', user_id + '.jpg') info_dialog("Foto Seleccionada") cv.DestroyWindow('crop' + str(param)) elif (event == cv.CV_EVENT_RBUTTONDOWN): cv.DestroyWindow('crop' + str(param))
def establecer_colores(imagen): global pixel_rojo, teclado nombre_color = 'Seleccionar Rojo' colors(imagen, nombre_color) pixel_rojo = color cv.DestroyWindow('Seleccionar Rojo') cv.DestroyWindow('Seleccionando pixeles') guardarcolores(pixel_rojo) pixel_rojo = cargarcolores()
def play_video(path, name, posmsec=0, fps=0): capture = cv.CaptureFromFile(path) if fps <= 0: fps = cv.GetCaptureProperty(capture, cv.CV_CAP_PROP_FPS) interval = int(1000.0 / fps) cv.SetCaptureProperty(capture, cv.CV_CAP_PROP_POS_MSEC, posmsec) playing = [True] cv.NamedWindow(name) def on_mouse(event, x, y, flags, param): if event == cv.CV_EVENT_RBUTTONDOWN: playing[0] = False cv.SetMouseCallback(name, on_mouse) while playing[0]: frame = cv.QueryFrame(capture) if frame is None: playing[0] = False else: cv.ShowImage(name, frame) cv.WaitKey(interval) cv.DestroyWindow(name) del capture
def get_tracked_region(im): tr = TrackedRegion(im) cv.NamedWindow("reference") cv.CreateTrackbar('xpos', 'reference', 0, im.width - 1, tr.set_x) cv.CreateTrackbar('ypos', 'reference', 0, im.height - 1, tr.set_y) cv.CreateTrackbar('size', 'reference', 0, im.width - 1, tr.set_size) # Show position of descriptors on reference image cv.ShowImage("reference", im) # Selecting tracked region while True: key_pressed = cv.WaitKey(100) if key_pressed == 32: cv.Rectangle(im, (tr.xpos, tr.ypos), (tr.xpos + tr.size, tr.ypos + tr.size), 255, thickness=3) cv.DestroyWindow("reference") break elif key_pressed == 27: cv.DestroyAllWindows() cv.WaitKey(100) return else: im_copy = cv.CreateMat(im.height, im.width, cv.CV_8UC1) cv.Copy(im, im_copy) cv.Rectangle(im_copy, (tr.xpos, tr.ypos), (tr.xpos + tr.size, tr.ypos + tr.size), 255, thickness=3) cv.ShowImage("reference", im_copy) return tr
def MouseCalibrate(image, markers): windowName = "Choose Point" cv2.namedWindow(windowName) gotPoint = [False] * len(markers) ind = [0] pt = [0, 0] def mouseback(event, x, y, flags, param): if event == cv.CV_EVENT_LBUTTONUP: # here event is left mouse button double-clicked print x, y pt[0] = x pt[1] = y gotPoint[ind[0]] = True cv.SetMouseCallback(windowName, mouseback) for i in range(0, len(markers)): #redisplay image and title cv2.imshow(windowName, image) ind[0] = i #ask for pt while not gotPoint[ind[0]]: ret, calibImage = calibCap.retrieve() cv2.imshow(windowName, calibImage) cv.WaitKey(1) #add point to matrix markers[i].pos = [pt[0], pt[1]] cv.DestroyWindow(windowName)
def main(): global startframe tree = utils.open_project(sys.argv) if tree == None: return os.chdir("shot_slitscans") '''cv.NamedWindow("win", cv.CV_WINDOW_AUTOSIZE) cv.MoveWindow("win", 500, 200) cv.SetMouseCallback("win", mouse_callback)''' bg_img = cv.CreateImage((576, 576), cv.IPL_DEPTH_8U, 1) #cv.Set(bg_img, (180)) files = sorted(glob.glob("*.png")) print(files) i = 0 while i < len(files): file = files[i] startframe = int(file.split("_")[3].split(".")[0]) print(startframe) cap = cv.CreateFileCapture(file) img = cv.QueryFrame(cap) win_name = "%d" % (int( float(i + 1) * 100.0 / len(files))) + "% - " + file cv.NamedWindow(win_name, cv.CV_WINDOW_AUTOSIZE) cv.MoveWindow(win_name, 500, 200) cv.SetMouseCallback(win_name, mouse_callback) cv.ShowImage(win_name, bg_img) cv.ShowImage(win_name, img) key = cv.WaitKey(0) print(key) if key in [2555904, 1113939]: # right arrow i += 1 elif key in [2424832, 1113937]: # left arrow i -= 1 if i < 0: i = 0 elif key in [27, 1048603]: # ESC break elif key in [1113941]: # page up i -= 100 if i < 0: i = 0 elif key in [1113942]: # page down i += 100 else: print("Unknown key code: {}".format(key)) cv.DestroyWindow(win_name) src_dir = os.path.dirname(sys.argv[0]) os.chdir(src_dir) os.system("python 02_2_save-shots.py \"" + sys.argv[1] + "\"")
def mouse_callback(self, event, x, y, flags, param): if event == cv.CV_EVENT_LBUTTONDOWN: bgra = cv.Get2D(self.image, y, x) # hsv = cv.Get2D(self.hsv, y, x) # bgrhsv = bgra[:-1] + hsv[:-1] print "coords: (", x, ",", y, ")" print "bgra:", bgra blue = int(bgra[0]) green = int(bgra[1]) red = int(bgra[2]) # hue = int(bgrhsv[3]) # sat = int(bgrhsv[4]) # val = int(bgrhsv[5]) self.RGBvals.append((red, green, blue)) # self.HSVvals.append((hue,sat,val)) if len(self.RGBavgs) > 0: print self.RGBavgs print red, green, blue self.RGBavgs = ((self.RGBavgs[0] + red) / 2, (self.RGBavgs[1] + green) / 2, (self.RGBavgs[2] + blue) / 2) # self.HSVavgs = ((self.HSVavgs[0] + hue)/2, # (self.HSVavgs[1] + sat)/2, # (self.HSVavgs[2] + val)/2) else: self.RGBavgs = (red, green, blue) # self.HSVavgs = (hue, sat, val) print "RGBavgs:", self.RGBavgs print "RGBvals:", self.RGBvals # print "HSVavgs:", self.HSVavgs # print "HSVvals:", self.HSVvals rgbwindow = 50 # half the size of the window we want for thresholds # hsvwindow = 200 self.thresholds['low_red'] = self.RGBavgs[0] - rgbwindow self.thresholds['high_red'] = self.RGBavgs[0] + rgbwindow self.thresholds['low_green'] = self.RGBavgs[1] - rgbwindow self.thresholds['high_green'] = self.RGBavgs[1] + rgbwindow self.thresholds['low_blue'] = self.RGBavgs[2] - rgbwindow self.thresholds['high_blue'] = self.RGBavgs[2] + rgbwindow # self.thresholds['low_hue'] = self.HSVavgs[0] - hsvwindow # self.thresholds['high_hue'] = self.HSVavgs[0] + hsvwindow # self.thresholds['low_sat'] = self.HSVavgs[1] - hsvwindow # self.thresholds['high_sat'] = self.HSVavgs[1] + hsvwindow # self.thresholds['low_val'] = self.HSVavgs[2] - hsvwindow # self.thresholds['high_val'] = self.HSVavgs[2] + hsvwindow #Recreate the slider window cv.DestroyWindow('sliders') self.make_slider_window()
def displayMovie(self, title="Movie", delay=0.01): cv.NamedWindow(title) for image in self._images: cv.ShowImage(title, image) cv.WaitKey() # TODO: FIXME time.sleep(delay) cv.DestroyWindow(title)
def main(): while True: cv.NamedWindow('a_window', cv.CV_WINDOW_AUTOSIZE) #logfiles = sorted([ f for f in os.listdir(report_dirName) if f.startswith('image')]) #logfiles=GetLatestArchive('image*.jpg') latest_folder = report_dirName + latest_file(name_start='Z', name_end='') + '\\' image = cv.LoadImage( latest_folder + latest_file(path=latest_folder, name_start='Z', name_end='.tif'), cv.CV_LOAD_IMAGE_COLOR) # .jpg images are 4x times smaller #img = cv2.imread(latest_folder+latest_file(path=latest_folder, name_start='', name_end='.tif')) #gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) #img2=cv2.equalizeHist(gray) #cvmat_img2=cv.fromarray(img2) font = cv.InitFont(cv.CV_FONT_HERSHEY_SIMPLEX, 1, 1, 0, 3, 8) newFrameImage8U = cv.CreateImage((image.width, image.height), cv.IPL_DEPTH_8U, 3) # optional convert to 8U cv.ConvertScale(image, newFrameImage8U) # optional image = newFrameImage8U # optional cv.PutText(image, "Counter:", (x, y), font, 255) #Draw the text #cv.PutText(cvmat_img2,"Counter:", (x,y),font, 255) cv.ShowImage('a_window', image) #Show the image #cv.Waitkey(10000) # open the latest xml-file in this folder and get the stage coordinates (x,y,z) (stage_x, stage_y, stage_z) = return_xyz_coordinates( latest_folder + latest_file(path=latest_folder, name_start='', name_end='.xml')) print 'stage coordinates x,y,z:', stage_x, stage_y, stage_z if cv.WaitKey(10) == 27: break cv.DestroyWindow("a_window")
def VideoStream(): """ VideoStream should probably be updated to utilized the cv2 python wrapper for opencv If you're having problems, remember to check the camera index, fps """ global Finished #display live video cv.NamedWindow("Badass video window", cv.CV_WINDOW_AUTOSIZE) #peripheral devices begin at > 0 global camera_index capture = cv.CaptureFromCAM(camera_index) frame = cv.QueryFrame(capture) writer = cv.CreateVideoWriter( "Stream.avi", 0, 20, cv.GetSize(frame), 1) #"filename", codec,fps, frame_size, is_color=true #isight can't handle 30 fps so changed it to 15 print "Calling thread at: ", time.time() Thread(target=AudioStream).start() i = 1 while True: print "Recording Video Frame: ", i, " At: ", time.time() frame = cv.QueryFrame(capture) cv.WriteFrame(writer, frame) cv.ShowImage("Badass video window", frame) k = cv.WaitKey(10) #milliseconds i += 1 if k == 0x1b: #ESC print 'ESC pressed. Exiting ... Time is: ', time.time() break Finished = True cv.DestroyWindow("Baddass video window") sys.exit(1) return
def display_single_image(img, name="Image", x_pos=0, y_pos=0, delay=0): """ Displays an image on screen. Position can be chosen, and time on screen too. Delay corresponds to the display time, in milliseconds. If delay =0, the Image stays on screen until user interaction. ---- Ex: img = cv.LoadImage("../data/tippy.jpg", cv.CV_LOAD_IMAGE_GRAYSCALE) display_single_image(img, "My Tippy", 0, 0, 100) """ #TODO: Still not implemented! if not isinstance(name, str): raise TypeError("(%s) Name :String expected!" % (sys._getframe().f_code.co_name)) if (not isinstance(x_pos, int)) \ or (not isinstance(x_pos, int)) \ or (not isinstance(x_pos, int)) : raise TypeError("(%s) Int expected!" % (sys._getframe().f_code.co_name)) cv.StartWindowThread() cv.NamedWindow(name) cv.MoveWindow(name, x_pos, y_pos) cv.ShowImage(name, img) cv.WaitKey(delay) cv.DestroyWindow(name)
def show(**images): for name, im in images.iteritems(): cv.NamedWindow(name) cv.ShowImage(name, im) cv.WaitKey(0) for name in images.keys(): cv.DestroyWindow(name)
def fit_ellipse_dynamic (filename, intensity): source_image = cv.LoadImage(filename, cv.CV_LOAD_IMAGE_COLOR) # Create windows. cv.NamedWindow("Source", 1) cv.NamedWindow("Result", 1) # Show the image. cv.ShowImage("Source", source_image) fe = FitEllipse(source_image, 70, intensity) print "Press any key to exit" cv.WaitKey(0) cv.DestroyWindow("Source") cv.DestroyWindow("Result")
def continually_update(self): while(not self.isClosed()): self.update() time.sleep(0.01) cv.WaitKey(100) cv.DestroyWindow(self.name) for i in range(10): cv.WaitKey(1) return
def quick_show(image): """Display an image on the screen. Quick 'n' dirty method to throw up a window with an image in it and wait for the user to dismiss it. """ cv.NamedWindow("foo") cv.ShowImage("foo", image) cv.WaitKey(0) cv.DestroyWindow("foo")
def toggle_detector_window(value): global detector_window #window is opened and has to be closed if detector_window == 1 and value == 0: cv.DestroyWindow('Detector') detector_window = 0 elif detector_window == 0 and value == 1: cv.NamedWindow('Detector') detector_window = 1
def __init__(self): self.valid_template='no' while self.valid_template !='yes': self.template=self.getTemplate(400,400,100,100) cv.ShowImage("template",self.template) self.valid_template=raw_input("Is the template acceptable?") cv.DestroyWindow("template") print self.valid_template self.matching(self.template,90)
def exit_nicely(): try: cv.DestroyWindow("camera") except Exception: pass try: pygame.quit() except Exception: pass exit(0)
def establecer_colores(imagen): global pixel_rojo, pixel_azul, pixel_verde,color, teclado nombre_color = 'Seleccionar Rojo' colors(imagen, nombre_color) pixel_rojo = color cv.DestroyWindow('Seleccionar Rojo') nombre_color = 'Seleccionar Verde' colors(imagen, nombre_color) pixel_verde = color cv.DestroyWindow('Seleccionar Verde') nombre_color = 'Seleccionar Azul' colors(imagen, nombre_color) pixel_azul = color cv.DestroyWindow('Seleccionar Azul') cv.DestroyWindow('Seleccionando pixeles') guardarcolores(pixel_rojo, pixel_verde, pixel_azul) pixel_rojo, pixel_verde, pixel_azul = cargarcolores()
def process(self, cv_image, info, image2=None): self.clicked = False self.name = "ClickNode" cv.NamedWindow(self.name) cv.ShowImage(self.name, cv_image) cv.SetMouseCallback(self.name, self.onMouse, 0) while not self.clicked: cv.WaitKey(5) cv.WaitKey(10) cv.DestroyWindow(self.name) for i in range(10): cv.WaitKey(1) return ([self.point], {}, cv_image)
def show_stream(name, wait=10): cv.NamedWindow(name) while True: image = yield if image: #TODO: check for StopIteration cv.ShowImage(name, image) cv.WaitKey(wait) else: cv.WaitKey(0) cv.DestroyWindow(name) yield StopIteration
def myVideo(url): flag = 0 #flag for checking if the file in present in the memory. search_folder = "." videoFile = url.split('/')[-1].split('#')[0].split('?')[ 0] #stripping the name of the file. for root, dirs, files in os.walk( search_folder): # using the os.walk module to find the files. for name in files: """Checking the videofile in the current directory and the sub-directories""" if videoFile == os.path.join( name ): #checking if the file is already present in the internal memory.(Traverse through subdirectories as well) flag += 1 print "The file is already present in the internal memory" return -1 # Returning the confirmation that the file is present. if flag == 0: # dowiloding only when the flag is zero(i.e the file is not in the internal memory.) print "Downloading the file" video = urllib.FancyURLopener() #downloading the file using urllib. video.retrieve(url, videoFile) curDir = os.getcwd() # getting the current working directory. fullVideoPath = os.path.join( curDir, videoFile) # Making the full path of the video file. """For playing the file using openCV first read the file. Find the number of frames and the frame rate. Finally use these parameters to display each extracted frame on the screen""" vidFile = cv.CaptureFromFile( fullVideoPath) #Video capturing from the file. nFrames = int( cv.GetCaptureProperty( vidFile, cv.CV_CAP_PROP_FRAME_COUNT)) #Number of frames in the video. fps = cv.GetCaptureProperty(vidFile, cv.CV_CAP_PROP_FPS) # Frame rate waitPerFrame = int(1 / fps * 1000 / 1) # Wait time between frames. for f in xrange(nFrames): frameImg = cv.QueryFrame( vidFile) # decoding and returning the grabbed video frame. cv2.namedWindow( "EPIC", cv2.WND_PROP_FULLSCREEN) #Making full size display. cv2.setWindowProperty( 'EPIC', cv2.WND_PROP_FULLSCREEN, cv2.cv.CV_WINDOW_FULLSCREEN ) # setting the window property to full screen. cv.ShowImage("EPIC", frameImg) # Showing the frame Image cv.WaitKey(waitPerFrame) # Waiting between the frames. cv.DestroyWindow( "EPIC") # Deleting the window once the playing is done. return 1 # The file is successfully played.
def toggle_threshold_window(value): global threshold_window #window is opened and has to be closed if threshold_window == 1 and value == 0: cv.DestroyWindow('Threshold') threshold_window = 0 elif threshold_window == 0 and value == 1: cv.NamedWindow('Threshold') cv.CreateTrackbar('threshold', 'Threshold', threshold, 500, change_threshold) cv.CreateTrackbar('depth', 'Threshold', current_depth, 2048, change_depth) threshold_window = 1
def Color_callibration(capture): vals = [] bgr = [] mini = [255, 255, 255] maxi = [0, 0, 0] cv.NamedWindow("BGR", 0) print 'Please Put Your color in the circular area.Press ESC to start callibration:' while 1: image = cv.QueryFrame(capture) cv.Flip(image, image, 1) cv.Circle(image, (int(200), int(300)), 20, cv.CV_RGB(255, 255, 255), 6) cv.ShowImage("BGR", image) c = cv.WaitKey(33) if c == 27: break for i in range(0, 10): image = cv.QueryFrame(capture) cv.Flip(image, image, 1) cv.Smooth(image, image, cv.CV_GAUSSIAN, 3, 0) imagehsv = cv.CreateImage(cv.GetSize(image), 8, 3) cv.CvtColor(image, imagehsv, cv.CV_BGR2HSV) vals = cv.Get2D(imagehsv, 300, 200) print 'blue:', vals[0], 'green:', vals[1], 'red:', vals[2] for j in range(0, 3): if (vals[j] < mini[j]): mini[j] = vals[j] if (vals[j] > maxi[j]): maxi[j] = vals[j] cv.Circle(image, (int(200), int(300)), 20, cv.CV_RGB(255, 255, 255), 6) cv.ShowImage("BGR", image) c = cv.WaitKey(33) if c == 27: break mini[0] -= 10 mini[1] -= 20 mini[2] -= 50 maxi[0] += 10 maxi[1] += 20 maxi[2] += 50 for i in range(0, 3): if (mini[i] < 0): mini[i] = 0 if (maxi[i] > 255): maxi[i] = 255 cv.DestroyWindow("BGR") print mini print maxi bgr = (mini, maxi) return bgr
def main(): global startframe os.chdir(sys.argv[1]) os.chdir("shot_slitscans") '''cv.NamedWindow("win", cv.CV_WINDOW_AUTOSIZE) cv.MoveWindow("win", 500, 200) cv.SetMouseCallback("win", mouse_callback)''' bg_img = cv.CreateImage((576, 576), cv.IPL_DEPTH_8U, 1) #cv.Set(bg_img, (180)) files = sorted(glob.glob("*.png")) i = 0 while i < len(files): file = files[i] startframe = int(file.split("_")[3].split(".")[0]) print startframe cap = cv.CreateFileCapture(file) img = cv.QueryFrame(cap) win_name = "%d" % (int( float(i + 1) * 100.0 / len(files))) + "% - " + file cv.NamedWindow(win_name, cv.CV_WINDOW_AUTOSIZE) cv.MoveWindow(win_name, 500, 200) cv.SetMouseCallback(win_name, mouse_callback) cv.ShowImage(win_name, bg_img) cv.ShowImage(win_name, img) key = cv.WaitKey(0) if key == 2555904: # right arrow i += 1 elif key == 2424832: # left arrow i -= 1 if i < 0: i = 0 elif key == 27: # ESC break cv.DestroyWindow(win_name) os.chdir("../../..") os.system("python 02_2_save-shots.py \"" + sys.argv[1] + "\"")
def takeaphoto(self): camcapture = cv.CaptureFromCAM(-1) cv.NamedWindow("FotografCek", 1) cv.SetMouseCallback("FotografCek", self.mouseEventp) while True: frame = cv.QueryFrame(camcapture) cv.ShowImage("FotografCek", frame) k = cv.WaitKey(5) if k % 256 == 10 or self.cwMouseLeft == 1: if frame: cv.SaveImage("uye.jpeg", frame) self.statusBar().showMessage(u"Fotoğraf Çekildi") self.cropandresizephoto() break if k % 256 == 27 or self.cwMouseRight == 1: break cv.DestroyWindow("FotografCek") self.cwMouseLeft = 0 self.cwMouseRight = 0
def show_faces(self, mytime=1000): """ Show all faces that have been found for the guys. The time for which each image will be displayed can be chosen. :param mytime: time for which the image should be displayed (in ms) (1000) :type mytime: int """ win_name = " Face Results" cv.NamedWindow(win_name, cv.CV_WINDOW_NORMAL) cv.ResizeWindow(win_name, 640, 480) for a_guy in self.guys: if self.run: out_im = self.prepare_image(a_guy) cv.ShowImage(win_name, out_im) cv.WaitKey(mytime) cv.DestroyWindow(win_name)