本文整理汇总了Python中Camera.Camera.stop方法的典型用法代码示例。如果您正苦于以下问题:Python Camera.stop方法的具体用法?Python Camera.stop怎么用?Python Camera.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Camera.Camera
的用法示例。
在下文中一共展示了Camera.stop方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from Camera import Camera [as 别名]
# 或者: from Camera.Camera import stop [as 别名]
def main():
global x, y, run
x = y = 0
run = True
pi = pigpio.pi()
motorx = Motor(pi,1)
motory = Motor(pi,2)
sampling_period = 0.2
control = Controller(pi, motorx, motory, sampling_period)
camera = Camera(sampling_period)
camera.start()
#control.start()
control.generate_transform()
control.target((0,0))
time.sleep(1)
#t = threading.Thread(target=read_input)
#t.start()
#obj = Identification()
try:
while True:
##### Test without the camera #####
#x = float(input("x: "))
#y = float(input("y: "))
#obj.position = (x,y)
#control.update_positions(obj, camera.laser)
############################################
control.target(camera.object.position)
time.sleep(sampling_period)
except(KeyboardInterrupt):
pass
finally:
run = False
control.stop()
camera.stop()
pi.stop()
示例2: main
# 需要导入模块: from Camera import Camera [as 别名]
# 或者: from Camera.Camera import stop [as 别名]
def main():
# Camera setup
camera_stack = []
camera_n = Semaphore(0)
camera_s = Semaphore(1)
cameras = Camera(camera_stack, camera_n, camera_s)
# Start the thread
cameras.start()
# Try to pull from the stack every 1 second and print data
for i in range(0, 10):
time.sleep(1)
camera_n.acquire()
camera_s.acquire()
left_lines = camera_stack.pop()
right_lines = camera_stack.pop()
camera_s.release()
print(i)
if right_lines != None:
for line in right_lines:
for rho, theta in line:
print(rho, theta)
else:
print("No right lines")
if left_lines != None:
for line in left_lines:
for rho, theta in line:
print(rho, theta)
else:
print("No left lines")
# Stop camera thread and wait for it to finish
cameras.stop()
cameras.join()
示例3: __init__
# 需要导入模块: from Camera import Camera [as 别名]
# 或者: from Camera.Camera import stop [as 别名]
#.........这里部分代码省略.........
# b = cv2.equalizeHist(b)
# g = cv2.equalizeHist(g)
# r = cv2.equalizeHist(r)
# frame = cv2.merge((b,g,r))
# frame = cv2.GaussianBlur(frame,(3,3),0)
# frame = cv2.medianBlur(frame,3)
# Convert to hsv format
# hsv = frame
hsv = cv2.cvtColor(frame,cv2.COLOR_BGR2HSV)
# hsv = cv2.split(frame)[2]
if not self.LOCKED:
# Get the reigon of interest
reigonOfInterest = hsv[ self.START[1]:self.END[1],self.START[0]:self.END[0],]
# Calculate histogram
self.ROI_HIST = cv2.calcHist([reigonOfInterest],[0,1], None, [180,255], [0,180,0, 255] )
# Normalize the histogram
cv2.normalize(self.ROI_HIST,self.ROI_HIST,0,255,cv2.NORM_MINMAX)
# Calculate back projection
dst = cv2.calcBackProject([hsv],[0,1],self.ROI_HIST,[0,180,0,255],10)
# Now convolute with circular disc
# threshold
# kernel = np.ones((5,5),np.uint8)
# ret,mask = cv2.threshold(dst,50,255,0)
# disc = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(5,5))
# cv2.filter2D(dst,-1,disc,dst)
# dst = cv2.merge((dst,dst,dst))
# res = cv2.bitwise_and(frame,dst)
# disc = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(3,3))
# cv2.filter2D(dst,-1,disc,dst)
# # dst = cv2.morphologyEx(dst,cv2.MORPH_OPEN,kernel)
# # dst = cv2.morphologyEx(dst,cv2.MORPH_OPEN,kernel)
# # dst = cv2.morphologyEx(dst,cv2.MORPH_OPEN,kernel)
# # dst = cv2.morphologyEx(dst,cv2.MORPH_CLOSE,kernel)
# # dst = cv2.morphologyEx(dst,cv2.MORPH_CLOSE,kernel)
# dst = cv2.morphologyEx(dst,cv2.MORPH_CLOSE,kernel)
# dst = cv2.morphologyEx(dst,cv2.MORPH_CLOSE,kernel)
# show the frame
# dst = cv2.dilate(dst,np.ones((3,3),np.uint8),iterations=2)
cv2.imshow('mask',dst)
cv2.rectangle(frame,self.START,self.END,(0,255,0),1)
cv2.imshow('original',frame)
# Lookout for any key presses
key = cv2.waitKey(1) & 0xFF
if key == 27:
break
if key == ord('l'):
self.LOCKED = True
if key == ord('u'):
self.LOCKED = False
self.end()
def end(self):
self.CAM.stop()
cv2.destroyAllWindows()
示例4:
# 需要导入模块: from Camera import Camera [as 别名]
# 或者: from Camera.Camera import stop [as 别名]
max_area=area
ci=i
if(ci != -1):
cnt=contours[ci]
# # cv2.imshow('mask',mask)
# # Draw a rectangle in the center
# frame = cv2.rectangle(frame,params.start,params.end,(0,255,0),1)
if(ci != -1):
# Find and draw the hull around the largest contour
hull = cv2.convexHull(cnt)
cv2.drawContours(frame,[hull],0,(0,255,0),2)
cv2.imshow('image',frame)
# print frame.astype(int)
# print BG.astype(int)
# c = c+1
key = cv2.waitKey(10) & 0xFF
if key == 27:
break
camera.stop()
cv2.destroyAllWindows()
示例5: main
# 需要导入模块: from Camera import Camera [as 别名]
# 或者: from Camera.Camera import stop [as 别名]
def main():
logger.debug("Starting TCNJ IGVC 2017")
logger.debug("Getting USB device mappings")
device_to_path = get_device_paths()
# GPS setup
logger.debug("Beginning GPS setup")
gps_coords_stack = Manager().list()
gps_n = Semaphore(0)
gps_s = Semaphore(1)
gps_sensor = GPS(gps_coords_stack, gps_n, gps_s, device_to_path["GPS"])
logger.debug("GPS setup complete")
# LiDAR setup
logger.debug("Beginning LiDAR setup")
lidar_data_stack = Manager().list()
lidar_n = Semaphore(0)
lidar_s = Semaphore(1)
lidar_sensor = LIDAR(lidar_data_stack, lidar_n, lidar_s, device_to_path["LIDAR"])
logger.debug("LiDAR setup complete")
# Camera setup
logger.debug("Beginning camera setup")
camera_lines_stack = Manager().list()
camera_n = Semaphore(0)
camera_s = Semaphore(1)
camera_controller = Camera(camera_lines_stack, camera_n, camera_s, device_to_path["RIGHT_CAM"], device_to_path["LEFT_CAM"])
logger.debug("Camera setup complete")
# Compass setup
logger.debug("Beginning compass setup")
compass_stack = Manager().list()
compass_n = Semaphore(0)
compass_s = Semaphore(1)
compass = Compass(compass_stack, compass_n, compass_s)
logger.debug("Compass setup complete")
# Wrap all the sensors' stacks and semaphores into 1 object
sensors = Sensors(
gps_coords_stack, gps_n, gps_s,
lidar_data_stack, lidar_n, lidar_s,
camera_lines_stack, camera_n, camera_s,
compass_stack, compass_n, compass_s
)
# Start the sensor processes
logger.debug("Setup complete")
logger.debug("Starting GPS process")
gps_sensor.start()
logger.debug("Startting LiDAR process")
lidar_sensor.start()
logger.debug("Starting camera process")
camera_controller.start();
logger.debug("Starting compass process")
compass.start();
# Set up wiringpi2 and GPIO pin 6 as input
logger.debug("Sensor process started, waiting for motors to turn on")
motors_on_pin = 6
wpi.wiringPiSetup()
wpi.pinMode(motors_on_pin, 0)
# Wait for motor controller to be turned on
motors_on = False
while not motors_on:
value = wpi.digitalRead(motors_on_pin)
if value == 1:
motors_on = True
else:
time.sleep(1)
logger.debug("Motors are on, begin autonomous navigation")
path_find = Avoidance(sensors)
path_find.start()
time.sleep(10)
# Stop the processes
logger.debug("Calling for processes to stop")
path_find.stop()
time.sleep(1)
gps_sensor.stop()
lidar_sensor.stop()
camera_controller.stop()
compass.stop()
# Clean up the processes
logger.debug("Waiting for processes to end")
path_find.join()
gps_sensor.join()
lidar_sensor.join()
camera_controller.join()
compass.join()
print("--------------- CAMERA STACK ---------------")
print(camera_lines_stack)
print("--------------- GPS STACK ---------------")
print(gps_coords_stack)
print("--------------- LIDAR STACK ---------------")
#.........这里部分代码省略.........