使用 IC Imaging Control 4 SDK 进行 Jupyterlab开发

来自The Imaging Source Knowledgebase Chinese
跳转到导航 跳转到搜索

安装环境

  • 安装 JupyterLab 开启终端机或命令提示字元,并输入以下指令安装 Jupyterlab:
    pip install jupyterlab
    

撷取影像的范例:

import imagingcontrol4 as ic4
ic4.Library.init()

# Create a Grabber object
grabber = ic4.Grabber()

# Open the first available video capture device
first_device_info = ic4.DeviceEnum.devices()[0]
grabber.device_open(first_device_info)

# Set the resolution to 640x480
grabber.device_property_map.set_value(ic4.PropId.WIDTH, 640)
grabber.device_property_map.set_value(ic4.PropId.HEIGHT, 480)

# Create a SnapSink. A SnapSink allows grabbing single images (or image sequences) out of a data stream.
sink = ic4.SnapSink()
# Setup data stream from the video capture device to the sink and start image acquisition.
grabber.stream_setup(sink, setup_option=ic4.StreamSetupOption.ACQUISITION_START)

try:
    # Grab a single image out of the data stream.
    image = sink.snap_single(1000)

    # Print image information.
    print(f"Received an image. ImageType: {image.image_type}")

    # Save the image.
    image.save_as_bmp("test.bmp")

except ic4.IC4Exception as ex:
    print(ex.message)
	
# Stop the data stream.
grabber.stream_stop()