def update_frame_big(self):

        self.grabResult = self.camera.RetrieveResult(
            5000, pylon.TimeoutHandling_ThrowException)

        if self.grabResult.GrabSucceeded():
            # Access the image data
            self.img = self.converter_RGB.Convert(self.grabResult)
            self.image = self.img.GetArray()

            # Find distance between target and needle position
            try:
                fdist = fd.FindingDistance(self.image)
                distance = fdist.real_distance
                # send out distance values to control thread
                # self.count_for_done += 1
                self.dist_signal.emit(distance)
                if self.count_for_done < self.TargetAmount_int - 1:
                    self.dist_signal.emit(distance)
                    print()
                    print("count: ", self.count_for_done)
                    print()

                else:
                    self.dist_signal.disconnect(self.obj3.robot)
                    print()
                    print("disconnect")
                    print()
                    '''
					# stop timer
					self.timer_camera_big.stop()
					self.timer_camera_small.stop()
					
					# Releasing grab result
					self.grabResult.Release()
					# Releasing the resource    
					self.camera.StopGrabbing()
					
					self.gui.Dia_Finish()
					self.gui.dialog6.show()
					self.gui.dialog6.exec_()
					'''
            except:
                print("No distance")
                # pass

            # Modify image for gui_window
            self.imp = im.ImageProcessing(self.image, 'BLOB')
            self.show_img = self.imp.img_with_bounding

            # get image infos
            height, width, channel = self.show_img.shape
            step = channel * width
            # create QImage from image
            qImg = QImage(self.show_img.data, width, height, step,
                          QImage.Format_RGB888)
            # show image in img_label
            self.gui.form_main.label_bigCam.setPixmap(QPixmap.fromImage(qImg))
            self.gui.form_main.label_bigCam.setScaledContents(True)
            '''
예제 #2
0
    def update_frame_big(self):

        self.grabResult = self.camera.RetrieveResult(
            5000, pylon.TimeoutHandling_ThrowException)

        if self.grabResult.GrabSucceeded():
            # Access the image data
            self.img = self.converter_RGB.Convert(self.grabResult)
            self.image = self.img.GetArray()

            # Find distance between target and needle position
            try:
                fdist = fd.FindingDistance(self.image)
                distance = fdist.real_distance
                # send out distance values to control thread
                self.dist_signal.emit(distance)

            except:
                print("No distance")
                # pass

            # Modify image for gui_window
            self.imp = im.ImageProcessing(self.image, 'BLOB')
            self.show_img = self.imp.img_with_bounding

            # get image infos
            height, width, channel = self.show_img.shape
            step = channel * width
            # create QImage from image
            qImg = QImage(self.show_img.data, width, height, step,
                          QImage.Format_RGB888)
            # show image in img_label
            self.gui.form_main.label_bigCam.setPixmap(QPixmap.fromImage(qImg))
            self.gui.form_main.label_bigCam.setScaledContents(True)
            '''
	def Camera(self, queue, queue2):
		
		# conecting to the first available camera
		camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())

		# Grabing Continusely (video) with minimal delay
		camera.StartGrabbing(pylon.GrabStrategy_LatestImageOnly) 
		##camera.StartGrabbing(pylon.GrabStrategy_OneByOne)
		##camera.StartGrabbing(pylon.GrabStrategy_LatestImages)
		converter = pylon.ImageFormatConverter()

		# converting to opencv bgr format
		converter.OutputPixelFormat = pylon.PixelType_BGR8packed
		converter.OutputBitAlignment = pylon.OutputBitAlignment_MsbAligned

		while camera.IsGrabbing():
			grabResult = camera.RetrieveResult(5000, pylon.TimeoutHandling_ThrowException)

			if grabResult.GrabSucceeded():
				# Access the image data
				image = converter.Convert(grabResult)
				img = image.GetArray()
				
				# Find distance between target and needle position
				try:
					fdist = fd.FindingDistance(img)
					distance = fdist.real_distance
					
					# send out distance values to control thread
					queue.put(distance)
					
					show_im = fdist.ip_Orb.reimg
					queue2.put(show_im)
					
					
				except:
					print("No distance")
					# pass
				
				
				k = cv2.waitKey(1)
				if k == 27:
					break
				
			grabResult.Release()

		# Releasing the resource    
		camera.StopGrabbing()

		cv2.destroyAllWindows()
def viewCam():
	global grabResult 
	
	### big window
	'''
	# read image in BGR format
	ret, image = self.cap.read()
	# convert image to RGB format
	image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
	# get image infos
	height, width, channel = image.shape
	step = channel * width
	# create QImage from image
	qImg = QImage(image.data, width, height, step, QImage.Format_RGB888)
	# show image in img_label
	self.label_camera.setPixmap(QPixmap.fromImage(qImg))
	self.label_camera.setScaledContents(True)
	'''
	
	
	### small window
	
	grabResult = camera.RetrieveResult(5000, pylon.TimeoutHandling_ThrowException)
	
	if grabResult.GrabSucceeded():
		# Access the image data
		image2 = converter.Convert(grabResult)
		img2 = image2.GetArray()
					
					
		# distance = ([x_distance, y_distance])
		fdist = fd.FindingDistance()
		distance = fdist.Distance(img2)
		
		robot.DXL_Control(serialPort, distance)
		
		show_im = fdist.ip_Orb.reimg
		
		# get image infos
		height2, width2, channel2 = show_im.shape
		step2 = channel2 * width2
		# create QImage from image
		qImg2 = QImage(show_im.data, width2, height2, step2, QImage.Format_RGB888)
		# show image in img_label
		ui.label_camera2.setPixmap(QPixmap.fromImage(qImg2))
		ui.label_camera2.setScaledContents(True)