activate_compute_device激活计算设备T_activate_compute_device激活计算设备ActivateComputeDevice激活计算设备ActivateComputeDevice激活计算设备activate_compute_device激活计算设备 (算子)
名称
activate_compute_device激活计算设备T_activate_compute_device激活计算设备ActivateComputeDevice激活计算设备ActivateComputeDevice激活计算设备activate_compute_device激活计算设备 — 激活计算设备。
签名
描述
activate_compute_deviceactivate_compute_deviceActivateComputeDeviceActivateComputeDeviceActivateComputeDeviceactivate_compute_device 用于激活当前 HALCON 线程的计算设备
DeviceHandleDeviceHandleDeviceHandleDeviceHandledeviceHandledevice_handle 。此后在该线程中调用的所有 HALCON 算子,若为该设备提供了实现(参见 get_operator_infoget_operator_infoGetOperatorInfoGetOperatorInfoGetOperatorInfoget_operator_info),都将在 DeviceHandleDeviceHandleDeviceHandleDeviceHandledeviceHandledevice_handle 执行。使用 deactivate_compute_devicedeactivate_compute_deviceDeactivateComputeDeviceDeactivateComputeDeviceDeactivateComputeDevicedeactivate_compute_device 停用
DeviceHandleDeviceHandleDeviceHandleDeviceHandledeviceHandledevice_handle。
当前每个 HALCON 线程仅能激活一个计算设备。若在调用 activate_compute_deviceactivate_compute_deviceActivateComputeDeviceActivateComputeDeviceActivateComputeDeviceactivate_compute_device 前已有其他设备处于活动状态,该设备将自动失效。
执行信息
- 多线程类型:可重入(与非独占算子并行运行)。
- 多线程作用域:局部(仅可在创建窗口、模型或工具实例的同一线程中调用)。
- 未采用并行化处理。
参数
DeviceHandleDeviceHandleDeviceHandleDeviceHandledeviceHandledevice_handle (输入控制) compute_device → HComputeDevice, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
计算设备句柄。
示例(HDevelop)
open_compute_device (DeviceIdentifier, DeviceHandle)
read_image (Image, 'rings_and_nuts')
*
* Gaussian convolution on a compute device
activate_compute_device (DeviceHandle)
derivate_gauss (Image, DerivGauss, 5, 'none')
*
* Gaussian convolution on the CPU
deactivate_compute_device (DeviceHandle)
derivate_gauss (Image, DerivGauss, 5, 'none')
结果
如果 DeviceHandleDeviceHandleDeviceHandleDeviceHandledeviceHandledevice_handle 有效,activate_compute_deviceactivate_compute_deviceActivateComputeDeviceActivateComputeDeviceActivateComputeDeviceactivate_compute_device 返回值 2 (
H_MSG_TRUE)。否则将抛出异常。
可能的前趋
open_compute_deviceopen_compute_deviceOpenComputeDeviceOpenComputeDeviceOpenComputeDeviceopen_compute_device
另见
deactivate_compute_devicedeactivate_compute_deviceDeactivateComputeDeviceDeactivateComputeDeviceDeactivateComputeDevicedeactivate_compute_device,
deactivate_all_compute_devicesdeactivate_all_compute_devicesDeactivateAllComputeDevicesDeactivateAllComputeDevicesDeactivateAllComputeDevicesdeactivate_all_compute_devices
模块
基础