def initialize_sensor(self, device_index=0): # Open Device self._device = k4a.Device.open(device_index) # Start Cameras device_config = k4a.DeviceConfiguration( color_format=k4a.EImageFormat.COLOR_BGRA32, color_resolution=k4a.EColorResolution.RES_720P, depth_mode=k4a.EDepthMode.NFOV_UNBINNED, camera_fps=k4a.EFramesPerSecond.FPS_30, synchronized_images_only=True ) status = self._device.start_cameras(device_config) if status != k4a.EStatus.SUCCEEDED: raise IOError("failed start cameras!")
def main(): dev = k4a.Device() if k4a.device_open(0, dev): # color control settings color_control = ColorControl(dev) params = dict() params['exposure_time_absolute'] = 100000 params['brightness'] = 100 color_control.apply_settings(params) color_control.show_settings() serial = k4a.device_get_serialnum(dev) version = k4a.device_get_version(dev) print("Opened device {} {}\n".format(serial, version)) config = k4a.DeviceConfiguration() config.color_format = k4a.K4A_IMAGE_FORMAT_COLOR_MJPG config.color_resolution = k4a.K4A_COLOR_RESOLUTION_2160P config.depth_mode = k4a.K4A_DEPTH_MODE_NFOV_UNBINNED config.camera_fps = k4a.K4A_FRAMES_PER_SECOND_30 config.synchronized_images_only = True if k4a.device_start_cameras(dev, config): capture(dev, f"exposure.jpg") else: print("Failed to start cameras!") k4a.device_stop_cameras(dev) k4a.device_close(dev) print("Closed") else: print("Failed to open device")
import k4a import faulthandler import sys faulthandler.enable() dev = k4a.Device() if k4a.device_open(0, dev): serial = k4a.device_get_serialnum(dev) version = k4a.device_get_version(dev) print("Opened device {} {}\n".format(serial, version)) config = k4a.DeviceConfiguration() config.color_format = k4a.K4A_IMAGE_FORMAT_COLOR_MJPG config.color_resolution = k4a.K4A_COLOR_RESOLUTION_1536P config.depth_mode = k4a.K4A_DEPTH_MODE_WFOV_UNBINNED config.camera_fps = k4a.K4A_FRAMES_PER_SECOND_15 config.synchronized_images_only = True if k4a.device_start_cameras(dev, config): count = 0 while True: count += 1 capture = k4a.Capture() res = k4a.device_get_capture(dev, capture, 1000) if res == k4a.K4A_WAIT_RESULT_SUCCEEDED: img = k4a.capture_get_color_image(capture) if img: w = k4a.image_get_width_pixels(img) h = k4a.image_get_height_pixels(img)
if __name__ == '__main__': count = detect_device() if count: device = k4a.Device.open(0) print(device.serial_number) print(device.hardware_version) print(device.color_ctrl_cap) # camera configuration device_config = k4a.DeviceConfiguration( color_format=k4a.EImageFormat.COLOR_BGRA32, color_resolution=k4a.EColorResolution.RES_1080P, depth_mode=k4a.EDepthMode.WFOV_2X2BINNED, camera_fps=k4a.EFramesPerSecond.FPS_15, synchronized_images_only=True, depth_delay_off_color_usec=0, wired_sync_mode=k4a.EWiredSyncMode.STANDALONE, subordinate_delay_off_master_usec=0, disable_streaming_indicator=False) status = device.start_cameras(device_config) if status != k4a.EStatus.SUCCEEDED: exit(-1) cv.namedWindow("Color Image") cv.resizeWindow("Color Image", 640, 360) cv.namedWindow("Depth Image") while True: capture = device.get_capture(-1)