def main(): camera = gbv.AsyncUSBCamera(0, gbv.UNKNOWN_CAMERA) camera.set_frame_size(640, 480) orig_window = gbv.CameraWindow('original', camera) edges_window = gbv.CameraWindow('edges', camera, drawing_pipeline=gbv.edges + gbv.gray) orig_window.show_async() edges_window.show()
def main(): camera = gbv.AsyncUSBCamera(0) camera.wait_start_reading() camera.set_frame_size(640, 480) orig_window = gbv.CameraWindow('original', camera) edges_window = gbv.CameraWindow('edges', camera, drawing_pipeline=gbv.edges + gbv.gray) orig_window.show_async() edges_window.show()
def main(): camera = gbv.AsyncUSBCamera(0) camera.set_exposure(-5) camera.wait_start_reading() window = gbv.CameraWindow('feed', camera, drawing_pipeline=gbv.DrawCircles( THRESHOLD, (0, 255, 0), circle_process=circle_process)) window.show_async() denoising_window = gbv.CameraWindow('denoised', camera, drawing_pipeline=THRESHOLD) denoising_window.show()
def main(): camera = gbv.AsyncUSBCamera(0) camera.wait_start_reading() window = gbv.CameraWindow('feed', camera) window.show_async() threshold_window = gbv.CameraWindow('threshold', camera, drawing_pipeline=THRESHOLD) threshold_window.show_async() denoising_window = gbv.CameraWindow('denoised', camera, drawing_pipeline=THRESHOLD + gbv.DistanceTransformThreshold(0.4)) denoising_window.show()
def main(): camera = gbv.USBCamera(0) camera.set_exposure(-5) window = gbv.CameraWindow('feed', camera) window.open() while True: frame = window.show_and_get_frame() k = window.last_key_pressed if k == 'r': bbox = cv2.selectROI('feed', frame) thr = gbv.median_threshold(frame, stdv, bbox, 'HSV') break cv2.destroyAllWindows() print(thr) original = gbv.FeedWindow(window_name='original') after_proc = gbv.FeedWindow(window_name='after threshold', drawing_pipeline=thr) original.open() after_proc.open() while True: ok, frame = camera.read() if not original.show_frame(frame): break if not after_proc.show_frame(frame): break original.close() after_proc.close()
def main(): camera = gbv.USBCamera(1, gbv.LIFECAM_3000) camera.resize(0.75, 0.75) # connect to camera camera.set_exposure(-8) # switch to auto exposure mode # this works on windows, when using a raspberry pi use booleans instead threshold_func = gbv.EMPTY_PIPELINE + CARGO_THRESHOLD + gbv.Erode( 5) + gbv.Dilate(10) # the full pipeline of thresholding and denoising window = gbv.CameraWindow( 'camera 0', camera, drawing_pipeline=gbv. DrawCircles( # draw the outline circles of the cargos threshold_func, (255, 0, 0), # threshold and color is blue (bgr) contours_process=gbv.FilterContours(100), # filter small contours circle_process=gbv.sort_circles + gbv.filter_inner_circles )) # sort circles and delete the inner circles window.show()
def main(): camera = gbv.USBCamera(0, gbv.LIFECAM_3000) threshold_function = THRESHOLD_CONST + gbv.MedianBlur(5) finder = gbv.RotatedRectFinder( threshold_function, OBJECT_CONST, contour_min_area=100, rotated_rects_process=gbv.sort_rotated_rects + gbv.filter_inner_rotated_rects) window = gbv.CameraWindow( 'feed', camera, drawing_pipeline=gbv.DrawRotatedRects( threshold_func=threshold_function, color=(255, 0, 0), contours_process=gbv.FilterContours(1000), rotated_rects_process=gbv.sort_rotated_rects + gbv.filter_inner_rotated_rects)) window.open() while window.is_opened(): frame = window.show_and_get_frame() objects = finder(frame, camera) if len(objects): print("object is at distance: %s meters" % (gbv.distance_from_object(objects[0]))) window.close()
def main(): camera = gbv.USBCamera(0) camera.set_exposure(-5) find_fuel = gbv.CircleFinder(FUEL_THRESHOLD, FUEL, contour_min_area=CONTOUR_MIN_AREA) window = gbv.CameraWindow( 'feed', camera, drawing_pipeline=gbv.DrawCircles( FUEL_THRESHOLD, (0, 255, 0), contours_process=gbv.FilterContours(CONTOUR_MIN_AREA), thickness=6)) while True: frame = window.show_and_get_frame() fuels = find_fuel.find_shapes(frame) k = window.last_key_pressed if k == 'r': wrapper = gbv.ContinuesShapeWrapper(fuels, frame, find_fuel.find_shapes, shape_type=SHAPE_TYPE, tracker_type=TRACKER_TYPE, shape_lifespan=20, track_new=True) break window.close() window = gbv.FeedWindow('track') window.open() ok = True while ok: ok, frame = camera.read() fuels = wrapper.find_shapes(frame) for i, fuel in fuels.items(): if fuel is None: continue frame = gbv.draw_circles(frame, [fuel], (0, 255, 0), thickness=6) frame = gbv.draw_text(frame, f'ID: {i}', (int(fuel[0][0]) - 10, int(fuel[0][1]) - 10), 1, (0, 255, 0), thickness=3) if not window.show_frame(frame): break
def main(): print('place object in the middle of the frame and press r') width = float(input('Enter object width in meters >>> ')) height = float(input('Enter object height in meters >>> ')) z = float( input('Enter distance from object in the Z axis in meter units >>> ')) camera = gbv.USBCamera(0) camera.set_exposure(-3) window = gbv.CameraWindow('feed', camera) window.open() while True: frame = window.show_and_get_frame() k = window.last_key_pressed if k == 'r': bbox = cv2.selectROI('feed', frame) fov = find_fov(bbox, (width, height), z, (camera.get_width(), camera.get_height())) break cv2.destroyAllWindows() print(f'width fov: {fov[0] / 2}\nheight fov: {fov[1] / 2}')