Commit 600adfe0 by 范立洲

add gitignore

parents
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
# vscode
.vscode/
\ No newline at end of file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# \~chinese 设备类型定义 \~english Device Type Definition
MV_UNKNOW_DEVICE = 0x00000000 # < \~chinese 未知设备类型,保留意义 \~english Unknown Device Type, Reserved
MV_GIGE_DEVICE = 0x00000001 # < \~chinese GigE设备 \~english GigE Device
MV_1394_DEVICE = 0x00000002 # < \~chinese 1394-a/b 设备 \~english 1394-a/b Device
MV_USB_DEVICE = 0x00000004 # < \~chinese USB 设备 \~english USB Device
MV_CAMERALINK_DEVICE = 0x00000008 # < \~chinese CameraLink设备 \~english CameraLink Device
INFO_MAX_BUFFER_SIZE = 64 # < \~chinese 最大的数据信息大小 \~english Maximum data information size
MV_MAX_TLS_NUM = 8 # < \~chinese 最多支持的传输层实例个数 \~english The maximum number of supported transport layer instances
MV_MAX_DEVICE_NUM = 256 # < \~chinese 最大支持的设备个数 \~english The maximum number of supported devices
MV_MAX_GENTL_IF_NUM = 256 # < \~chinese 最大支持的GenTL数量 \~english The maximum number of GenTL supported
MV_MAX_GENTL_DEV_NUM = 256 # < \~chinese 最大支持的GenTL设备数量 \~english The maximum number of GenTL devices supported
# \~chinese 设备的访问模式 \~english Device Access Mode
# \~chinese 独占权限,其他APP只允许读CCP寄存器 \~english Exclusive authority, other APP is only allowed to read the CCP register
MV_ACCESS_Exclusive = 1
# \~chinese 可以从5模式下抢占权限,然后以独占权限打开 \~english You can seize the authority from the 5 mode, and then open with exclusive authority
MV_ACCESS_ExclusiveWithSwitch = 2
# \~chinese 控制权限,其他APP允许读所有寄存器 \~english Control authority, allows other APP reading all registers
MV_ACCESS_Control = 3
# \~chinese 可以从5的模式下抢占权限,然后以控制权限打开 \~english You can seize the authority from the 5 mode, and then open with control authority
MV_ACCESS_ControlWithSwitch = 4
# \~chinese 以可被抢占的控制权限打开 \~english Open with seized control authority
MV_ACCESS_ControlSwitchEnable = 5
# \~chinese 可以从5的模式下抢占权限,然后以可被抢占的控制权限打开 \~english You can seize the authority from the 5 mode, and then open with seized control authority
MV_ACCESS_ControlSwitchEnableWithKey = 6
# \~chinese 读模式打开设备,适用于控制权限下 \~english Open with read mode and is available under control authority
MV_ACCESS_Monitor = 7
MV_MATCH_TYPE_NET_DETECT = 0x00000001 # < \~chinese 网络流量和丢包信息 \~english Network traffic and packet loss information
MV_MATCH_TYPE_USB_DETECT = 0x00000002 # < \~chinese host接收到来自U3V设备的字节总数 \~english The total number of bytes host received from U3V device
# \~chinese GigEVision IP配置 \~english GigEVision IP Configuration
MV_IP_CFG_STATIC = 0x05000000 # < \~chinese 静态 \~english Static
MV_IP_CFG_DHCP = 0x06000000 # < \~chinese DHCP \~english DHCP
MV_IP_CFG_LLA = 0x04000000 # < \~chinese LLA \~english LLA
# \~chinese GigEVision网络传输模式 \~english GigEVision Net Transfer Mode
MV_NET_TRANS_DRIVER = 0x00000001 # < \~chinese 驱动 \~english Driver
MV_NET_TRANS_SOCKET = 0x00000002 # < \~chinese Socket \~english Socket
# \~chinese CameraLink波特率 \~english CameraLink Baud Rates (CLUINT32)
MV_CAML_BAUDRATE_9600 = 0x00000001 # < \~chinese 9600 \~english 9600
MV_CAML_BAUDRATE_19200 = 0x00000002 # < \~chinese 19200 \~english 19200
MV_CAML_BAUDRATE_38400 = 0x00000004 # < \~chinese 38400 \~english 38400
MV_CAML_BAUDRATE_57600 = 0x00000008 # < \~chinese 57600 \~english 57600
MV_CAML_BAUDRATE_115200 = 0x00000010 # < \~chinese 115200 \~english 115200
MV_CAML_BAUDRATE_230400 = 0x00000020 # < \~chinese 230400 \~english 230400
MV_CAML_BAUDRATE_460800 = 0x00000040 # < \~chinese 460800 \~english 460800
MV_CAML_BAUDRATE_921600 = 0x00000080 # < \~chinese 921600 \~english 921600
MV_CAML_BAUDRATE_AUTOMAX = 0x40000000 # < \~chinese 最大值 \~english Auto Max
# \~chinese 异常消息类型 \~english Exception message type
MV_EXCEPTION_DEV_DISCONNECT = 0x00008001 # < \~chinese 设备断开连接 \~english The device is disconnected
MV_EXCEPTION_VERSION_CHECK = 0x00008002 # < \~chinese SDK与驱动版本不匹配 \~english SDK does not match the driver version
MAX_EVENT_NAME_SIZE = 128 # < \~chinese 设备Event事件名称最大长度 \~english Max length of event name
MV_MAX_XML_SYMBOLIC_NUM = 64 # \~chinese 最大XML符号数 \~english Max XML Symbolic Number
# generated by 'xml2py'
# flags '-c -d -v C:\test_h\CameraParams.xml -o CameraParams_header.py'
from ctypes import *
from enum import Enum
from CameraParams_const import *
from PixelType_header import *
STRING = c_char_p
MV_PointCloudFile_Undefined = 0 # < \~chinese 未定义的点云格式 \~english Undefined point cloud format
MV_ACQ_MODE_CONTINUOUS = 2 # < \~chinese 持续采集模式 \~english Continuous Mode
MV_ACQ_MODE_MUTLI = 1 # < \~chinese 多帧模式 \~english Multi Mode
MV_TRIGGER_MODE_ON = 1 # < \~chinese 打开 \~english On
AM_CycleDetect = 6 # < \~chinese 内部用于AccessMode循环检测 \~english used internally for AccessMode cycle detection
AM_Undefined = 5 # < \~chinese 对象未被初始化 \~english Object is not yet initialized
AM_RW = 4 # < \~chinese 读和写 \~english Read and Write
AM_RO = 3 # < \~chinese 只读 \~english Read Only
AM_WO = 2 # < \~chinese 只写 \~english Write Only
AM_NA = 1 # < \~chinese 不可用 \~english Not available
AM_NI = 0 # < \~chinese 没有实现 \~english Not implemented
MV_Image_Tif = 4 # < \~chinese Tif格式 \~english Tif image file
MV_Image_Png = 3 # < \~chinese Png格式 \~english Png image file
MV_Image_Jpeg = 2 # < \~chinese Jpeg格式 \~english Jpeg image file
MV_Image_Bmp = 1 # < \~chinese Bmp格式 \~english Bmp image file
MV_GAIN_MODE_CONTINUOUS = 2 # < \~chinese 连续 \~english Gain Mode Continuous
MV_GAIN_MODE_ONCE = 1 # < \~chinese 单次 \~english Gain Mode Once
MV_GrabStrategy_UpcomingImage = 3 # < \~chinese 等待下一帧图像 \~english Wait for the next image
MV_GrabStrategy_LatestImages = 2 # < \~chinese 获取列表中最新的图像 \~english Gets the latest image in the list
MV_GrabStrategy_LatestImagesOnly = 1 # < \~chinese 获取列表中最新的一帧图像(同时清除列表中的其余图像) \~english Gets the most recent image in the list (while clearing the rest of the images in the list)
MV_PointCloudFile_OBJ = 3 # < \~chinese OBJ点云格式 \~english The point cloud format named OBJ
MV_PointCloudFile_CSV = 2 # < \~chinese CSV点云格式 \~english The point cloud format named CSV
MV_PointCloudFile_PLY = 1 # < \~chinese PLY点云格式 \~english The point cloud format named PLY
MV_ACQ_MODE_SINGLE = 0 # < \~chinese 单帧模式 \~english Single Mode
MV_TRIGGER_MODE_OFF = 0 # < \~chinese 关闭 \~english Off
MV_TRIGGER_SOURCE_SOFTWARE = 7 # < \~chinese 软触发 \~english Trigger source software
MV_EXPOSURE_MODE_TIMED = 0 # < \~chinese 曝光超时模式 \~english exposure mode timed
MV_FormatType_Undefined = 0 # < \~chinese 未定义的格式类型 \~english Undefined format type
MV_GAIN_MODE_OFF = 0 # < \~chinese 关闭增益模式 \~english Gain mode off
MV_EXPOSURE_AUTO_MODE_CONTINUOUS = 2 # < \~chinese 自动连续曝光模式 \~english Exposure auto mode continuous
MV_EXPOSURE_AUTO_MODE_ONCE = 1 # < \~chinese 单次自动曝光模式 \~english Exposure auto mode once
MV_EXPOSURE_AUTO_MODE_OFF = 0 # < \~chinese 关闭自动曝光模式 \~english Exposure auto mode off
IFT_IValue = 0 # < \~chinese IValue接口类型 \~english IValue interface
MV_GrabStrategy_OneByOne = 0 # < \~chinese 从旧到新一帧一帧的获取图像 \~english Frame by frame from old to new
MV_FormatType_AVI = 1 # < \~chinese AVI视频格式 \~english AVI format type
MV_GAMMA_SELECTOR_USER = 1 # < \~chinese gamma选择项User \~english This enumeration selects the type of gamma to apply
IFT_IString = 6 # < \~chinese IString接口类型 \~english IString interface
MV_BALANCEWHITE_AUTO_OFF = 0 # < \~chinese 白平衡自动关闭 \~english Balance white auto off
MV_GAMMA_SELECTOR_SRGB = 2 # < \~chinese gamma选择项SRGB \~english This enumeration selects the type of gamma to apply
IFT_IPort = 11 # < \~chinese IPort接口类型 \~english IPort interface
MV_BALANCEWHITE_AUTO_CONTINUOUS = 1 # < \~chinese 白平衡自动连续 \~english Balance white auto continuous
IFT_IEnumEntry = 10 # < \~chinese IEnumEntry接口类型 \~english IEnumEntry interface
IFT_ICategory = 8 # < \~chinese ICategory接口类型 \~english ICategory interface
IFT_IRegister = 7 # < \~chinese IRegister接口类型 \~english IRegister interface
MV_Image_Undefined = 0 # < \~chinese 未定义的图像类型 \~english Image undefined
IFT_IFloat = 5 # < \~chinese IFloat接口类型 \~english IFloat interface
IFT_IEnumeration = 9 # < \~chinese IEnumeration接口类型 \~english IEnumeration interface
IFT_ICommand = 4 # < \~chinese ICommand接口类型 \~english ICommand interface
IFT_IBoolean = 3 # < \~chinese IBoolean接口类型 \~english IBoolean interface
IFT_IInteger = 2 # < \~chinese IInteger接口类型 \~english IInteger interface
MV_GIGE_TRANSTYPE_MULTICAST_WITHOUT_RECV = 65537 # < \~chinese 表示组播模式,但本实例不接收图像数据 \~english Multicast without receive data
IFT_IBase = 1 # < \~chinese IBase接口类型 \~english IBase interface
MV_GIGE_TRANSTYPE_UNICAST_WITHOUT_RECV = 65536 # < \~chinese 表示设置了单播,但本实例不接收图像数据 \~english Unicast without receive data
MV_BALANCEWHITE_AUTO_ONCE = 2 # < \~chinese 单次自动白平衡 \~english Balance white auto once
MV_GIGE_TRANSTYPE_LIMITEDBROADCAST = 2 # < \~chinese 表示局域网内广播,暂不支持 \~english Limited broadcast mode,not support
MV_GIGE_TRANSTYPE_MULTICAST = 1 # < \~chinese 表示组播 \~english Multicast mode
MV_GIGE_TRANSTYPE_UNICAST = 0 # < \~chinese 表示单播(默认) \~english Unicast mode(default)
MV_GIGE_TRANSTYPE_CAMERADEFINED = 4 # < \~chinese 表示从相机获取,暂不支持 \~english Transtype from camera,not support
MV_GIGE_TRANSTYPE_SUBNETBROADCAST = 3 # < \~chinese 表示子网内广播,暂不支持 \~english Subnet broadcast mode,not support
MV_EXPOSURE_MODE_TRIGGER_WIDTH = 1 # < \~chinese 曝光模式触发宽 \~english Trigger width
MV_GIGE_TRANSTYPE_UNICAST_DEFINED_PORT = 5 # < \~chinese 表示用户自定义应用端接收图像数据Port号 \~english User Defined Receive Data Port
MV_TRIGGER_SOURCE_FrequencyConverter = 8 # < \~chinese 触发源变频器 \~english Trigger source frequency converter
MV_TRIGGER_SOURCE_COUNTER0 = 4 # < \~chinese 触发源计数器 \~english Trigger source conuter
MV_TRIGGER_SOURCE_LINE3 = 3 # < \~chinese LINE3 触发源 \~english Trigger source line3
MV_TRIGGER_SOURCE_LINE2 = 2 # < \~chinese LINE2 触发源 \~english Trigger source line2
MV_TRIGGER_SOURCE_LINE1 = 1 # < \~chinese LINE1 触发源 \~english Trigger source line1
MV_TRIGGER_SOURCE_LINE0 = 0 # < \~chinese LINE0 触发源 \~english Trigger source line0
int8_t = c_int8
int16_t = c_int16
int32_t = c_int32
int64_t = c_int64
uint8_t = c_uint8
uint16_t = c_uint16
uint32_t = c_uint32
uint64_t = c_uint64
int_least8_t = c_byte
int_least16_t = c_short
int_least32_t = c_int
int_least64_t = c_long
uint_least8_t = c_ubyte
uint_least16_t = c_ushort
uint_least32_t = c_uint
uint_least64_t = c_ulong
int_fast8_t = c_byte
int_fast16_t = c_long
int_fast32_t = c_long
int_fast64_t = c_long
uint_fast8_t = c_ubyte
uint_fast16_t = c_ulong
uint_fast32_t = c_ulong
uint_fast64_t = c_ulong
intptr_t = c_long
uintptr_t = c_ulong
intmax_t = c_long
uintmax_t = c_ulong
# GigE设备信息 \~english GigE device info
class _MV_GIGE_DEVICE_INFO_(Structure):
pass
_MV_GIGE_DEVICE_INFO_._fields_ = [
('nIpCfgOption', c_uint), # < \~chinese IP配置选项 \~english Ip config option
('nIpCfgCurrent', c_uint), # < \~chinese 当前IP地址配置 \~english IP configuration:bit31-static bit30-dhcp bit29-lla
('nCurrentIp', c_uint), # < \~chinese 当前主机IP地址 \~english Current host Ip
('nCurrentSubNetMask', c_uint), # < \~chinese 当前子网掩码 \~english curtent subnet mask
('nDefultGateWay', c_uint), # < \~chinese 默认网关 \~english Default gate way
('chManufacturerName', c_ubyte * 32), # < \~chinese 厂商名称 \~english Manufacturer Name
('chModelName', c_ubyte * 32), # < \~chinese 型号名称 \~english Mode name
('chDeviceVersion', c_ubyte * 32), # < \~chinese 设备固件版本 \~english Device Version
('chManufacturerSpecificInfo', c_ubyte * 48), # < \~chinese 厂商特殊信息 \~english Manufacturer Specific Infomation
('chSerialNumber', c_ubyte * 16), # < \~chinese 序列号 \~english serial number
('chUserDefinedName', c_ubyte * 16), # < \~chinese 用户定义名称 \~english User Defined Name
('nNetExport', c_uint), # < \~chinese 网口Ip地址 \~english NetWork Ip address
('nReserved', c_uint * 4), # < \~chinese 保留字节 \~english Reserved bytes
]
MV_GIGE_DEVICE_INFO = _MV_GIGE_DEVICE_INFO_
# USB设备信息 \~english USB device info
class _MV_USB3_DEVICE_INFO_(Structure):
pass
_MV_USB3_DEVICE_INFO_._fields_ = [
('CrtlInEndPoint', c_ubyte), # < \~chinese 控制输入端点 \~english Control input endpoint
('CrtlOutEndPoint', c_ubyte), # < \~chinese 控制输出端点 \~english Control output endpoint
('StreamEndPoint', c_ubyte), # < \~chinese 流端点 \~english Flow endpoint
('EventEndPoint', c_ubyte), # < \~chinese 事件端点 \~english Event endpoint
('idVendor', c_ushort), # < \~chinese 供应商ID号 \~english Vendor ID Number
('idProduct', c_ushort), # < \~chinese 产品ID号 \~english Device ID Number
('nDeviceNumber', c_uint), # < \~chinese 设备序列号 \~english Device Serial Number
('chDeviceGUID', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 设备GUID号 \~english Device GUID Number
('chVendorName', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 供应商名字 \~english Vendor Name
('chModelName', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 型号名字 \~english Model Name
('chFamilyName', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 家族名字 \~english Family Name
('chDeviceVersion', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 设备版本号 \~english Device Version
('chManufacturerName', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 制造商名字 \~english Manufacturer Name
('chSerialNumber', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 序列号 \~english Serial Number
('chUserDefinedName', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 用户自定义名字 \~english User Defined Name
('nbcdUSB', c_uint), # < \~chinese 支持的USB协议 \~english Support USB Protocol
('nDeviceAddress', c_uint), # < \~chinese 设备地址 \~english Device Address
('nReserved', c_uint * 2), # < \~chinese 保留字节 \~english Reserved bytes
]
MV_USB3_DEVICE_INFO = _MV_USB3_DEVICE_INFO_
# CameraLink设备信息 \~english CameraLink device info
class _MV_CamL_DEV_INFO_(Structure):
pass
_MV_CamL_DEV_INFO_._fields_ = [
('chPortID', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 端口号 \~english Port ID
('chModelName', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 设备型号 \~english Model name
('chFamilyName', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 家族名字 \~english Family Name
('chDeviceVersion', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 设备版本号 \~english Device Version
('chManufacturerName', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 制造商名字 \~english Manufacturer Name
('chSerialNumber', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 序列号 \~english Serial Number
('nReserved', c_uint * 38), # < \~chinese 保留字节 \~english Reserved bytes
]
MV_CamL_DEV_INFO = _MV_CamL_DEV_INFO_
# CameraParams.h 80
class _MV_CC_DEVICE_INFO_(Structure):
pass
# 设备信息 \~english Device info
class N19_MV_CC_DEVICE_INFO_3DOT_0E(Union):
pass
N19_MV_CC_DEVICE_INFO_3DOT_0E._fields_ = [
('stGigEInfo', MV_GIGE_DEVICE_INFO), # < \~chinese Gige设备信息 \~english Gige device infomation
('stUsb3VInfo', MV_USB3_DEVICE_INFO), # < \~chinese U3V设备信息 \~english u3V device information
('stCamLInfo', MV_CamL_DEV_INFO), # < \~chinese CamLink设备信息 \~english CamLink device information
]
_MV_CC_DEVICE_INFO_._fields_ = [
# CameraParams.h 80
('nMajorVer', c_ushort), # < \~chinese 规范的主要版本 \~english Major version of the specification.
('nMinorVer', c_ushort), # < \~chinese 规范的次要版本 \~english Minor version of the specification
('nMacAddrHigh', c_uint), # < \~chinese MAC地址高位 \~english Mac address high
('nMacAddrLow', c_uint), # < \~chinese MAC地址低位 \~english Mac address low
('nTLayerType', c_uint), # < \~chinese 设备传输层协议类型 \~english Device Transport Layer Protocol Type, e.g. MV_GIGE_DEVICE
('nReserved', c_uint * 4), # < \~chinese 保留字节 \~english Reserved bytes
('SpecialInfo', N19_MV_CC_DEVICE_INFO_3DOT_0E), # < \~chinese 不同设备特有信息 \~english Special information
]
MV_CC_DEVICE_INFO = _MV_CC_DEVICE_INFO_
# 设备信息列表 \~english Device Information List
class _MV_CC_DEVICE_INFO_LIST_(Structure):
pass
_MV_CC_DEVICE_INFO_LIST_._fields_ = [
('nDeviceNum', c_uint), # < \~chinese 在线设备数量 \~english Online Device Number
('pDeviceInfo', POINTER(MV_CC_DEVICE_INFO) * MV_MAX_DEVICE_NUM), # < \~chinese 支持最多256个设备 \~english Support up to 256 devices
]
MV_CC_DEVICE_INFO_LIST = _MV_CC_DEVICE_INFO_LIST_
# 通过GenTL枚举到的Interface信息 \~english Interface Information with GenTL
class _MV_GENTL_IF_INFO_(Structure):
pass
_MV_GENTL_IF_INFO_._fields_ = [
('chInterfaceID', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese GenTL接口ID \~english Interface ID of GenTL
('chTLType', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 传输层类型 \~english Transport Layer type
('chDisplayName', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 设备显示名称 \~english Display name
('nCtiIndex', c_uint), # < \~chinese GenTL的cti文件索引 \~english Cti file index of GenTL
('nReserved', c_uint * 8), # < \~chinese 保留字节 \~english Reserved bytes
]
MV_GENTL_IF_INFO = _MV_GENTL_IF_INFO_
# 通过GenTL枚举到的设备信息列表 \~english Device Information List with GenTL
class _MV_GENTL_IF_INFO_LIST_(Structure):
pass
_MV_GENTL_IF_INFO_LIST_._fields_ = [
('nInterfaceNum', c_uint), # < \~chinese 在线设备数量 \~english Online Device Number
('pIFInfo', POINTER(MV_GENTL_IF_INFO) * MV_MAX_GENTL_IF_NUM), # < \~chinese 支持最多256个设备 \~english Support up to 256 devices
]
MV_GENTL_IF_INFO_LIST = _MV_GENTL_IF_INFO_LIST_
# 通过GenTL枚举到的设备信息 \~english Device Information with GenTL
class _MV_GENTL_DEV_INFO_(Structure):
pass
_MV_GENTL_DEV_INFO_._fields_ = [
('chInterfaceID', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese GenTL接口ID \~english Interface ID of GenTL
('chDeviceID', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 设备ID \~english Device ID
('chVendorName', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 供应商名字 \~english Vendor Name
('chModelName', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 型号名字 \~english Model name
('chTLType', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 传输层类型 \~english Transport Layer type
('chDisplayName', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 显示名称 \~english Display name
('chUserDefinedName', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 用户自定义名字 \~english User defined name
('chSerialNumber', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 序列号 \~english Serial number
('chDeviceVersion', c_ubyte * INFO_MAX_BUFFER_SIZE), # < \~chinese 设备版本号 \~english Device version
('nCtiIndex', c_uint), # < \~chinese cti索引 \~english Cti Index
('nReserved', c_uint * 8), # < \~chinese 保留字节 \~english Reserved bytes
]
MV_GENTL_DEV_INFO = _MV_GENTL_DEV_INFO_
# 通过GenTL枚举到的设备信息列表 \~english Device Information List with GenTL
class _MV_GENTL_DEV_INFO_LIST_(Structure):
pass
_MV_GENTL_DEV_INFO_LIST_._fields_ = [
('nDeviceNum', c_uint), # < \~chinese 在线设备数量 \~english Online Device Number
('pDeviceInfo', POINTER(MV_GENTL_DEV_INFO) * MV_MAX_GENTL_DEV_NUM), # < \~chinese GenTL设备信息 \~english device infomation of GenTL device
]
MV_GENTL_DEV_INFO_LIST = _MV_GENTL_DEV_INFO_LIST_
# Chunk内容 \~english The content of ChunkData
class _MV_CHUNK_DATA_CONTENT_(Structure):
pass
_MV_CHUNK_DATA_CONTENT_._fields_ = [
('pChunkData', POINTER(c_ubyte)), # < \~chinese 块数据 \~english Chunk data
('nChunkID', c_uint), # < \~chinese 块数据ID \~english Chunk id
('nChunkLen', c_uint), # < \~chinese 块数据长度 \~english Chunk len
('nReserved', c_uint * 8), # < \~chinese 保留字节 \~english Reserved bytes
]
MV_CHUNK_DATA_CONTENT = _MV_CHUNK_DATA_CONTENT_
# 输出帧的信息 \~english Output Frame Information
class _MV_FRAME_OUT_INFO_EX_(Structure):
pass
# values for enumeration 'MvGvspPixelType'
MvGvspPixelType = c_int # enum
class N22_MV_FRAME_OUT_INFO_EX_3DOT_1E(Union):
pass
N22_MV_FRAME_OUT_INFO_EX_3DOT_1E._fields_ = [
('pUnparsedChunkContent', POINTER(MV_CHUNK_DATA_CONTENT)), # < \~chinese Chunk内容 \~english Chunk Content
('nAligning', int64_t), # < \~chinese 校准字段 \~english Aligning
]
_MV_FRAME_OUT_INFO_EX_._fields_ = [
('nWidth', c_ushort), # < \~chinese 图像宽 \~english Image Width
('nHeight', c_ushort), # < \~chinese 图像高 \~english Image Height
('enPixelType', MvGvspPixelType), # < \~chinese 像素格式 \~english Pixel Type
('nFrameNum', c_uint), # < \~chinese 帧号 \~english Frame Number
('nDevTimeStampHigh', c_uint), # < \~chinese 时间戳高32位 \~english Timestamp high 32 bits
('nDevTimeStampLow', c_uint), # < \~chinese 时间戳低32位 \~english Timestamp low 32 bits
('nReserved0', c_uint), # < \~chinese 保留,8字节对齐 \~english Reserved, 8-byte aligned
('nHostTimeStamp', int64_t), # < \~chinese 主机生成的时间戳 \~english Host-generated timestamp
('nFrameLen', c_uint), # < \~chinese 帧的长度 \~english Frame length
# < \~chinese 以下为chunk新增水印信息 \~english The followings are chunk add frame-specific information
# < \~chinese 设备水印时标 \~english Device frame-specific time scale
('nSecondCount', c_uint),
('nCycleCount', c_uint),
('nCycleOffset', c_uint),
('fGain', c_float), # < \~chinese 增益 \~english Gain
('fExposureTime', c_float), # < \~chinese 曝光时间 \~english Exposure Time
('nAverageBrightness', c_uint), # < \~chinese 平均亮度 \~english Average brightness
# < \~chinese:白平衡相关 \~english White balance
('nRed', c_uint),
('nGreen', c_uint),
('nBlue', c_uint),
('nFrameCounter', c_uint), # < \~chinese 帧计数 \~english Frame counter
('nTriggerIndex', c_uint), # < \~chinese 触发计数 \~english Trigger index
# < \~chinese 输入/输出 \~english Line Input/Output
('nInput', c_uint),
('nOutput', c_uint),
# < \~chinese ROI区域 \~english ROI Region
('nOffsetX', c_ushort),
('nOffsetY', c_ushort),
('nChunkWidth', c_ushort),
('nChunkHeight', c_ushort),
('nLostPacket', c_uint), # < \~chinese 本帧丢包数 \~english Lost Pacekt Number In This Frame
('nUnparsedChunkNum', c_uint), # < \~chinese 未解析的Chunkdata个数 \~english Unparsed chunk number
('UnparsedChunkList', N22_MV_FRAME_OUT_INFO_EX_3DOT_1E), # < \~chinese 数据库链表 \~english Unparsed chunk list
('nReserved', c_uint * 36), # < \~chinese 保留字节 \~english Reserved bytes
]
MV_FRAME_OUT_INFO_EX = _MV_FRAME_OUT_INFO_EX_
# 图像结构体,输出图像指针地址及图像信息 \~english Image Struct, output the pointer of Image and the information of the specific image
class _MV_FRAME_OUT_(Structure):
pass
_MV_FRAME_OUT_._fields_ = [
('pBufAddr', POINTER(c_ubyte)), # < \~chinese 图像指针地址 \~english pointer of image
('stFrameInfo', MV_FRAME_OUT_INFO_EX), # < \~chinese 图像信息 \~english information of the specific image
('nRes', c_uint * 16), # < \~chinese 保留字节 \~english Reserved bytes
]
MV_FRAME_OUT = _MV_FRAME_OUT_
# values for enumeration '_MV_GRAB_STRATEGY_'
_MV_GRAB_STRATEGY_ = c_int # enum
MV_GRAB_STRATEGY = _MV_GRAB_STRATEGY_
# 网络传输的相关信息 \~english Network transmission information
class _MV_NETTRANS_INFO_(Structure):
pass
_MV_NETTRANS_INFO_._fields_ = [
('nReceiveDataSize', int64_t), # < \~chinese 已接收数据大小 [统计StartGrabbing和StopGrabbing之间的数据量] \~english Received Data Size [Calculate the Data Size between StartGrabbing and StopGrabbing]
('nThrowFrameCount', c_int), # < \~chinese 丢帧数量 \~english Throw frame number
('nNetRecvFrameCount', c_uint), # < \~chinese 收到帧计数 \~english Receive Frame count
('nRequestResendPacketCount', int64_t), # < \~chinese 请求重发包数 \~english Request Resend Packet Count
('nResendPacketCount', int64_t), # < \~chinese 重发包数 \~english Resend Packet Count
]
MV_NETTRANS_INFO = _MV_NETTRANS_INFO_
# 全匹配的一种信息结构体 \~english A fully matched information structure
class _MV_ALL_MATCH_INFO_(Structure):
pass
_MV_ALL_MATCH_INFO_._fields_ = [
('nType', c_uint), # < \~chinese 需要输出的信息类型 \~english Information type need to output
('pInfo', c_void_p), # < \~chinese 输出的信息缓存,由调用者分配 \~englishOutput information cache, which is allocated by the caller
('nInfoSize', c_uint), # < \~chinese 信息缓存的大小 \~english Information cache size
]
MV_ALL_MATCH_INFO = _MV_ALL_MATCH_INFO_
# 网络流量和丢包信息反馈结构体,对应类型为 MV_MATCH_TYPE_NET_DETECT \~english Network traffic and packet loss feedback structure, the corresponding type is MV_MATCH_TYPE_NET_DETECT
class _MV_MATCH_INFO_NET_DETECT_(Structure):
pass
_MV_MATCH_INFO_NET_DETECT_._fields_ = [
('nReceiveDataSize', int64_t), # < \~chinese 已接收数据大小 \~english Received data size
('nLostPacketCount', int64_t), # < \~chinese 丢失的包数量 \~english Number of packets lost
('nLostFrameCount', c_uint), # < \~chinese 丢帧数量 \~english Number of frames lost
('nNetRecvFrameCount', c_uint), # < \~chinese 收到帧计数 \~english Receive Frame count
('nRequestResendPacketCount', int64_t), # < \~chinese 请求重发包数 \~english Request Resend Packet Count
('nResendPacketCount', int64_t), # < \~chinese 重发包数 \~english Resend Packet Count
]
MV_MATCH_INFO_NET_DETECT = _MV_MATCH_INFO_NET_DETECT_
# \~chinese host收到从u3v设备端的总字节数,对应类型为 MV_MATCH_TYPE_USB_DETECT \~english The total number of bytes host received from the u3v device side, the corresponding type is MV_MATCH_TYPE_USB_DETECT
class _MV_MATCH_INFO_USB_DETECT_(Structure):
pass
_MV_MATCH_INFO_USB_DETECT_._fields_ = [
('nReceiveDataSize', int64_t), # < \~chinese 已接收数据大小 \~english Received data size
('nReceivedFrameCount', c_uint), # < \~chinese 已收到的帧数 \~english Number of frames received
('nErrorFrameCount', c_uint), # < \~chinese 错误帧数 \~english Number of error frames
('nReserved', c_uint * 2), # < \~chinese 保留字节 \~english Reserved bytes
]
MV_MATCH_INFO_USB_DETECT = _MV_MATCH_INFO_USB_DETECT_
# \~chinese 显示帧信息 \~english Display frame information
class _MV_DISPLAY_FRAME_INFO_(Structure):
pass
_MV_DISPLAY_FRAME_INFO_._fields_ = [
('hWnd', c_void_p), # < \~chinese 窗口句柄 \~english Windows handle
('pData', POINTER(c_ubyte)), # < \~chinese 显示的数据 \~english Data Buffer
('nDataLen', c_uint), # < \~chinese 数据长度 \~english Data Size
('nWidth', c_ushort), # < \~chinese 图像宽 \~english Width
('nHeight', c_ushort), # < \~chinese 图像高 \~english Height
('enPixelType', MvGvspPixelType), # < \~chinese 像素格式 \~english Pixel format
('nRes', c_uint * 4), # < \~chinese 保留字节 \~english Reserved bytes
]
MV_DISPLAY_FRAME_INFO = _MV_DISPLAY_FRAME_INFO_
# values for enumeration 'MV_SAVE_POINT_CLOUD_FILE_TYPE'
MV_SAVE_POINT_CLOUD_FILE_TYPE = c_int # enum
# \~chinese 保存3D数据到缓存 \~english Save 3D data to buffer
class _MV_SAVE_POINT_CLOUD_PARAM_(Structure):
pass
_MV_SAVE_POINT_CLOUD_PARAM_._fields_ = [
('nLinePntNum', c_uint), # < \~chinese 每一行点的数量,即图像宽 \~english The number of points in each row,which is the width of the image
('nLineNum', c_uint), # < \~chinese 行数,即图像高 \~english The number of rows,which is the height of the image
('enSrcPixelType', MvGvspPixelType), # < \~chinese 输入数据的像素格式 \~english The pixel format of the input data
('pSrcData', POINTER(c_ubyte)), # < \~chinese 输入数据缓存 \~english Input data buffer
('nSrcDataLen', c_uint), # < \~chinese 输入数据大小 \~english Input data size
('pDstBuf', POINTER(c_ubyte)), # < \~chinese 输出像素数据缓存 \~english Output pixel data buffer
('nDstBufSize', c_uint), # < \~chinese 提供的输出缓冲区大小(nLinePntNum * nLineNum * (16*3 + 4) + 2048) \~english Output buffer size provided (nLinePntNum * nLineNum * (16*3 + 4) + 2048)
('nDstBufLen', c_uint), # < \~chinese 输出像素数据缓存长度 \~english Output pixel data buffer size
('enPointCloudFileType', MV_SAVE_POINT_CLOUD_FILE_TYPE), # < \~chinese 提供输出的点云文件类型 \~english Output point data file type provided
('nReserved', c_uint * 8), # < \~chinese 保留字节 \~english Reserved bytes
]
MV_SAVE_POINT_CLOUD_PARAM = _MV_SAVE_POINT_CLOUD_PARAM_
# values for enumeration 'MV_SAVE_IAMGE_TYPE'
MV_SAVE_IAMGE_TYPE = c_int # enum
# \~chinese 图片保存参数 \~english Save Image Parameters
class _MV_SAVE_IMAGE_PARAM_T_EX_(Structure):
pass
_MV_SAVE_IMAGE_PARAM_T_EX_._fields_ = [
('pData', POINTER(c_ubyte)), # < \~chinese 输入数据缓存 \~english Input Data Buffer
('nDataLen', c_uint), # < \~chinese 输入数据大小 \~english Input Data Size
('enPixelType', MvGvspPixelType), # < \~chinese 输入数据的像素格式 \~english Input Data Pixel Format
('nWidth', c_ushort), # < \~chinese 图像宽 \~english Image Width
('nHeight', c_ushort), # < \~chinese 图像高 \~english Image Height
('pImageBuffer', POINTER(c_ubyte)), # < \~chinese 输出图片缓存 \~english Output Image Buffer
('nImageLen', c_uint), # < \~chinese 输出图片大小 \~english Output Image Size
('nBufferSize', c_uint), # < \~chinese 提供的输出缓冲区大小 \~english Output buffer size provided
('enImageType', MV_SAVE_IAMGE_TYPE), # < \~chinese 输出图片格式 \~english Output Image Format
('nJpgQuality', c_uint), # < \~chinese 编码质量, (50-99] \~english Encoding quality, (50-99]
# < \~chinese Bayer格式转为RGB24的插值方法 0-最近邻 1-双线性 2-Hamilton (如果传入其它值则默认为最近邻)
# < \~english Interpolation method of convert Bayer to RGB24 0-nearest neighbour 1-bilinearity 2-Hamilton
('iMethodValue', c_uint),
('nReserved', c_uint * 3), # < \~chinese 保留字节 \~english Reserved bytes
]
MV_SAVE_IMAGE_PARAM_EX = _MV_SAVE_IMAGE_PARAM_T_EX_
# \~chinese 保存BMP、JPEG、PNG、TIFF图片文件的参数 \~english Save BMP、JPEG、PNG、TIFF image file parameters
class _MV_SAVE_IMG_TO_FILE_PARAM_(Structure):
pass
_MV_SAVE_IMG_TO_FILE_PARAM_._fields_ = [
('enPixelType', MvGvspPixelType), # < \~chinese 输入数据的像素格式 \~english The pixel format of the input data
('pData', POINTER(c_ubyte)), # < \~chinese 输入数据缓存 \~english Input Data Buffer
('nDataLen', c_uint), # < \~chinese 输入数据大小 \~english Input Data Size
('nWidth', c_ushort), # < \~chinese 图像宽 \~english Image Width
('nHeight', c_ushort), # < \~chinese 图像高 \~english Image Height
('enImageType', MV_SAVE_IAMGE_TYPE), # < \~chinese 输入图片格式 \~english Input Image Format
('nQuality', c_uint), # < \~chinese JPG编码质量(50-99],PNG编码质量[0-9] \~english JPG Encoding quality(50-99],PNG Encoding quality[0-9]
('pImagePath', c_char * 256), # < \~chinese 输入文件路径 \~english Input file path
# < \~chinese ch:Bayer格式转为RGB24的插值方法 0-最近邻 1-双线性 2-Hamilton
# < \~english en:Interpolation method of convert Bayer to RGB24 0-nearest neighbour 1-bilinearity 2-Hamilton
('iMethodValue', c_int),
('nReserved', c_uint * 8), # < \~chinese 保留字节 \~english Reserved bytes
]
MV_SAVE_IMG_TO_FILE_PARAM = _MV_SAVE_IMG_TO_FILE_PARAM_
# \~chinese 图像转换结构体 \~english Pixel convert structure
class _MV_PIXEL_CONVERT_PARAM_T_(Structure):
pass
_MV_PIXEL_CONVERT_PARAM_T_._fields_ = [
('nWidth', c_ushort), # < \~chinese 图像宽 \~english Image Width
('nHeight', c_ushort), # < \~chinese 图像高 \~english Image Height
('enSrcPixelType', MvGvspPixelType), # < \~chinese 源像素格式 \~english Source pixel format
('pSrcData', POINTER(c_ubyte)), # < \~chinese 输入数据缓存 \~english Input data buffer
('nSrcDataLen', c_uint), # < \~chinese 输入数据大小 \~english Input data size
('enDstPixelType', MvGvspPixelType), # < \~chinese 目标像素格式 \~english Destination pixel format
('pDstBuffer', POINTER(c_ubyte)), # < \~chinese 输出数据缓存 \~english Output data buffer
('nDstLen', c_uint), # < \~chinese 输出数据大小 \~english Output data size
('nDstBufferSize', c_uint), # < \~chinese 提供的输出缓冲区大小 \~english Provided outbut buffer size
('nRes', c_uint * 4), # < \~chinese 保留字节 \~english Reserved bytes
]
MV_CC_PIXEL_CONVERT_PARAM = _MV_PIXEL_CONVERT_PARAM_T_
# values for enumeration '_MV_RECORD_FORMAT_TYPE_'
_MV_RECORD_FORMAT_TYPE_ = c_int # enum
MV_RECORD_FORMAT_TYPE = _MV_RECORD_FORMAT_TYPE_
# \~chinese 录像参数 \~english Record Parameters
class _MV_CC_RECORD_PARAM_T_(Structure):
pass
_MV_CC_RECORD_PARAM_T_._fields_ = [
('enPixelType', MvGvspPixelType), # < \~chinese 输入数据的像素格式 \~english Ip config option
('nWidth', c_ushort), # < \~chinese 图像宽(指定目标参数时需为2的倍数) \~english Ip config option
('nHeight', c_ushort), # < \~chinese 图像高(指定目标参数时需为2的倍数) \~english Ip config option
('fFrameRate', c_float), # < \~chinese 帧率fps(1/16-120) \~english Ip config option
('nBitRate', c_uint), # < \~chinese 码率kbps(128kbps-16Mbps) \~english Ip config option
('enRecordFmtType', MV_RECORD_FORMAT_TYPE), # < \~chinese 录像格式 \~english Ip config option
('strFilePath', STRING), # < \~chinese 录像文件存放路径(如果路径中存在中文,需转成utf-8) \~english Video file storage path (if there is Chinese in the path, it needs to be converted to utf-8)
('nRes', c_uint * 8), # < \~chinese 保留字节 \~english Reserved bytes
]
MV_CC_RECORD_PARAM = _MV_CC_RECORD_PARAM_T_
# \~chinese 录像数据 \~english Record Data
class _MV_CC_INPUT_FRAME_INFO_T_(Structure):
pass
_MV_CC_INPUT_FRAME_INFO_T_._fields_ = [
('pData', POINTER(c_ubyte)), # < \~chinese 图像数据指针 \~english Input Data Buffer
('nDataLen', c_uint), # < \~chinese 输入数据大小 \~english Input Data Size
('nRes', c_uint * 8), # < \~chinese 保留字节 \~english Reserved bytes
]
MV_CC_INPUT_FRAME_INFO = _MV_CC_INPUT_FRAME_INFO_T_
# values for enumeration '_MV_CAM_ACQUISITION_MODE_'
_MV_CAM_ACQUISITION_MODE_ = c_int # enum
MV_CAM_ACQUISITION_MODE = _MV_CAM_ACQUISITION_MODE_
# values for enumeration '_MV_CAM_GAIN_MODE_'
_MV_CAM_GAIN_MODE_ = c_int # enum
MV_CAM_GAIN_MODE = _MV_CAM_GAIN_MODE_
# values for enumeration '_MV_CAM_EXPOSURE_MODE_'
_MV_CAM_EXPOSURE_MODE_ = c_int # enum
MV_CAM_EXPOSURE_MODE = _MV_CAM_EXPOSURE_MODE_
# values for enumeration '_MV_CAM_EXPOSURE_AUTO_MODE_'
_MV_CAM_EXPOSURE_AUTO_MODE_ = c_int # enum
MV_CAM_EXPOSURE_AUTO_MODE = _MV_CAM_EXPOSURE_AUTO_MODE_
# values for enumeration '_MV_CAM_TRIGGER_MODE_'
_MV_CAM_TRIGGER_MODE_ = c_int # enum
MV_CAM_TRIGGER_MODE = _MV_CAM_TRIGGER_MODE_
# values for enumeration '_MV_CAM_GAMMA_SELECTOR_'
_MV_CAM_GAMMA_SELECTOR_ = c_int # enum
MV_CAM_GAMMA_SELECTOR = _MV_CAM_GAMMA_SELECTOR_
# values for enumeration '_MV_CAM_BALANCEWHITE_AUTO_'
_MV_CAM_BALANCEWHITE_AUTO_ = c_int # enum
MV_CAM_BALANCEWHITE_AUTO = _MV_CAM_BALANCEWHITE_AUTO_
# values for enumeration '_MV_CAM_TRIGGER_SOURCE_'
_MV_CAM_TRIGGER_SOURCE_ = c_int # enum
MV_CAM_TRIGGER_SOURCE = _MV_CAM_TRIGGER_SOURCE_
# \~chinese Event事件回调信息\ \~english Event callback infomation
class _MV_EVENT_OUT_INFO_(Structure):
pass
_MV_EVENT_OUT_INFO_._fields_ = [
('EventName', c_char * MAX_EVENT_NAME_SIZE), # < \~chinese Event名称 \~english Event name
('nEventID', c_ushort), # < \~chinese Event号 \~english Event ID
('nStreamChannel', c_ushort), # < \~chinese 流通道序号 \~english Circulation number
('nBlockIdHigh', c_uint), # < \~chinese 帧号高位 \~english BlockId high
('nBlockIdLow', c_uint), # < \~chinese 帧号低位 \~english BlockId low
('nTimestampHigh', c_uint), # < \~chinese 时间戳高位 \~english Timestramp high
('nTimestampLow', c_uint), # < \~chinese 时间戳低位 \~english Timestramp low
('pEventData', c_void_p), # < \~chinese Event数据 \~english Event data
('nEventDataSize', c_uint), # < \~chinese Event数据长度 \~english Event data len
('nReserved', c_uint * 16), # < \~chinese 保留字节 \~english Reserved bytes
]
MV_EVENT_OUT_INFO = _MV_EVENT_OUT_INFO_
# \~chinese 文件存取 \~english File Access
class _MV_CC_FILE_ACCESS_T(Structure):
pass
_MV_CC_FILE_ACCESS_T._fields_ = [
('pUserFileName', STRING), # < \~chinese 用户文件名 \~english User file name
('pDevFileName', STRING), # < \~chinese 设备文件名 \~english Device file name
('nReserved', c_uint * 32), # < \~chinese 保留字节 \~english Reserved bytes
]
MV_CC_FILE_ACCESS = _MV_CC_FILE_ACCESS_T
# \~chinese 文件存取进度 \~english File Access Progress
class _MV_CC_FILE_ACCESS_PROGRESS_T(Structure):
pass
_MV_CC_FILE_ACCESS_PROGRESS_T._fields_ = [
('nCompleted', int64_t), # < \~chinese 已完成的长度 \~english Completed Length
('nTotal', int64_t), # < \~chinese 总长度 \~english Total Length
('nReserved', c_uint * 8), # < \~chinese 保留字节 \~english Reserved bytes
]
MV_CC_FILE_ACCESS_PROGRESS = _MV_CC_FILE_ACCESS_PROGRESS_T
# values for enumeration '_MV_GIGE_TRANSMISSION_TYPE_'
_MV_GIGE_TRANSMISSION_TYPE_ = c_int # enum
MV_GIGE_TRANSMISSION_TYPE = _MV_GIGE_TRANSMISSION_TYPE_
# 传输模式,可以为单播模式、组播模式等 \~english Transmission type
class _MV_TRANSMISSION_TYPE_T(Structure):
pass
_MV_TRANSMISSION_TYPE_T._fields_ = [
('enTransmissionType', MV_GIGE_TRANSMISSION_TYPE), # < \~chinese 传输模式 \~english Transmission type
('nDestIp', c_uint), # < \~chinese 目标IP,组播模式下有意义 \~english Destination IP
('nDestPort', c_ushort), # < \~chinese 目标Port,组播模式下有意义 \~english Destination port
('nReserved', c_uint * 32), # < \~chinese 保留字节 \~english Reserved bytes
]
MV_TRANSMISSION_TYPE = _MV_TRANSMISSION_TYPE_T
# \~chinese 动作命令信息 \~english Action Command
class _MV_ACTION_CMD_INFO_T(Structure):
pass
_MV_ACTION_CMD_INFO_T._fields_ = [
('nDeviceKey', c_uint), # < \~chinese 设备密钥 \~english Device key
('nGroupKey', c_uint), # < \~chinese 组键 \~english Group key
('nGroupMask', c_uint), # < \~chinese 组掩码 \~english Group mask
('bActionTimeEnable', c_uint), # < \~chinese 只有设置成1时Action Time才有效,非1时无效 \~english Action time enable
('nActionTime', int64_t), # < \~chinese 预定的时间,和主频有关 \~english Action time
('pBroadcastAddress', STRING), # < \~chinese 广播包地址 \~english Broadcast address
('nTimeOut', c_uint), # < \~chinese 等待ACK的超时时间,如果为0表示不需要ACK \~english Timeout
('nReserved', c_uint * 16), # < \~chinese 预留 \~english Reserved bytes
]
MV_ACTION_CMD_INFO = _MV_ACTION_CMD_INFO_T
# \~chinese 动作命令返回信息 \~english Action Command Result
class _MV_ACTION_CMD_RESULT_T(Structure):
pass
_MV_ACTION_CMD_RESULT_T._fields_ = [
('strDeviceAddress', c_ubyte * 16), # < \~chinese IP配置选项 \~english IP address of the device
#1.0x0000:success.
#2.0x8001:Command is not supported by the device.
#3.0x8013:The device is not synchronized to a master clock to be used as time reference.
#4.0x8015:A device queue or packet data has overflowed.
#5.0x8016:The requested scheduled action command was requested at a time that is already past.
('nStatus', c_int), # < \~chinese 状态码 \~english status
('nReserved', c_uint * 4), # < \~chinese 预留 \~english Reserved bytes
]
MV_ACTION_CMD_RESULT = _MV_ACTION_CMD_RESULT_T
# \~chinese 动作命令返回信息列表 \~english Action Command Result List
class _MV_ACTION_CMD_RESULT_LIST_T(Structure):
pass
_MV_ACTION_CMD_RESULT_LIST_T._fields_ = [
('nNumResults', c_uint), # < \~chinese 返回值个数 \~english Num Results
('pResults', POINTER(MV_ACTION_CMD_RESULT)), # < \~chinese 动作命令返回信息 \~english action command result list
]
MV_ACTION_CMD_RESULT_LIST = _MV_ACTION_CMD_RESULT_LIST_T
# values for enumeration 'MV_XML_InterfaceType'
MV_XML_InterfaceType = c_int # enum
# values for enumeration 'MV_XML_AccessMode'
MV_XML_AccessMode = c_int # enum
# \~chinese 枚举类型值 \~english Enumeration Value
class _MVCC_ENUMVALUE_T(Structure):
pass
_MVCC_ENUMVALUE_T._fields_ = [
('nCurValue', c_uint), # < \~chinese 当前值 \~english Current Value
('nSupportedNum', c_uint), # < \~chinese 数据的有效数据个数 \~english Number of valid data
('nSupportValue', c_uint * MV_MAX_XML_SYMBOLIC_NUM), # < \~chinese 支持值列表 \~english Support value list
('nReserved', c_uint * 4), # < \~chinese 预留 \~english Reserved bytes
]
MVCC_ENUMVALUE = _MVCC_ENUMVALUE_T
# \~chinese Int类型值 \~english Int Value
class _MVCC_INTVALUE_T(Structure):
pass
_MVCC_INTVALUE_T._fields_ = [
('nCurValue', c_uint), # < \~chinese 当前值 \~english Current Value
('nMax', c_uint), # < \~chinese 最大值 \~english Max Value
('nMin', c_uint), # < \~chinese 最小值 \~english Min Value
('nInc', c_uint), # < \~chinese 步径 \~english Step size
('nReserved', c_uint * 4), # < \~chinese 预留 \~english Reserved bytes
]
MVCC_INTVALUE = _MVCC_INTVALUE_T
# \~chinese Int类型值Ex \~english Int Value Ex
class _MVCC_INTVALUE_EX_T(Structure):
pass
_MVCC_INTVALUE_EX_T._fields_ = [
('nCurValue', int64_t), # < \~chinese 当前值 \~english Current Value
('nMax', int64_t), # < \~chinese 最大值 \~english Max Value
('nMin', int64_t), # < \~chinese 最小值 \~english Min Value
('nInc', int64_t), # < \~chinese 步径 \~english Step size
('nReserved', c_uint * 16), # < \~chinese 预留 \~english Reserved bytes
]
MVCC_INTVALUE_EX = _MVCC_INTVALUE_EX_T
# \~chinese Float类型值 \~english Float Value
class _MVCC_FLOATVALUE_T(Structure):
pass
_MVCC_FLOATVALUE_T._fields_ = [
('fCurValue', c_float), # < \~chinese 当前值 \~english Current Value
('fMax', c_float), # < \~chinese 最大值 \~english Max Value
('fMin', c_float), # < \~chinese 最小值 \~english Min Value
('nReserved', c_uint * 4), # < \~chinese 预留 \~english Reserved bytes
]
MVCC_FLOATVALUE = _MVCC_FLOATVALUE_T
# \~chinese String类型值 \~english String Value
class _MVCC_STRINGVALUE_T(Structure):
pass
_MVCC_STRINGVALUE_T._fields_ = [
('chCurValue', c_char * 256), # < \~chinese 当前值 \~english Current Value
('nMaxLength', int64_t), # < \~chinese 最大长度 \~english Max length
('nReserved', c_uint * 2), # < \~chinese 预留 \~english Reserved bytes
]
MVCC_STRINGVALUE = _MVCC_STRINGVALUE_T
__all__ = ['_MV_ALL_MATCH_INFO_', 'MV_CC_FILE_ACCESS_PROGRESS',
'N19_MV_CC_DEVICE_INFO_3DOT_0E', 'MV_FRAME_OUT',
'MV_CAM_GAIN_MODE',
'MV_ALL_MATCH_INFO',
'MV_GIGE_TRANSTYPE_UNICAST_WITHOUT_RECV',
'MV_TRIGGER_SOURCE_LINE0', 'MV_PointCloudFile_Undefined',
'MV_TRIGGER_SOURCE_LINE2', 'MV_TRIGGER_SOURCE_LINE3',
'AM_CycleDetect',
'MV_GrabStrategy_UpcomingImage', 'IFT_IFloat',
'MV_EVENT_OUT_INFO', 'MV_TRANSMISSION_TYPE',
'uint_fast16_t', 'MV_CHUNK_DATA_CONTENT','MV_ACTION_CMD_RESULT',
'MV_CC_INPUT_FRAME_INFO',
'_MV_ACTION_CMD_RESULT_T',
'AM_RO', 'IFT_IPort', 'uint_least16_t',
'_MV_FRAME_OUT_INFO_EX_', '_MV_TRANSMISSION_TYPE_T',
'MV_SAVE_IMAGE_PARAM_EX', 'AM_RW', 'MV_XML_InterfaceType',
'int32_t', '_MV_ACTION_CMD_INFO_T', 'intptr_t',
'uint_least64_t', '_MV_NETTRANS_INFO_',
'_MV_CAM_TRIGGER_MODE_', 'int_least32_t',
'MV_GIGE_TRANSTYPE_SUBNETBROADCAST',
'MV_SAVE_POINT_CLOUD_FILE_TYPE',
'MV_ACTION_CMD_RESULT_LIST',
'MV_BALANCEWHITE_AUTO_CONTINUOUS',
'_MV_CHUNK_DATA_CONTENT_', 'MV_FormatType_AVI',
'_MV_PIXEL_CONVERT_PARAM_T_',
'MV_GENTL_IF_INFO',
'MV_ACQ_MODE_SINGLE',
'MV_TRIGGER_MODE_ON',
'int_least16_t', 'N22_MV_FRAME_OUT_INFO_EX_3DOT_1E',
'MV_GIGE_TRANSTYPE_LIMITEDBROADCAST', 'int_fast32_t',
'_MV_CAM_GAIN_MODE_',
'MV_RECORD_FORMAT_TYPE', 'MV_CC_DEVICE_INFO',
'IFT_ICommand', '_MV_RECORD_FORMAT_TYPE_',
'_MV_CAM_ACQUISITION_MODE_',
'_MVCC_STRINGVALUE_T',
'MV_GIGE_TRANSTYPE_MULTICAST_WITHOUT_RECV',
'_MV_MATCH_INFO_NET_DETECT_', 'MVCC_INTVALUE',
'MV_PointCloudFile_OBJ', '_MV_GIGE_TRANSMISSION_TYPE_',
'_MV_CC_RECORD_PARAM_T_',
'_MV_GENTL_IF_INFO_', 'MV_EXPOSURE_MODE_TIMED', 'intmax_t',
'int16_t',
'MV_DISPLAY_FRAME_INFO', '_MV_CC_FILE_ACCESS_PROGRESS_T',
'_MV_GRAB_STRATEGY_', '_MV_SAVE_IMG_TO_FILE_PARAM_',
'int_fast64_t',
'MV_XML_AccessMode',
'MV_GAIN_MODE_ONCE', 'IFT_IInteger',
'MV_CAM_BALANCEWHITE_AUTO', 'int_least8_t',
'MV_PointCloudFile_CSV', 'IFT_IBase',
'MV_TRIGGER_MODE_OFF', 'MV_Image_Bmp',
'_MV_GENTL_DEV_INFO_', 'MV_CC_FILE_ACCESS',
'_MV_CAM_EXPOSURE_AUTO_MODE_',
'uint_least8_t',
'MV_ACTION_CMD_INFO',
'_MV_CC_INPUT_FRAME_INFO_T_',
'MV_GENTL_DEV_INFO_LIST', '_MV_CAM_TRIGGER_SOURCE_',
'MV_GRAB_STRATEGY',
'IFT_IEnumeration', 'uint64_t', 'uint8_t',
'_MV_GENTL_DEV_INFO_LIST_',
'MV_CAM_GAMMA_SELECTOR',
'MV_CamL_DEV_INFO', 'MV_GENTL_IF_INFO_LIST',
'MV_CAM_TRIGGER_MODE', 'MV_GIGE_TRANSTYPE_MULTICAST',
'uint16_t', 'uint_fast8_t',
'_MV_ACTION_CMD_RESULT_LIST_T',
'_MV_MATCH_INFO_USB_DETECT_',
'_MVCC_ENUMVALUE_T',
'MV_SAVE_POINT_CLOUD_PARAM', '_MV_CC_DEVICE_INFO_',
'IFT_IBoolean',
'MV_MATCH_INFO_USB_DETECT', 'MV_PointCloudFile_PLY',
'MVCC_ENUMVALUE',
'IFT_IString',
'MV_ACQ_MODE_CONTINUOUS',
'MV_TRIGGER_SOURCE_FrequencyConverter',
'MV_TRIGGER_SOURCE_COUNTER0',
'MV_GAIN_MODE_OFF', '_MV_CC_DEVICE_INFO_LIST_',
'MV_GIGE_DEVICE_INFO', '_MV_SAVE_IMAGE_PARAM_T_EX_',
'AM_NA', 'uint_least32_t',
'MV_CC_PIXEL_CONVERT_PARAM','AM_NI',
'_MVCC_INTVALUE_EX_T', 'uintptr_t', 'MV_Image_Tif',
'MVCC_FLOATVALUE', 'MV_GIGE_TRANSTYPE_CAMERADEFINED',
'_MV_GENTL_IF_INFO_LIST_', 'MV_NETTRANS_INFO',
'IFT_IRegister', 'MV_GIGE_TRANSMISSION_TYPE',
'MV_EXPOSURE_AUTO_MODE_ONCE', 'MV_GIGE_TRANSTYPE_UNICAST',
'int8_t', '_MV_GIGE_DEVICE_INFO_', 'IFT_IValue', 'AM_WO',
'int_fast8_t',
'MV_GAMMA_SELECTOR_SRGB','int_least64_t',
'MV_GrabStrategy_LatestImagesOnly',
'MV_EXPOSURE_AUTO_MODE_OFF', 'MV_CAM_EXPOSURE_AUTO_MODE',
'MV_EXPOSURE_AUTO_MODE_CONTINUOUS',
'MV_CAM_ACQUISITION_MODE', 'AM_Undefined',
'MV_MATCH_INFO_NET_DETECT',
'_MV_CC_FILE_ACCESS_T',
'_MV_DISPLAY_FRAME_INFO_','MV_GrabStrategy_OneByOne',
'MV_TRIGGER_SOURCE_SOFTWARE', 'MV_FormatType_Undefined',
'MV_BALANCEWHITE_AUTO_ONCE',
'uintmax_t', 'int_fast16_t',
'_MV_CAM_EXPOSURE_MODE_','MV_BALANCEWHITE_AUTO_OFF',
'int64_t', 'MV_Image_Undefined', 'MV_GAIN_MODE_CONTINUOUS',
'uint_fast32_t',
'MV_CAM_TRIGGER_SOURCE', 'MV_GrabStrategy_LatestImages',
'MV_Image_Png',
'MV_Image_Jpeg', '_MV_CamL_DEV_INFO_',
'_MVCC_FLOATVALUE_T',
'MV_FRAME_OUT_INFO_EX', '_MV_SAVE_POINT_CLOUD_PARAM_',
'_MV_CAM_BALANCEWHITE_AUTO_', 'MV_CC_RECORD_PARAM',
'_MV_USB3_DEVICE_INFO_',
'MVCC_INTVALUE_EX', 'MV_EXPOSURE_MODE_TRIGGER_WIDTH',
'MV_GIGE_TRANSTYPE_UNICAST_DEFINED_PORT',
'MV_SAVE_IAMGE_TYPE','MV_GENTL_DEV_INFO',
'MV_CAM_EXPOSURE_MODE',
'MVCC_STRINGVALUE',
'MvGvspPixelType',
'MV_CC_DEVICE_INFO_LIST',
'MV_TRIGGER_SOURCE_LINE1',
'uint_fast64_t','_MVCC_INTVALUE_T',
'IFT_ICategory',
'MV_SAVE_IMG_TO_FILE_PARAM', '_MV_FRAME_OUT_',
'MV_GAMMA_SELECTOR_USER',
'uint32_t', '_MV_CAM_GAMMA_SELECTOR_', 'MV_ACQ_MODE_MUTLI',
'MV_USB3_DEVICE_INFO', '_MV_EVENT_OUT_INFO_']
# -- coding: utf-8 --
import sys
import copy
import ctypes
from ctypes import *
from PixelType_header import *
from CameraParams_const import *
from CameraParams_header import *
from MvErrorDefine_const import *
# MvCamCtrldll = WinDLL("C:\Program Files (x86)\Common Files\MVS\Runtime\Win64_x64\MvCameraControl.dll")
MvCamCtrldll = WinDLL("MvCameraControl.dll")
# 用于回调函数传入相机实例
class _MV_PY_OBJECT_(Structure):
pass
_MV_PY_OBJECT_._fields_ = [
('PyObject', py_object),
]
MV_PY_OBJECT = _MV_PY_OBJECT_
class MvCamera():
def __init__(self):
self._handle = c_void_p() # 记录当前连接设备的句柄
self.handle = pointer(self._handle) # 创建句柄指针
#####设备的基本指令和操作#####
# ch:获取SDK版本号 | en:Get SDK Version
@staticmethod
def MV_CC_GetSDKVersion():
MvCamCtrldll.MV_CC_GetSDKVersion.restype = c_uint
# C原型:unsigned int __stdcall MV_CC_GetSDKVersion();
return MvCamCtrldll.MV_CC_GetSDKVersion()
# ch:获取支持的传输层 | en:Get supported Transport Layer
@staticmethod
def MV_CC_EnumerateTls():
MvCamCtrldll.MV_CC_EnumerateTls.restype = c_uint
# C原型:int __stdcall MV_CC_EnumerateTls();
return MvCamCtrldll.MV_CC_EnumerateTls()
# ch:枚举设备 | en:Enumerate Device
@staticmethod
def MV_CC_EnumDevices(nTLayerType, stDevList):
MvCamCtrldll.MV_CC_EnumDevices.argtype = (c_uint, c_void_p)
MvCamCtrldll.MV_CC_EnumDevices.restype = c_uint
# C原型:int __stdcall MV_CC_EnumDevices(unsigned int nTLayerType, MV_CC_DEVICE_INFO_LIST* pstDevList)
return MvCamCtrldll.MV_CC_EnumDevices(c_uint(nTLayerType), byref(stDevList))
# ch:根据厂商名字枚举设备 | en:Enumerate device according to manufacture name
@staticmethod
def MV_CC_EnumDevicesEx(nTLayerType, stDevList, strManufacturerName):
MvCamCtrldll.MV_CC_EnumDevicesEx.argtype = (c_uint, c_void_p, c_void_p)
MvCamCtrldll.MV_CC_EnumDevicesEx.restype = c_uint
# C原型:int __stdcall MV_CC_EnumDevicesEx(IN unsigned int nTLayerType, IN OUT MV_CC_DEVICE_INFO_LIST* pstDevList, IN const char* strManufacturerName);
return MvCamCtrldll.MV_CC_EnumDevicesEx(c_uint(nTLayerType), byref(stDevList), strManufacturerName.encode('ascii'))
# ch:设备是否可达 | en:Is the device accessible
@staticmethod
def MV_CC_IsDeviceAccessible(stDevInfo, nAccessMode):
MvCamCtrldll.MV_CC_IsDeviceAccessible.argtype = (c_void_p, c_uint)
MvCamCtrldll.MV_CC_IsDeviceAccessible.restype = c_uint
# C原型:bool __stdcall MV_CC_IsDeviceAccessible(IN MV_CC_DEVICE_INFO* pstDevInfo, IN unsigned int nAccessMode);
return MvCamCtrldll.MV_CC_IsDeviceAccessible(byref(stDevInfo), nAccessMode)
# ch:创建设备句柄 | en:Create Device Handle
def MV_CC_CreateHandle(self, stDevInfo):
MvCamCtrldll.MV_CC_DestroyHandle.argtype = c_void_p
MvCamCtrldll.MV_CC_DestroyHandle.restype = c_uint
MvCamCtrldll.MV_CC_DestroyHandle(self.handle)
MvCamCtrldll.MV_CC_CreateHandle.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CC_CreateHandle.restype = c_uint
# C原型:int MV_CC_CreateHandle(void ** handle, MV_CC_DEVICE_INFO* pstDevInfo)
return MvCamCtrldll.MV_CC_CreateHandle(byref(self.handle), byref(stDevInfo))
# ch:创建句柄(不生成日志) | en:Create Device Handle without log
def MV_CC_CreateHandleWithoutLog(self, stDevInfo):
MvCamCtrldll.MV_CC_DestroyHandle.argtype = c_void_p
MvCamCtrldll.MV_CC_DestroyHandle.restype = c_uint
MvCamCtrldll.MV_CC_DestroyHandle(self.handle)
MvCamCtrldll.MV_CC_CreateHandleWithoutLog.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CC_CreateHandleWithoutLog.restype = c_uint
# C原型:int MV_CC_CreateHandleWithoutLog(void ** handle, MV_CC_DEVICE_INFO* pstDevInfo)
return MvCamCtrldll.MV_CC_CreateHandleWithoutLog(byref(self.handle), byref(stDevInfo))
# ch:销毁设备句柄 | en:Destroy Device Handle
def MV_CC_DestroyHandle(self):
MvCamCtrldll.MV_CC_DestroyHandle.argtype = c_void_p
MvCamCtrldll.MV_CC_DestroyHandle.restype = c_uint
return MvCamCtrldll.MV_CC_DestroyHandle(self.handle)
# ch:打开设备 | en:Open Device
def MV_CC_OpenDevice(self, nAccessMode=MV_ACCESS_Exclusive, nSwitchoverKey=0):
MvCamCtrldll.MV_CC_OpenDevice.argtype = (c_void_p, c_uint32, c_uint16)
MvCamCtrldll.MV_CC_OpenDevice.restype = c_uint
# C原型:int MV_CC_OpenDevice(void* handle, unsigned int nAccessMode, unsigned short nSwitchoverKey)
return MvCamCtrldll.MV_CC_OpenDevice(self.handle, nAccessMode, nSwitchoverKey)
# ch:关闭设备 | en:Close Device
def MV_CC_CloseDevice(self):
MvCamCtrldll.MV_CC_CloseDevice.argtype = c_void_p
MvCamCtrldll.MV_CC_CloseDevice.restype = c_uint
return MvCamCtrldll.MV_CC_CloseDevice(self.handle)
# ch:判断设备是否处于连接状态 | en: Is The Device Connected
def MV_CC_IsDeviceConnected(self):
MvCamCtrldll.MV_CC_IsDeviceConnected.argtype = (c_void_p)
MvCamCtrldll.MV_CC_IsDeviceConnected.restype = c_bool
# C原型:bool __stdcall MV_CC_IsDeviceConnected(IN void* handle);
return MvCamCtrldll.MV_CC_IsDeviceConnected(self.handle)
# ch:注册图像数据回调 | en:Register the image callback function
def MV_CC_RegisterImageCallBackEx(self, CallBackFun, pUser):
MvCamCtrldll.MV_CC_RegisterImageCallBackEx.argtype = (c_void_p, c_void_p, c_void_p)
MvCamCtrldll.MV_CC_RegisterImageCallBackEx.restype = c_uint
# C原型:int MV_CC_RegisterImageCallBackEx(void* handle, void(* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser),void* pUser);
return MvCamCtrldll.MV_CC_RegisterImageCallBackEx(self.handle, CallBackFun, pUser)
# ch:注册取流回调 | en:Register the image callback function
def MV_CC_RegisterImageCallBackForRGB(self, CallBackFun, pUser):
MvCamCtrldll.MV_CC_RegisterImageCallBackForRGB.argtype = (c_void_p, c_void_p, c_void_p)
MvCamCtrldll.MV_CC_RegisterImageCallBackForRGB.restype = c_uint
# C原型:int MV_CC_RegisterImageCallBackForRGB(void* handle, void(* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser),void* pUser);
return MvCamCtrldll.MV_CC_RegisterImageCallBackForRGB(self.handle, CallBackFun, pUser)
# ch:注册取流回调 | en:Register the image callback function
def MV_CC_RegisterImageCallBackForBGR(self, CallBackFun, pUser):
MvCamCtrldll.MV_CC_RegisterImageCallBackForBGR.argtype = (c_void_p, c_void_p, c_void_p)
MvCamCtrldll.MV_CC_RegisterImageCallBackForBGR.restype = c_uint
# C原型:int MV_CC_RegisterImageCallBackForBGR(void* handle, void(* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser),void* pUser);
return MvCamCtrldll.MV_CC_RegisterImageCallBackForBGR(self.handle, CallBackFun, pUser)
# ch:开始取流 | en:Start Grabbing
def MV_CC_StartGrabbing(self):
MvCamCtrldll.MV_CC_StartGrabbing.argtype = c_void_p
MvCamCtrldll.MV_CC_StartGrabbing.restype = c_uint
return MvCamCtrldll.MV_CC_StartGrabbing(self.handle)
# ch:停止取流 | en:Stop Grabbing
def MV_CC_StopGrabbing(self):
MvCamCtrldll.MV_CC_StopGrabbing.argtype = c_void_p
MvCamCtrldll.MV_CC_StopGrabbing.restype = c_uint
return MvCamCtrldll.MV_CC_StopGrabbing(self.handle)
# ch:获取一帧RGB数据,此函数为查询式获取,每次调用查询内部缓存有无数据,有数据则获取数据,无数据返回错误码 | en:Get one frame of RGB data, this function is using query to get data query whether the internal cache has data, get data if there has, return error code if no data
def MV_CC_GetImageForRGB(self, pData, nDataSize, stFrameInfo, nMsec):
MvCamCtrldll.MV_CC_GetImageForRGB.argtype = (c_void_p, c_void_p, c_uint, c_void_p, c_uint)
MvCamCtrldll.MV_CC_GetImageForRGB.restype = c_uint
# C原型:int MV_CC_GetImageForRGB(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pstFrameInfo, int nMsec);
return MvCamCtrldll.MV_CC_GetImageForRGB(self.handle, pData, nDataSize, byref(stFrameInfo), nMsec)
# ch:获取一帧BGR数据,此函数为查询式获取,每次调用查询内部缓存有无数据,有数据则获取数据,无数据返回错误码 | en:Get one frame of BGR data, this function is using query to get data query whether the internal cache has data, get data if there has, return error code if no data
def MV_CC_GetImageForBGR(self, pData, nDataSize, stFrameInfo, nMsec):
MvCamCtrldll.MV_CC_GetImageForBGR.argtype = (c_void_p, c_void_p, c_uint, c_void_p, c_uint)
MvCamCtrldll.MV_CC_GetImageForBGR.restype = c_uint
# C原型:int MV_CC_GetImageForBGR(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pstFrameInfo, int nMsec);
return MvCamCtrldll.MV_CC_GetImageForBGR(self.handle, pData, nDataSize, byref(stFrameInfo), nMsec)
# ch:使用内部缓存获取一帧图片(与MV_CC_Display不能同时使用) | en:Get a frame of an image using an internal cache(Cannot be used together with the interface of MV_CC_Display)
def MV_CC_GetImageBuffer(self, stFrame, nMsec):
MvCamCtrldll.MV_CC_GetImageBuffer.argtype = (c_void_p, c_void_p, c_uint)
MvCamCtrldll.MV_CC_GetImageBuffer.restype = c_uint
# C原型:int MV_CC_GetImageBuffer(IN void* handle, OUT MV_FRAME_OUT* pstFrame, IN unsigned int nMsec);
return MvCamCtrldll.MV_CC_GetImageBuffer(self.handle, byref(stFrame), nMsec)
# ch:使用内部缓存获取一帧图片(与MV_CC_Display不能同时使用) | en:Get a frame of an image using an internal cache(Cannot be used together with the interface of MV_CC_Display)
def MV_CC_FreeImageBuffer(self, stFrame):
MvCamCtrldll.MV_CC_FreeImageBuffer.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CC_FreeImageBuffer.restype = c_uint
# C原型:int MV_CC_FreeImageBuffer(IN void* handle, IN MV_FRAME_OUT* pstFrame);
return MvCamCtrldll.MV_CC_FreeImageBuffer(self.handle, byref(stFrame))
# ch:采用超时机制获取一帧图片,SDK内部等待直到有数据时返回 | en:Timeout mechanism is used to get image, and the SDK waits inside until the data is returned
def MV_CC_GetOneFrameTimeout(self, pData, nDataSize, stFrameInfo, nMsec=1000):
MvCamCtrldll.MV_CC_GetOneFrameTimeout.argtype = (c_void_p, c_void_p, c_uint, c_void_p, c_uint)
MvCamCtrldll.MV_CC_GetOneFrameTimeout.restype = c_uint
# C原型:int MV_CC_GetOneFrameTimeout(void* handle, unsigned char * pData , unsigned int nDataSize, MV_FRAME_OUT_INFO_EX* pFrameInfo, unsigned int nMsec)
return MvCamCtrldll.MV_CC_GetOneFrameTimeout(self.handle, pData, nDataSize, byref(stFrameInfo), nMsec)
# ch:清除取流数据缓存 | en:if Image buffers has retrieved the data,Clear them
def MV_CC_ClearImageBuffer(self):
MvCamCtrldll.MV_CC_ClearImageBuffer.argtype = (c_void_p)
MvCamCtrldll.MV_CC_ClearImageBuffer.restype = c_uint
# C原型:int MV_CC_ClearImageBuffer(IN void* handle);
return MvCamCtrldll.MV_CC_ClearImageBuffer(self.handle)
# ch:显示一帧图像 | en:Get a frame of an image using an internal cache(Cannot be used together with the interface of MV_CC_Display)
def MV_CC_DisplayOneFrame(self, stDisplayInfo):
MvCamCtrldll.MV_CC_DisplayOneFrame.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CC_DisplayOneFrame.restype = c_uint
# C原型:int MV_CC_DisplayOneFrame(IN void* handle, IN MV_DISPLAY_FRAME_INFO* pstDisplayInfo);
return MvCamCtrldll.MV_CC_DisplayOneFrame(self.handle, byref(stDisplayInfo))
# ch:设置SDK内部图像缓存节点个数,大于等于1,在抓图前调用 | en:Set the number of the internal image cache nodes in SDK, Greater than or equal to 1, to be called before the capture
def MV_CC_SetImageNodeNum(self, nNum):
MvCamCtrldll.MV_CC_SetImageNodeNum.argtype = (c_void_p, c_uint)
MvCamCtrldll.MV_CC_SetImageNodeNum.restype = c_uint
# C原型:int MV_CC_SetImageNodeNum(IN void* handle, unsigned int nNum);
return MvCamCtrldll.MV_CC_SetImageNodeNum(self.handle, c_uint(nNum))
# ch:设置取流策略 | en:Set Grab Strategy
def MV_CC_SetGrabStrategy(self, enGrabStrategy):
MvCamCtrldll.MV_CC_SetGrabStrategy.argtype = (c_void_p, c_uint)
MvCamCtrldll.MV_CC_SetGrabStrategy.restype = c_uint
# C原型:int MV_CC_SetGrabStrategy(IN void* handle, IN MV_GRAB_STRATEGY enGrabStrategy);
return MvCamCtrldll.MV_CC_SetGrabStrategy(self.handle, c_uint(enGrabStrategy))
# ch:设置输出缓存个数(只有在MV_GrabStrategy_LatestImages策略下才有效,范围:1-ImageNodeNum) | en:Set The Size of Output Queue(Only work under the strategy of MV_GrabStrategy_LatestImages,rang:1-ImageNodeNum)
def MV_CC_SetOutputQueueSize(self, nOutputQueueSize):
MvCamCtrldll.MV_CC_SetOutputQueueSize.argtype = (c_void_p, c_uint)
MvCamCtrldll.MV_CC_SetOutputQueueSize.restype = c_uint
# C原型:int MV_CC_SetOutputQueueSize(IN void* handle, IN unsigned int nOutputQueueSize);
return MvCamCtrldll.MV_CC_SetOutputQueueSize(self.handle, nOutputQueueSize)
# ch:获取设备信息,取流之前调用 | en:Get device information
def MV_CC_GetDeviceInfo(self, stDevInfo):
MvCamCtrldll.MV_CC_GetDeviceInfo.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CC_GetDeviceInfo.restype = c_uint
# C原型:int MV_CC_GetDeviceInfo(IN void * handle, IN OUT MV_CC_DEVICE_INFO* pstDevInfo);
return MvCamCtrldll.MV_CC_GetDeviceInfo(self.handle, byref(stDevInfo))
# ch:获取各种类型的信息 | en:Get various type of information
def MV_CC_GetAllMatchInfo(self, stInfo):
MvCamCtrldll.MV_CC_GetAllMatchInfo.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CC_GetAllMatchInfo.restype = c_uint
# C原型:int MV_CC_GetAllMatchInfo(IN void* handle, IN OUT MV_ALL_MATCH_INFO* pstInfo);
return MvCamCtrldll.MV_CC_GetAllMatchInfo(self.handle, byref(stInfo))
#####设置和获取设备参数的万能接口#####
# ch:获取Integer属性值 | en:Get Integer value
def MV_CC_GetIntValueEx(self, strKey, stIntValue):
MvCamCtrldll.MV_CC_GetIntValueEx.argtype = (c_void_p, c_void_p, c_void_p)
MvCamCtrldll.MV_CC_GetIntValueEx.restype = c_uint
# C原型:int MV_CC_GetIntValueEx(IN void* handle,IN const char* strKey,OUT MVCC_INTVALUE_EX *pstIntValue);
return MvCamCtrldll.MV_CC_GetIntValueEx(self.handle, strKey.encode('ascii'), byref(stIntValue))
# ch:设置Integer型属性值 | en:Set Integer value
def MV_CC_SetIntValueEx(self, strKey, nValue):
MvCamCtrldll.MV_CC_SetIntValueEx.argtype = (c_void_p, c_void_p, c_uint)
MvCamCtrldll.MV_CC_SetIntValueEx.restype = c_uint
# C原型:int MV_CC_SetIntValueEx(IN void* handle,IN const char* strKey,IN int64_t nValue);
return MvCamCtrldll.MV_CC_SetIntValueEx(self.handle, strKey.encode('ascii'), c_uint(nValue))
# ch:获取Integer型属性值 | en:Get Integer value
def MV_CC_GetIntValue(self, strKey, stIntValue):
MvCamCtrldll.MV_CC_GetIntValue.argtype = (c_void_p, c_void_p, c_void_p)
MvCamCtrldll.MV_CC_GetIntValue.restype = c_uint
# C原型:int MV_CC_GetIntValue(void* handle,char* strKey,MVCC_INTVALUE *pIntValue)
return MvCamCtrldll.MV_CC_GetIntValue(self.handle, strKey.encode('ascii'), byref(stIntValue))
# ch:设置Integer型属性值 | en:Set Integer value
def MV_CC_SetIntValue(self, strKey, nValue):
MvCamCtrldll.MV_CC_SetIntValue.argtype = (c_void_p, c_void_p, c_uint32)
MvCamCtrldll.MV_CC_SetIntValue.restype = c_uint
# C原型:int MV_CC_SetIntValue(void* handle, char* strKey, unsigned int nValue)
return MvCamCtrldll.MV_CC_SetIntValue(self.handle, strKey.encode('ascii'), c_uint32(nValue))
# ch:获取Enum属性值 | en:Get Enum value
def MV_CC_GetEnumValue(self, strKey, stEnumValue):
MvCamCtrldll.MV_CC_GetEnumValue.argtype = (c_void_p, c_void_p, c_void_p)
MvCamCtrldll.MV_CC_GetEnumValue.restype = c_uint
# C原型:int MV_CC_GetEnumValue(void* handle,char* strKey,MVCC_ENUMVALUE *pEnumValue)
return MvCamCtrldll.MV_CC_GetEnumValue(self.handle, strKey.encode('ascii'), byref(stEnumValue))
# ch:设置Enum型属性值 | en:Set Enum value
def MV_CC_SetEnumValue(self, strKey, nValue):
MvCamCtrldll.MV_CC_SetEnumValue.argtype = (c_void_p, c_void_p, c_uint32)
MvCamCtrldll.MV_CC_SetEnumValue.restype = c_uint
# C原型:int MV_CC_SetEnumValue(void* handle,char* strKey,unsigned int nValue)
return MvCamCtrldll.MV_CC_SetEnumValue(self.handle, strKey.encode('ascii'), c_uint32(nValue))
# ch:设置Enum型属性值 | en:Set Enum value
def MV_CC_SetEnumValueByString(self, strKey, sValue):
MvCamCtrldll.MV_CC_SetEnumValueByString.argtype = (c_void_p, c_void_p, c_void_p)
MvCamCtrldll.MV_CC_SetEnumValueByString.restype = c_uint
# C原型:int MV_CC_SetEnumValueByString(void* handle,char* strKey,char* sValue)
return MvCamCtrldll.MV_CC_SetEnumValueByString(self.handle, strKey.encode('ascii'), sValue.encode('ascii'))
# ch:获取Float型属性值 | en:Get Float value
def MV_CC_GetFloatValue(self, strKey, stFloatValue):
MvCamCtrldll.MV_CC_GetFloatValue.argtype = (c_void_p, c_void_p, c_void_p)
MvCamCtrldll.MV_CC_GetFloatValue.restype = c_uint
# C原型:int MV_CC_GetFloatValue(void* handle,char* strKey,MVCC_FLOATVALUE *pFloatValue)
return MvCamCtrldll.MV_CC_GetFloatValue(self.handle, strKey.encode('ascii'), byref(stFloatValue))
# ch:设置Float型属性值 | en:Set float value
def MV_CC_SetFloatValue(self, strKey, fValue):
MvCamCtrldll.MV_CC_SetFloatValue.argtype = (c_void_p, c_void_p, c_float)
MvCamCtrldll.MV_CC_SetFloatValue.restype = c_uint
# C原型:int MV_CC_SetFloatValue(void* handle,char* strKey,float fValue)
return MvCamCtrldll.MV_CC_SetFloatValue(self.handle, strKey.encode('ascii'), c_float(fValue))
# ch:获取Boolean型属性值 | en:Get Boolean value
def MV_CC_GetBoolValue(self, strKey, BoolValue):
MvCamCtrldll.MV_CC_GetBoolValue.argtype = (c_void_p, c_void_p, c_void_p)
MvCamCtrldll.MV_CC_GetBoolValue.restype = c_uint
# C原型:int MV_CC_GetBoolValue(void* handle,char* strKey,bool *pBoolValue)
return MvCamCtrldll.MV_CC_GetBoolValue(self.handle, strKey.encode('ascii'), byref(BoolValue))
# ch:设置Boolean型属性值 | en:Set Boolean value
def MV_CC_SetBoolValue(self, strKey, bValue):
MvCamCtrldll.MV_CC_SetBoolValue.argtype = (c_void_p, c_void_p, c_bool)
MvCamCtrldll.MV_CC_SetBoolValue.restype = c_uint
# C原型:int MV_CC_SetBoolValue(void* handle,char* strKey,bool bValue)
return MvCamCtrldll.MV_CC_SetBoolValue(self.handle, strKey.encode('ascii'), bValue)
# ch:获取String型属性值 | en:Get String value
def MV_CC_GetStringValue(self, strKey, StringValue):
MvCamCtrldll.MV_CC_GetStringValue.argtype = (c_void_p, c_void_p, c_void_p)
MvCamCtrldll.MV_CC_GetStringValue.restype = c_uint
# C原型:int MV_CC_GetStringValue(void* handle,char* strKey,MVCC_STRINGVALUE *pStringValue)
return MvCamCtrldll.MV_CC_GetStringValue(self.handle, strKey.encode('ascii'), byref(StringValue))
# ch:设置String型属性值 | en:Set String value
def MV_CC_SetStringValue(self, strKey, sValue):
MvCamCtrldll.MV_CC_SetStringValue.argtype = (c_void_p, c_void_p, c_void_p)
MvCamCtrldll.MV_CC_SetStringValue.restype = c_uint
# C原型:int MV_CC_SetStringValue(void* handle,char* strKey,char * sValue)
return MvCamCtrldll.MV_CC_SetStringValue(self.handle, strKey.encode('ascii'), sValue.encode('ascii'))
# ch:设置Command型属性值 | en:Send Command
def MV_CC_SetCommandValue(self, strKey):
MvCamCtrldll.MV_CC_SetCommandValue.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CC_SetCommandValue.restype = c_uint
# C原型:int MV_CC_SetCommandValue(void* handle,char* strKey)
return MvCamCtrldll.MV_CC_SetCommandValue(self.handle, strKey.encode('ascii'))
# ch:清除GenICam节点缓存 | en:Invalidate GenICam Nodes
def MV_CC_InvalidateNodes(self):
MvCamCtrldll.MV_CC_InvalidateNodes.argtype = (c_void_p)
MvCamCtrldll.MV_CC_InvalidateNodes.restype = c_uint
# C原型:int MV_CC_InvalidateNodes(IN void* handle);
return MvCamCtrldll.MV_CC_InvalidateNodes(self.handle)
#####寄存器读写 和异常、事件回调#####
# ch:读内存 | en:Read Memory
def MV_CC_ReadMemory(self, pBuffer, nAddress, nLength):
MvCamCtrldll.MV_CC_ReadMemory.argtype = (c_void_p, c_void_p, c_uint, c_uint)
MvCamCtrldll.MV_CC_ReadMemory.restype = c_uint
# C原型:int MV_CC_ReadMemory(IN void* handle , void *pBuffer, int64_t nAddress, int64_t nLength);
return MvCamCtrldll.MV_CC_ReadMemory(self.handle, pBuffer, c_uint(nAddress), nLength)
# ch:写内存 | en:Write Memory
def MV_CC_WriteMemory(self, pBuffer, nAddress, nLength):
MvCamCtrldll.MV_CC_WriteMemory.argtype = (c_void_p, c_void_p, c_uint, c_uint)
MvCamCtrldll.MV_CC_WriteMemory.restype = c_uint
# C原型:int MV_CC_WriteMemory(IN void* handle, const void *pBuffer, int64_t nAddress, int64_t nLength);
return MvCamCtrldll.MV_CC_WriteMemory(self.handle, pBuffer, c_uint(nAddress), nLength)
# ch:注册异常消息回调 | en:Register Exception Message CallBack, call after open device
def MV_CC_RegisterExceptionCallBack(self, ExceptionCallBackFun, pUser):
MvCamCtrldll.MV_CC_RegisterExceptionCallBack.argtype = (c_void_p, c_void_p, c_void_p)
MvCamCtrldll.MV_CC_RegisterExceptionCallBack.restype = c_uint
# C原型:int MV_CC_RegisterExceptionCallBack(void* handle, void(* cbException)(unsigned int nMsgType, void* pUser),void* pUser)
return MvCamCtrldll.MV_CC_RegisterExceptionCallBack(self.handle, ExceptionCallBackFun, pUser)
# ch:注册全部事件回调,在打开设备之后调用 | en:Register event callback, which is called after the device is opened
def MV_CC_RegisterAllEventCallBack(self, EventCallBackFun, pUser):
MvCamCtrldll.MV_CC_RegisterAllEventCallBack.argtype = (c_void_p, c_void_p, c_void_p)
MvCamCtrldll.MV_CC_RegisterAllEventCallBack.restype = c_uint
# C原型:int MV_CC_RegisterAllEventCallBack(void* handle, void(__stdcall* cbEvent)(MV_EVENT_OUT_INFO * pEventInfo, void* pUser), void* pUser);
return MvCamCtrldll.MV_CC_RegisterAllEventCallBack(self.handle, EventCallBackFun, pUser)
# ch:注册单个事件回调,在打开设备之后调用 | en:Register single event callback, which is called after the device is opened
def MV_CC_RegisterEventCallBackEx(self, pEventName, EventCallBackFun, pUser):
MvCamCtrldll.MV_CC_RegisterEventCallBackEx.argtype = (c_void_p, c_void_p, c_void_p, c_void_p)
MvCamCtrldll.MV_CC_RegisterEventCallBackEx.restype = c_uint
# C原型:int MV_CC_RegisterEventCallBackEx(void* handle, char* pEventName,void(* cbEvent)(MV_EVENT_OUT_INFO * pEventInfo, void* pUser),void* pUser)
return MvCamCtrldll.MV_CC_RegisterEventCallBackEx(self.handle, pEventName.encode('ascii'), EventCallBackFun, pUser)
#####GigEVision 设备独有的接口#####
# ch:强制修改IP | en:Force IP
def MV_GIGE_ForceIpEx(self, nIP, nSubNetMask, nDefaultGateWay):
MvCamCtrldll.MV_GIGE_ForceIpEx.argtype = (c_void_p, c_uint, c_uint, c_uint)
MvCamCtrldll.MV_GIGE_ForceIpEx.restype = c_uint
# C原型:int MV_GIGE_ForceIpEx(void* handle, unsigned int nIP, unsigned int nSubNetMask, unsigned int nDefaultGateWay)
return MvCamCtrldll.MV_GIGE_ForceIpEx(self.handle, c_uint(nIP), c_uint(nSubNetMask), c_uint(nDefaultGateWay))
# ch:配置IP方式 | en: IP configuration method
def MV_GIGE_SetIpConfig(self, nType):
MvCamCtrldll.MV_GIGE_SetIpConfig.argtype = (c_void_p, c_uint)
MvCamCtrldll.MV_GIGE_SetIpConfig.restype = c_uint
# C原型:int MV_GIGE_SetIpConfig(void* handle, unsigned int nType)
return MvCamCtrldll.MV_GIGE_SetIpConfig(self.handle, c_uint(nType))
# ch:设置仅使用某种模式,type: MV_NET_TRANS_x,不设置时,默认优先使用driver | en: Set to use only one mode,type: MV_NET_TRANS_x. When do not set, priority is to use driver by default
def MV_GIGE_SetNetTransMode(self, nType):
MvCamCtrldll.MV_GIGE_SetNetTransMode.argtype = (c_void_p, c_uint)
MvCamCtrldll.MV_GIGE_SetNetTransMode.restype = c_uint
# C原型:int MV_GIGE_SetNetTransMode(IN void* handle, unsigned int nType);
return MvCamCtrldll.MV_GIGE_SetNetTransMode(self.handle, c_uint(nType))
# ch:获取网络传输信息 | en: Get net transmission information
def MV_GIGE_GetNetTransInfo(self, pstInfo):
MvCamCtrldll.MV_GIGE_GetNetTransInfo.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_GIGE_GetNetTransInfo.restype = c_uint
# C原型:int MV_GIGE_GetNetTransInfo(IN void* handle, MV_NETTRANS_INFO* pstInfo);
return MvCamCtrldll.MV_GIGE_GetNetTransInfo(self.handle, byref(pstInfo))
# ch:设置GVCP命令超时时间| en: Set GVCP cammand timeout
def MV_GIGE_SetGvcpTimeout(self, nMillisec):
MvCamCtrldll.MV_GIGE_SetGvcpTimeout.argtype = (c_void_p, c_uint)
MvCamCtrldll.MV_GIGE_SetGvcpTimeout.restype = c_uint
# C原型:int MV_GIGE_SetGvcpTimeout(void* handle, unsigned int nMillisec);
return MvCamCtrldll.MV_GIGE_SetGvcpTimeout(self.handle, c_uint(nMillisec))
# ch:获取GVCP命令超时时间 | en: Get GVCP cammand timeout
def MV_GIGE_GetGvcpTimeout(self, pnMillisec):
MvCamCtrldll.MV_GIGE_GetGvcpTimeout.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_GIGE_GetGvcpTimeout.restype = c_uint
# C原型:int MV_GIGE_GetGvcpTimeout(IN void* handle, unsigned int* pnMillisec);
return MvCamCtrldll.MV_GIGE_GetGvcpTimeout(self.handle, byref(pnMillisec))
# ch:设置重传GVCP命令次数| en: Set the number of retry GVCP cammand
def MV_GIGE_SetRetryGvcpTimes(self, nRetryGvcpTimes):
MvCamCtrldll.MV_GIGE_SetRetryGvcpTimes.argtype = (c_void_p, c_uint)
MvCamCtrldll.MV_GIGE_SetRetryGvcpTimes.restype = c_uint
# C原型:int MV_GIGE_SetRetryGvcpTimes(IN void* handle, unsigned int nRetryGvcpTimes);
return MvCamCtrldll.MV_GIGE_SetRetryGvcpTimes(self.handle, c_uint(nRetryGvcpTimes))
# ch:获取GVCP命令超时时间 | en: Get GVCP cammand timeout
def MV_GIGE_GetRetryGvcpTimes(self, pnRetryGvcpTimes):
MvCamCtrldll.MV_GIGE_GetRetryGvcpTimes.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_GIGE_GetRetryGvcpTimes.restype = c_uint
# C原型:int MV_GIGE_GetRetryGvcpTimes(IN void* handle, unsigned int* pnRetryGvcpTimes);
return MvCamCtrldll.MV_GIGE_GetRetryGvcpTimes(self.handle, byref(pnRetryGvcpTimes))
# ch:获取网络最佳包大小 | en:Get the optimal Packet Size, Only support GigE Camera
def MV_CC_GetOptimalPacketSize(self):
MvCamCtrldll.MV_CC_GetOptimalPacketSize.argtype = (c_void_p)
MvCamCtrldll.MV_CC_GetOptimalPacketSize.restype = c_uint
# C原型:int __stdcall MV_CC_GetOptimalPacketSize(void* handle);
return MvCamCtrldll.MV_CC_GetOptimalPacketSize(self.handle)
# ch:设置是否打开重发包支持,及重发包设置| en: Set whethe to enable resend, and set resend
def MV_GIGE_SetResend(self, bEnable,nMaxResendPercent=10,nResendTimeout=50):
MvCamCtrldll.MV_GIGE_SetResend.argtype = (c_void_p, c_uint, c_uint, c_uint)
MvCamCtrldll.MV_GIGE_SetResend.restype = c_uint
# C原型:int MV_GIGE_SetResend(void* handle, unsigned int bEnable, unsigned int nMaxResendPercent = 10, unsigned int nResendTimeout = 50);
return MvCamCtrldll.MV_GIGE_SetResend(self.handle, c_uint(bEnable), c_uint(nMaxResendPercent),c_uint(nResendTimeout))
# ch:设置传输模式,可以为单播模式、组播模式等 |en:Set transmission type,Unicast or Multicast
def MV_GIGE_SetTransmissionType(self, stTransmissionType):
MvCamCtrldll.MV_GIGE_SetTransmissionType.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_GIGE_SetTransmissionType.restype = c_uint
# C原型:int MV_GIGE_SetTransmissionType(void* handle, MV_TRANSMISSION_TYPE * pstTransmissionType)
return MvCamCtrldll.MV_GIGE_SetTransmissionType(self.handle, byref(stTransmissionType))
# ch:发出动作命令 | en:Issue Action Command
def MV_GIGE_IssueActionCommand(self, pstActionCmdInfo, pstActionCmdResults):
MvCamCtrldll.MV_GIGE_IssueActionCommand.argtype = (c_void_p, c_void_p, c_void_p)
MvCamCtrldll.MV_GIGE_IssueActionCommand.restype = c_uint
# C原型:int MV_GIGE_IssueActionCommand(IN MV_ACTION_CMD_INFO* pstActionCmdInfo, OUT MV_ACTION_CMD_RESULT_LIST* pstActionCmdResults);
return MvCamCtrldll.MV_GIGE_IssueActionCommand(byref(pstActionCmdInfo, byref(pstActionCmdResults)))
# ch:获取组播状态 | en:Get Multicast Status
def MV_GIGE_GetMulticastStatus(self, pstDevInfo, pbStatus):
MvCamCtrldll.MV_GIGE_GetMulticastStatus.argtype = (c_void_p, c_void_p, c_void_p)
MvCamCtrldll.MV_GIGE_GetMulticastStatus.restype = c_uint
# C原型:int MV_GIGE_GetMulticastStatus(IN MV_CC_DEVICE_INFO* pstDevInfo, OUT bool* pbStatus);
return MvCamCtrldll.MV_GIGE_GetMulticastStatus(byref(pstDevInfo, byref(pbStatus)))
#####CameraLink 设备独有的接口#####
# ch:设置设备波特率| en: Set device bauderate using one of the CL_BAUDRATE_XXXX value
def MV_CAML_SetDeviceBauderate(self, nBaudrate):
MvCamCtrldll.MV_CAML_SetDeviceBauderate.argtype = (c_void_p, c_uint)
MvCamCtrldll.MV_CAML_SetDeviceBauderate.restype = c_uint
# C原型:int MV_CAML_SetDeviceBauderate(IN void* handle, unsigned int nBaudrate);
return MvCamCtrldll.MV_CAML_SetDeviceBauderate(self.handle, c_uint(nBaudrate))
# ch:获取设备波特率 | en:Returns the current device bauderate, using one of the CL_BAUDRATE_XXXX value
def MV_CAML_GetDeviceBauderate(self, pnCurrentBaudrate):
MvCamCtrldll.MV_CAML_GetDeviceBauderate.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CAML_GetDeviceBauderate.restype = c_uint
# C原型:int MV_CAML_GetDeviceBauderate(IN void* handle,unsigned int* pnCurrentBaudrate);
return MvCamCtrldll.MV_CAML_GetDeviceBauderate(self.handle, byref(pnCurrentBaudrate))
# ch:获取设备与主机间连接支持的波特率 | en:Returns supported bauderates of the combined device and host interface
def MV_CAML_GetSupportBauderates(self, pnBaudrateAblity):
MvCamCtrldll.MV_CAML_GetSupportBauderates.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CAML_GetSupportBauderates.restype = c_uint
# C原型:int MV_CAML_GetSupportBauderates(IN void* handle,unsigned int* pnBaudrateAblity);
return MvCamCtrldll.MV_CAML_GetSupportBauderates(self.handle, byref(pnBaudrateAblity))
# ch:设置串口操作等待时长 | en: Sets the timeout for operations on the serial port
def MV_CAML_SetGenCPTimeOut(self, nMillisec):
MvCamCtrldll.MV_CAML_SetGenCPTimeOut.argtype = (c_void_p, c_uint)
MvCamCtrldll.MV_CAML_SetGenCPTimeOut.restype = c_uint
# C原型:int MV_CAML_SetGenCPTimeOut(IN void* handle, unsigned int nMillisec);
return MvCamCtrldll.MV_CAML_SetGenCPTimeOut(self.handle, c_uint(nMillisec))
#####U3V 设备独有的接口#####
# ch:设置U3V的传输包大小 | en: Set transfer size of U3V device
def MV_USB_SetTransferSize(self, nTransferSize):
MvCamCtrldll.MV_USB_SetTransferSize.argtype = (c_void_p, c_uint)
MvCamCtrldll.MV_USB_SetTransferSize.restype = c_uint
# C原型:int MV_USB_SetTransferSize(IN void* handle, unsigned int nTransferSize);
return MvCamCtrldll.MV_USB_SetTransferSize(self.handle, c_uint(nTransferSize))
# ch:获取U3V的传输包大小 | en:Get transfer size of U3V device
def MV_USB_GetTransferSize(self, pnTransferSize):
MvCamCtrldll.MV_USB_GetTransferSize.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_USB_GetTransferSize.restype = c_uint
# C原型:int MV_USB_GetTransferSize(IN void* handle, unsigned int* pnTransferSize);
return MvCamCtrldll.MV_USB_GetTransferSize(self.handle, byref(pnTransferSize))
# ch:设置U3V的传输通道个数 | en: Set transfer ways of U3V device
def MV_USB_SetTransferWays(self, nTransferWays):
MvCamCtrldll.MV_USB_SetTransferWays.argtype = (c_void_p, c_uint)
MvCamCtrldll.MV_USB_SetTransferWays.restype = c_uint
# C原型:int MV_USB_SetTransferWays(IN void* handle, unsigned int nTransferWays);
return MvCamCtrldll.MV_USB_SetTransferWays(self.handle, c_uint(nTransferWays))
# ch:获取U3V的传输通道个数 | en:Get transfer ways of U3V device
def MV_USB_GetTransferWays(self, pnTransferWays):
MvCamCtrldll.MV_USB_GetTransferWays.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_USB_GetTransferWays.restype = c_uint
# C原型:int MV_USB_GetTransferWays(IN void* handle, unsigned int* pnTransferWays);
return MvCamCtrldll.MV_USB_GetTransferWays(self.handle, byref(pnTransferWays))
#####GenTL相关接口,其它接口可以复用(部分接口不支持)#####
# ch:通过GenTL枚举Interfaces | en:Enumerate Interfaces with GenTL
def MV_CC_EnumInterfacesByGenTL(stIFList, strGenTLPath):
MvCamCtrldll.MV_CC_EnumInterfacesByGenTL.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CC_EnumInterfacesByGenTL.restype = c_uint
# C原型:int MV_CC_EnumInterfacesByGenTL(IN OUT MV_GENTL_IF_INFO_LIST* pstIFList, IN const char * strGenTLPath);
return MvCamCtrldll.MV_CC_EnumInterfacesByGenTL(byref(stIFList), strGenTLPath.encode('ascii'))
# ch:通过GenTL Interface枚举设备 | en:Enumerate Devices with GenTL interface
def MV_CC_EnumDevicesByGenTL(stIFInfo, stDevList):
MvCamCtrldll.MV_CC_EnumDevicesByGenTL.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CC_EnumDevicesByGenTL.restype = c_uint
# C原型:int MV_CC_EnumDevicesByGenTL(IN MV_GENTL_IF_INFO* pstIFInfo, IN OUT MV_GENTL_DEV_INFO_LIST* pstDevList);
return MvCamCtrldll.MV_CC_EnumDevicesByGenTL((stIFInfo), byref(stDevList))
# ch:通过GenTL设备信息创建设备句柄 | en:Create Device Handle with GenTL Device Info
def MV_CC_CreateHandleByGenTL(self, stDevInfo):
MvCamCtrldll.MV_CC_DestroyHandle.argtype = c_void_p
MvCamCtrldll.MV_CC_DestroyHandle.restype = c_uint
MvCamCtrldll.MV_CC_DestroyHandle(self.handle)
MvCamCtrldll.MV_CC_CreateHandleByGenTL.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CC_CreateHandleByGenTL.restype = c_uint
# C原型:int MV_CC_CreateHandleByGenTL(OUT void ** handle, IN const MV_GENTL_DEV_INFO* pstDevInfo);
return MvCamCtrldll.MV_CC_CreateHandleByGenTL(byref(self.handle), byref(stDevInfo))
#####XML解析树的生成#####
# ch:获取设备属性树XML | en:Get camera feature tree XML
def MV_XML_GetGenICamXML(self, pData, nDataSize, pnDataLen):
MvCamCtrldll.MV_XML_GetGenICamXML.argtype = (c_void_p, c_void_p, c_uint, c_void_p)
MvCamCtrldll.MV_XML_GetGenICamXML.restype = c_uint
# C原型:int MV_XML_GetGenICamXML(IN void* handle, IN OUT unsigned char* pData, IN unsigned int nDataSize, OUT unsigned int* pnDataLen);
return MvCamCtrldll.MV_XML_GetGenICamXML(self.handle, pData, c_uint(nDataSize), byref(pnDataLen))
# ch:获得当前节点的访问模式 | en:Get Access mode of cur node
def MV_XML_GetNodeAccessMode(self, strName, penAccessMode):
MvCamCtrldll.MV_XML_GetNodeAccessMode.argtype = (c_void_p, c_void_p, c_void_p)
MvCamCtrldll.MV_XML_GetNodeAccessMode.restype = c_uint
# C原型:int MV_XML_GetNodeAccessMode(IN void* handle, IN const char * strName, OUT MV_XML_AccessMode *penAccessMode);
return MvCamCtrldll.MV_XML_GetNodeAccessMode(self.handle, strName.encode('ascii'), byref(penAccessMode))
# ch:获得当前节点的类型 | en:Get Interface Type of cur node
def MV_XML_GetNodeInterfaceType(self, strName, penInterfaceType):
MvCamCtrldll.MV_XML_GetNodeInterfaceType.argtype = (c_void_p, c_void_p, c_void_p)
MvCamCtrldll.MV_XML_GetNodeInterfaceType.restype = c_uint
# C原型:int MV_XML_GetNodeInterfaceType(IN void* handle, IN const char * strName, OUT MV_XML_InterfaceType *penInterfaceType);
return MvCamCtrldll.MV_XML_GetNodeInterfaceType(self.handle, strName.encode('ascii'), byref(penInterfaceType))
#####附加接口#####
# ch:保存图片,支持Bmp和Jpeg | en:Save image, support Bmp and Jpeg.
def MV_CC_SaveImageEx2(self, stSaveParam):
MvCamCtrldll.MV_CC_SaveImageEx2.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CC_SaveImageEx2.restype = c_uint
# C原型:int MV_CC_SaveImageEx2(void* handle, MV_SAVE_IMAGE_PARAM_EX* pSaveParam)
return MvCamCtrldll.MV_CC_SaveImageEx2(self.handle, byref(stSaveParam))
# ch:保存图像到文件 | en:Save the image file
def MV_CC_SaveImageToFile(self, stSaveFileParam):
MvCamCtrldll.MV_CC_SaveImageToFile.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CC_SaveImageToFile.restype = c_uint
# C原型:int MV_CC_SaveImageToFile(IN void* handle, MV_SAVE_IMG_TO_FILE_PARAM* pstSaveFileParam);
return MvCamCtrldll.MV_CC_SaveImageToFile(self.handle, byref(stSaveFileParam))
# ch:保存3D点云数据,支持PLY、CSV和OBJ三种格式 | en:Save 3D point data, support PLY、CSV and OBJ
def MV_CC_SavePointCloudData(self, stPointDataParam):
MvCamCtrldll.MV_CC_SavePointCloudData.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CC_SavePointCloudData.restype = c_uint
# C原型:int MV_CC_SavePointCloudData(IN void* handle, MV_SAVE_POINT_CLOUD_PARAM* pstPointDataParam);
return MvCamCtrldll.MV_CC_SavePointCloudData(self.handle, byref(stPointDataParam))
# ch:像素格式转换 | en:Pixel format conversion
def MV_CC_ConvertPixelType(self, stConvertParam):
MvCamCtrldll.MV_CC_ConvertPixelType.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CC_ConvertPixelType.restype = c_uint
# C原型:int MV_CC_ConvertPixelType(void* handle, MV_CC_PIXEL_CONVERT_PARAM* pstCvtParam)
return MvCamCtrldll.MV_CC_ConvertPixelType(self.handle, byref(stConvertParam))
# ch:插值算法类型设置 | en:Interpolation algorithm type setting
def MV_CC_SetBayerCvtQuality(self, nBayerCvtQuality):
MvCamCtrldll.MV_CC_SetBayerCvtQuality.argtype = (c_void_p, c_uint)
MvCamCtrldll.MV_CC_SetBayerCvtQuality.restype = c_uint
# C原型:int MV_CC_SetBayerCvtQuality(IN void* handle, IN unsigned int nBayerCvtQuality);
return MvCamCtrldll.MV_CC_SetBayerCvtQuality(self.handle, c_uint(nBayerCvtQuality))
# ch:保存设备属性 | en:Save camera feature
def MV_CC_FeatureSave(self, strFileName):
MvCamCtrldll.MV_CC_FeatureSave.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CC_FeatureSave.restype = c_uint
# C原型:int MV_CC_FeatureSave(void* handle, char* pFileName)
return MvCamCtrldll.MV_CC_FeatureSave(self.handle, strFileName.encode('ascii'))
# ch:导入设备属性 | en:Load camera feature
def MV_CC_FeatureLoad(self, strFileName):
MvCamCtrldll.MV_CC_FeatureLoad.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CC_FeatureLoad.restype = c_uint
# C原型:int MV_CC_FeatureLoad(void* handle, char* pFileName)
return MvCamCtrldll.MV_CC_FeatureLoad(self.handle, strFileName.encode('ascii'))
# ch:从设备读取文件 | en:Read the file from the camera
def MV_CC_FileAccessRead(self, stFileAccess):
MvCamCtrldll.MV_CC_FileAccessRead.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CC_FileAccessRead.restype = c_uint
# C原型:int MV_CC_FileAccessRead(void* handle, MV_CC_FILE_ACCESS * pstFileAccess)
return MvCamCtrldll.MV_CC_FileAccessRead(self.handle, byref(stFileAccess))
# ch:将文件写入设备 | en:Write the file to camera
def MV_CC_FileAccessWrite(self, stFileAccess):
MvCamCtrldll.MV_CC_FileAccessWrite.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CC_FileAccessWrite.restype = c_uint
# C原型:int MV_CC_FileAccessWrite(void* handle, MV_CC_FILE_ACCESS * pstFileAccess)
return MvCamCtrldll.MV_CC_FileAccessWrite(self.handle, byref(stFileAccess))
# ch:获取文件存取进度 | en:Get File Access Progress
def MV_CC_GetFileAccessProgress(self, stFileAccessProgress):
MvCamCtrldll.MV_CC_GetFileAccessProgress.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CC_GetFileAccessProgress.restype = c_uint
# C原型:int MV_CC_GetFileAccessProgress(void* handle, MV_CC_FILE_ACCESS_PROGRESS * pstFileAccessProgress)
return MvCamCtrldll.MV_CC_GetFileAccessProgress(self.handle, byref(stFileAccessProgress))
# ch:开始录像 | en:Start Record
def MV_CC_StartRecord(self, stRecordParam):
MvCamCtrldll.MV_CC_StartRecord.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CC_StartRecord.restype = c_uint
# C原型:int __stdcall MV_CC_StartRecord(IN void* handle, IN MV_CC_RECORD_PARAM* pstRecordParam);
return MvCamCtrldll.MV_CC_StartRecord(self.handle, byref(stRecordParam))
# ch: 输入录像数据 | en:Input RAW data to Record
def MV_CC_InputOneFrame(self, stInputFrameInfo):
MvCamCtrldll.MV_CC_InputOneFrame.argtype = (c_void_p, c_void_p)
MvCamCtrldll.MV_CC_InputOneFrame.restype = c_uint
# C原型:int __stdcall MV_CC_InputOneFrame(IN void* handle, IN MV_CC_INPUT_FRAME_INFO * pstInputFrameInfo);
return MvCamCtrldll.MV_CC_InputOneFrame(self.handle, byref(stInputFrameInfo))
# ch:停止录像 | en:Stop Record
def MV_CC_StopRecord(self):
MvCamCtrldll.MV_CC_StopRecord.argtype = (c_void_p)
MvCamCtrldll.MV_CC_StopRecord.restype = c_uint
# C原型:int __stdcall MV_CC_StopRecord(IN void* handle);
return MvCamCtrldll.MV_CC_StopRecord(self.handle)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
MV_OK = 0x00000000 # < \~chinese 成功,无错误 \~english Successed, no error
# 通用错误码定义:范围0x80000000-0x800000FF
MV_E_HANDLE = 0x80000000 # < \~chinese 错误或无效的句柄 \~english Error or invalid handle
MV_E_SUPPORT = 0x80000001 # < \~chinese 不支持的功能 \~english Not supported function
MV_E_BUFOVER = 0x80000002 # < \~chinese 缓存已满 \~english Buffer overflow
MV_E_CALLORDER = 0x80000003 # < \~chinese 函数调用顺序错误 \~english Function calling order error
MV_E_PARAMETER = 0x80000004 # < \~chinese 错误的参数 \~english Incorrect parameter
MV_E_RESOURCE = 0x80000006 # < \~chinese 资源申请失败 \~english Applying resource failed
MV_E_NODATA = 0x80000007 # < \~chinese 无数据 \~english No data
MV_E_PRECONDITION = 0x80000008 # < \~chinese 前置条件有误,或运行环境已发生变化 \~english Precondition error, or running environment changed
MV_E_VERSION = 0x80000009 # < \~chinese 版本不匹配 \~english Version mismatches
MV_E_NOENOUGH_BUF = 0x8000000A # < \~chinese 传入的内存空间不足 \~english Insufficient memory
MV_E_ABNORMAL_IMAGE = 0x8000000B # < \~chinese 异常图像,可能是丢包导致图像不完整 \~english Abnormal image, maybe incomplete image because of lost packet
MV_E_LOAD_LIBRARY = 0x8000000C # < \~chinese 动态导入DLL失败 \~english Load library failed
MV_E_NOOUTBUF = 0x8000000D # < \~chinese 没有可输出的缓存 \~english No Avaliable Buffer
MV_E_UNKNOW = 0x800000FF # < \~chinese 未知的错误 \~english Unknown error
# GenICam系列错误:范围0x80000100-0x800001FF
MV_E_GC_GENERIC = 0x80000100 # < \~chinese 通用错误 \~english General error
MV_E_GC_ARGUMENT = 0x80000101 # < \~chinese 参数非法 \~english Illegal parameters
MV_E_GC_RANGE = 0x80000102 # < \~chinese 值超出范围 \~english The value is out of range
MV_E_GC_PROPERTY = 0x80000103 # < \~chinese 属性 \~english Property
MV_E_GC_RUNTIME = 0x80000104 # < \~chinese 运行环境有问题 \~english Running environment error
MV_E_GC_LOGICAL = 0x80000105 # < \~chinese 逻辑错误 \~english Logical error
MV_E_GC_ACCESS = 0x80000106 # < \~chinese 节点访问条件有误 \~english Node accessing condition error
MV_E_GC_TIMEOUT = 0x80000107 # < \~chinese 超时 \~english Timeout
MV_E_GC_DYNAMICCAST = 0x80000108 # < \~chinese 转换异常 \~english Transformation exception
MV_E_GC_UNKNOW = 0x800001FF # < \~chinese GenICam未知错误 \~english GenICam unknown error
# GigE_STATUS对应的错误码:范围0x80000200-0x800002FF
MV_E_NOT_IMPLEMENTED = 0x80000200 # < \~chinese 命令不被设备支持 \~english The command is not supported by device
MV_E_INVALID_ADDRESS = 0x80000201 # < \~chinese 访问的目标地址不存在 \~english The target address being accessed does not exist
MV_E_WRITE_PROTECT = 0x80000202 # < \~chinese 目标地址不可写 \~english The target address is not writable
MV_E_ACCESS_DENIED = 0x80000203 # < \~chinese 设备无访问权限 \~english No permission
MV_E_BUSY = 0x80000204 # < \~chinese 设备忙,或网络断开 \~english Device is busy, or network disconnected
MV_E_PACKET = 0x80000205 # < \~chinese 网络包数据错误 \~english Network data packet error
MV_E_NETER = 0x80000206 # < \~chinese 网络相关错误 \~english Network error
MV_E_IP_CONFLICT = 0x80000221 # < \~chinese 设备IP冲突 \~english Device IP conflict
# USB_STATUS对应的错误码:范围0x80000300-0x800003FF
MV_E_USB_READ = 0x80000300 # < \~chinese 读usb出错 \~english Reading USB error
MV_E_USB_WRITE = 0x80000301 # < \~chinese 写usb出错 \~english Writing USB error
MV_E_USB_DEVICE = 0x80000302 # < \~chinese 设备异常 \~english Device exception
MV_E_USB_GENICAM = 0x80000303 # < \~chinese GenICam相关错误 \~english GenICam error
MV_E_USB_BANDWIDTH = 0x80000304 # < \~chinese 带宽不足 该错误码新增 \~english Insufficient bandwidth, this error code is newly added
MV_E_USB_DRIVER = 0x80000305 # < \~chinese 驱动不匹配或者未装驱动 \~english Driver mismatch or unmounted drive
MV_E_USB_UNKNOW = 0x800003FF # < \~chinese USB未知的错误 \~english USB unknown error
# 升级时对应的错误码:范围0x80000400-0x800004FF
MV_E_UPG_FILE_MISMATCH = 0x80000400 # < \~chinese 升级固件不匹配 \~english Firmware mismatches
MV_E_UPG_LANGUSGE_MISMATCH = 0x80000401 # < \~chinese 升级固件语言不匹配 \~english Firmware language mismatches
MV_E_UPG_CONFLICT = 0x80000402 # < \~chinese 升级冲突(设备已经在升级了再次请求升级即返回此错误) \~english Upgrading conflicted (repeated upgrading requests during device upgrade)
MV_E_UPG_INNER_ERR = 0x80000403 # < \~chinese 升级时设备内部出现错误 \~english Camera internal error during upgrade
MV_E_UPG_UNKNOW = 0x800004FF # < \~chinese 升级时未知错误 \~english Unknown error during upgrade
from ctypes import *
PixelType_Gvsp_BGR12_Packed = 36700187
PixelType_Gvsp_COORD3D_DEPTH_PLUS_MASK = -2112094207
PixelType_Gvsp_RGB10V1_Packed = 35651612
PixelType_Gvsp_BayerRG12_Packed = 17563691
PixelType_Gvsp_RGB12_Planar = 36700195
PixelType_Gvsp_YUV411_Packed = 34340894
PixelType_Gvsp_YUV444_Packed = 35127328
PixelType_Gvsp_BGR10_Packed = 36700185
PixelType_Gvsp_YCBCR422_8 = 34603067
PixelType_Gvsp_YCBCR709_422_8 = 34603073
PixelType_Gvsp_RGB12_Packed = 36700186
PixelType_Gvsp_Coord3D_ABC32f_Planar = 39846081
PixelType_Gvsp_Mono8_Signed = 17301506
PixelType_Gvsp_YUV422_YUYV_Packed = 34603058
PixelType_Gvsp_Mono4p = 17039417
PixelType_Gvsp_BayerGR12_Packed = 17563690
PixelType_Gvsp_Coord3D_ABC32 = -2107625471
PixelType_Gvsp_Coord3D_AB32f = -2109722622
PixelType_Gvsp_YCBCR709_411_8_CBYYCRYY = 34340930
PixelType_Gvsp_YCBCR709_422_8_CBYCRY = 34603077
PixelType_Gvsp_Coord3D_AB32 = -2109722621
PixelType_Gvsp_YCBCR601_422_8_CBYCRY = 34603076
PixelType_Gvsp_YCBCR709_8_CBYCR = 35127360
PixelType_Gvsp_Coord3D_AC32f = 36176066
PixelType_Gvsp_YCBCR8_CBYCR = 35127354
PixelType_Gvsp_YCBCR411_8_CBYYCRYY = 34340924
PixelType_Gvsp_Coord3D_ABC32f = 39846080
PixelType_Gvsp_YUV422_Packed = 34603039
PixelType_Gvsp_Coord3D_ABC16 = 36700345
PixelType_Gvsp_RGB10_Planar = 36700194
PixelType_Gvsp_RGB8_Planar = 35127329
PixelType_Gvsp_RGB10_Packed = 36700184
PixelType_Gvsp_Coord3D_C32 = -2128596986
PixelType_Gvsp_RGB16_Packed = 36700211
PixelType_Gvsp_YCBCR422_8_CBYCRY = 34603075
PixelType_Gvsp_YCBCR601_411_8_CBYYCRYY = 34340927
PixelType_Gvsp_BGRA8_Packed = 35651607
PixelType_Gvsp_Jpeg = -2145910783
PixelType_Gvsp_YCBCR601_422_8 = 34603070
PixelType_Gvsp_Coord3D_C32f = 18874559
PixelType_Gvsp_BayerGB12_Packed = 17563692
PixelType_Gvsp_BayerRG16 = 17825839
PixelType_Gvsp_BayerGB10_Packed = 17563688
PixelType_Gvsp_RGB12V1_Packed = 35913780
PixelType_Gvsp_RGB16_Planar = 36700196
PixelType_Gvsp_BGR565_Packed = 34603062
PixelType_Gvsp_Mono16 = 17825799
PixelType_Gvsp_BayerBG10 = 17825807
PixelType_Gvsp_Coord3D_AC32f_64 = 37748930
PixelType_Gvsp_RGBA8_Packed = 35651606
PixelType_Gvsp_Mono12 = 17825797
PixelType_Gvsp_Coord3D_A32f = 18874557
PixelType_Gvsp_YCBCR601_8_CBYCR = 35127357
PixelType_Gvsp_BayerGB16 = 17825840
PixelType_Gvsp_Coord3D_AC32 = -2109722620
PixelType_Gvsp_BayerBG16 = 17825841
PixelType_Gvsp_Coord3D_AC32f_Planar = 37748931
PixelType_Gvsp_BayerBG10_Packed = 17563689
PixelType_Gvsp_RGB8_Packed = 35127316
PixelType_Gvsp_BGR8_Packed = 35127317
PixelType_Gvsp_BayerGR16 = 17825838
PixelType_Gvsp_BayerGR10_Packed = 17563686
PixelType_Gvsp_Mono8 = 17301505
PixelType_Gvsp_Mono14 = 17825829
PixelType_Gvsp_BayerGB10 = 17825806
PixelType_Gvsp_Undefined = -1
PixelType_Gvsp_BayerRG8 = 17301513
PixelType_Gvsp_BayerGB12 = 17825810
PixelType_Gvsp_Mono12_Packed = 17563654
PixelType_Gvsp_BayerBG8 = 17301515
PixelType_Gvsp_BayerBG12_Packed = 17563693
PixelType_Gvsp_Mono1p = 16842807
PixelType_Gvsp_Mono2p = 16908344
PixelType_Gvsp_RGB565_Packed = 34603061
PixelType_Gvsp_RGB10V2_Packed = 35651613
PixelType_Gvsp_BayerRG12 = 17825809
PixelType_Gvsp_Mono10_Packed = 17563652
PixelType_Gvsp_BayerGR8 = 17301512
PixelType_Gvsp_BayerGB8 = 17301514
PixelType_Gvsp_BayerGR12 = 17825808
PixelType_Gvsp_BayerGR10 = 17825804
PixelType_Gvsp_BayerRG10 = 17825805
PixelType_Gvsp_BayerBG12 = 17825811
PixelType_Gvsp_Coord3D_A32 = -2128596987
PixelType_Gvsp_Mono10 = 17825795
PixelType_Gvsp_BayerRG10_Packed = 17563687
__all__ = ['PixelType_Gvsp_BayerRG8',
'PixelType_Gvsp_YCBCR422_8',
'PixelType_Gvsp_Coord3D_ABC32',
'PixelType_Gvsp_Coord3D_AB32f',
'PixelType_Gvsp_COORD3D_DEPTH_PLUS_MASK',
'PixelType_Gvsp_RGB10_Packed',
'PixelType_Gvsp_RGB10V1_Packed',
'PixelType_Gvsp_RGB8_Planar',
'PixelType_Gvsp_RGBA8_Packed',
'PixelType_Gvsp_RGB8_Packed',
'PixelType_Gvsp_BayerBG12',
'PixelType_Gvsp_Coord3D_AC32f_Planar',
'PixelType_Gvsp_BayerBG10_Packed',
'PixelType_Gvsp_YCBCR709_422_8_CBYCRY',
'PixelType_Gvsp_Coord3D_A32f',
'PixelType_Gvsp_YUV411_Packed',
'PixelType_Gvsp_BayerBG12_Packed',
'PixelType_Gvsp_RGB16_Packed',
'PixelType_Gvsp_BayerRG12',
'PixelType_Gvsp_BayerRG10',
'PixelType_Gvsp_BayerRG16',
'PixelType_Gvsp_YCBCR709_411_8_CBYYCRYY',
'PixelType_Gvsp_BayerGB12_Packed',
'PixelType_Gvsp_Coord3D_AC32f',
'PixelType_Gvsp_BayerRG12_Packed',
'PixelType_Gvsp_Coord3D_AB32',
'PixelType_Gvsp_BGR12_Packed',
'PixelType_Gvsp_BayerGR10_Packed',
'PixelType_Gvsp_Coord3D_AC32',
'PixelType_Gvsp_RGB12_Planar',
'PixelType_Gvsp_YCBCR709_422_8',
'PixelType_Gvsp_BGR8_Packed',
'PixelType_Gvsp_Jpeg',
'PixelType_Gvsp_Coord3D_AC32f_64',
'PixelType_Gvsp_YUV422_Packed',
'PixelType_Gvsp_Mono8_Signed',
'PixelType_Gvsp_BayerBG10',
'PixelType_Gvsp_BayerBG16',
'PixelType_Gvsp_BayerGR8',
'PixelType_Gvsp_RGB16_Planar',
'PixelType_Gvsp_Mono4p',
'PixelType_Gvsp_BayerRG10_Packed',
'PixelType_Gvsp_Mono8',
'PixelType_Gvsp_BayerGR16',
'PixelType_Gvsp_BayerGR10',
'PixelType_Gvsp_BGRA8_Packed',
'PixelType_Gvsp_BayerGR12',
'PixelType_Gvsp_Mono12_Packed',
'PixelType_Gvsp_YCBCR709_8_CBYCR',
'PixelType_Gvsp_Coord3D_A32',
'PixelType_Gvsp_YCBCR601_422_8',
'PixelType_Gvsp_Coord3D_C32',
'PixelType_Gvsp_YCBCR411_8_CBYYCRYY',
'PixelType_Gvsp_Undefined',
'PixelType_Gvsp_BayerGR12_Packed',
'PixelType_Gvsp_YCBCR601_411_8_CBYYCRYY',
'PixelType_Gvsp_RGB10_Planar',
'PixelType_Gvsp_BayerGB16',
'PixelType_Gvsp_BayerGB10',
'PixelType_Gvsp_BayerGB12',
'PixelType_Gvsp_BGR565_Packed',
'PixelType_Gvsp_Mono1p',
'PixelType_Gvsp_Coord3D_ABC16',
'PixelType_Gvsp_YUV444_Packed',
'PixelType_Gvsp_YUV422_YUYV_Packed',
'PixelType_Gvsp_BayerBG8',
'PixelType_Gvsp_Coord3D_C32f',
'PixelType_Gvsp_BGR10_Packed',
'PixelType_Gvsp_BayerGB10_Packed',
'PixelType_Gvsp_Coord3D_ABC32f_Planar',
'PixelType_Gvsp_Coord3D_ABC32f',
'PixelType_Gvsp_YCBCR422_8_CBYCRY',
'PixelType_Gvsp_RGB12_Packed',
'PixelType_Gvsp_Mono12',
'PixelType_Gvsp_Mono10',
'PixelType_Gvsp_Mono16',
'PixelType_Gvsp_Mono2p',
'PixelType_Gvsp_Mono14',
'PixelType_Gvsp_RGB10V2_Packed',
'PixelType_Gvsp_RGB12V1_Packed',
'PixelType_Gvsp_Mono10_Packed',
'PixelType_Gvsp_YCBCR601_8_CBYCR',
'PixelType_Gvsp_BayerGB8',
'PixelType_Gvsp_YCBCR8_CBYCR',
'PixelType_Gvsp_RGB565_Packed',
'PixelType_Gvsp_YCBCR601_422_8_CBYCRY']
File added
[video]
# 配置是否播放视频,1:播放,0:不播放
is_show=0
# 配置摄像头宽高,用,间隔
size=[1440,1080]
[point]
# 配置激光点的面积范围,用,间隔,用于过滤干扰点
area=[0,100]
# 配置激光点亮度下限,软件只捕获RGB平均值>该设定值的激光点
# 调整该值,满足以下要求:除激光外,其他内容的亮度均小于该值
light=20
# 配置鼠标是否跟随,1:跟随,0:不跟随
is_mouse_follow=1
# 配置鼠标跟随的帧系数,浮点数,0~1,表示每秒鼠标跟随(视频帧速率 x 系数)次
# 主要用于在低性能机器上解析高帧速率视频,实现降采样,普通机器默认配置1(即正常采样)
fps_ratio=1
# 配置激光的监视系数,浮点数,表示激光可超出屏幕的百分比
# 默认配置0,如果激光直径比较大,可以配置该系数,如0.005
monitor_ratio=0
[correct]
# position1和position2用于给摄像头拍到的屏幕4个角进行定位,坐标为屏幕xy坐标
# 配置项为二维数组,分别表示左上、左下、右下、右上4个坐标点
position1=[[72,147],[119,890],[1326,905],[1392,161]]
position2=[[51,121],[110,867],[1312,874],[1380,127]]
[screen]
# 配置显示器是分屏还是合屏,1:合屏,0:分屏
is_merge=0
screen_width = 3840
screen_height = 1080
#layout = [{"id": "screen1", "ip": "192.168.31.150", "anchor": [0, 0], "width": 1920, "height": 1080}, {"id": "screen2", "ip": "192.168.31.151", "anchor": [1920, 0], "width": 1920, "height": 1080}]
layout = [{"id": "screen1", "ip": "192.168.31.150", "anchor": [0, 0], "width": 3840, "height": 1080}]
# 指令字符串配置
[udp_service]
port=18300
# 指令字符串配置
[order]
left_clicked=btn:left_clicked\r\n
left_long_clicked=btn:left_long_clicked\r\n
left_long_clicked_release=btn:left_long_clicked_release\r\n
left_double_clicked=btn:left_double_clicked\r\n
right_clicked=btn:right_clicked\r\n
right_long_clicked=btn:right_long_clicked\r\n
right_long_clicked_release=btn:right_long_clicked_release\r\n
right_double_clicked=btn:right_double_clicked\r\n
page_up_clicked=btn:page_up_clicked\r\n
page_down_clicked=btn:page_down_clicked\r\n
switch_clicked=btn:switch_clicked\r\n
audio_clicked=btn:audio_clicked\r\n
\ No newline at end of file
import socket
import time,random
class KM:
def __init__(self,ip):
self.sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
self.sock.settimeout(1)
self.ip=ip
self.sync_mode=True
def __del__(self):
self.Close()
def Close(self):
if self.sock!=None:
self.sock.close()
self.sock=None
def Send(self,msg):
self.sock.sendto(msg.encode('ascii'),(self.ip,2333))
def Recv(self):
try:
data,_ = self.sock.recvfrom(128)
return data
except socket.timeout:
self.Close()
self.sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
self.sock.settimeout(1)
return [0xff];
def SendCmd(self,type,params):
cmd=type+"="+",".join([str(s) for s in params])+"\r\n"
self.Send(cmd)
if self.sync_mode:
return self.Recv()
return None
@staticmethod
def Delay(millisecond):
time.sleep(millisecond/1000)
@staticmethod
def DelayRandom(min,max):
time.sleep(random.randint(min,max)/1000)
def GetName(self):
data=self.SendCmd("P",[0])
if data[0]==0xff:
return ""
else:
data=data[:data.index(0)]
return data.decode("gbk")
def GetID(self):
data=self.SendCmd("P",[1])
if len(data)!=4:
return 0
return data[0]<<24|data[1]<<16|data[2]<<8|data[3]
#Setting
def SetScreenRes(self,width,height):
self.SendCmd("S",[0,width,height])
def SetSpeedMode(self,on):
self.sync_mode=not on
self.SendCmd("S",[1,1 if on else 0])
def Reboot(self):
self.SendCmd("S",[2])
#Mouse
def MoveTo(self,x,y):
self.SendCmd("M",[0,x,y])
def MoveD(self,x,y,shift=0,time=0):
self.SendCmd("M",[1,x,y,shift,time])
def MoveR(self,dx,dy):
self.SendCmd("M",[2,dx,dy])
def LeftDown(self):
self.SendCmd("M",[3])
def LeftUp(self):
self.SendCmd("M",[4])
def LeftClick(self,min=0,max=0):
self.SendCmd("M",[5,min,max])
def LeftDoubleClick(self,min=0,max=0):
self.SendCmd("M",[6,min,max])
def RightDown(self):
self.SendCmd("M",[7])
def RightUp(self):
self.SendCmd("M",[8])
def RightClick(self,min=0,max=0):
self.SendCmd("M",[9,min,max])
def MouseWheel(self,delta):
self.SendCmd("M",[10,delta])
def MiddleDown(self):
self.SendCmd("M",[11])
def MiddleUp(self):
self.SendCmd("M",[12])
def MiddleClick(self,min=0,max=0):
self.SendCmd("M",[13,min,max])
def MouseAllUp(self):
self.SendCmd("M",[14])
#Keyboard
def KeyDown(self,scancode):
self.SendCmd("K",[0,scancode])
def KeyUp(self,scancode):
self.SendCmd("K",[1,scancode])
def KeyPress(self,scancode,min=0,max=0):
self.SendCmd("K",[2,scancode,min,max])
def KeyDownVirtual(self,virtualcode):
scancode=self.GetScanCodeFromVirtualCode(virtualcode)
self.SendCmd("K",[0,scancode])
def KeyUpVirtual(self,virtualcode):
scancode=self.GetScanCodeFromVirtualCode(virtualcode)
self.SendCmd("K",[1,scancode])
def KeyPressVirtual(self,virtualcode,min=0,max=0):
scancode=self.GetScanCodeFromVirtualCode(virtualcode)
self.SendCmd("K",[2,scancode,min,max])
def KeyDownName(self,keyname):
scancode=self.GetScanCodeFromKeyName(keyname)
self.SendCmd("K",[0,scancode])
def KeyUpName(self,keyname):
scancode=self.GetScanCodeFromKeyName(keyname)
self.SendCmd("K",[1,scancode])
def KeyPressName(self,keyname,min=0,max=0):
scancode=self.GetScanCodeFromKeyName(keyname)
self.SendCmd("K",[2,scancode,min,max])
def KeyAllUp(self):
self.SendCmd("K",[3])
@staticmethod
def GetScanCodeFromVirtualCode(vcode):
keymap={
"65":4,"66":5,"67":6,"68":7,"69":8,"70":9,"71":10,"72":11,"73":12,"74":13,"75":14,"76":15,"77":16,"78":17,"79":18,
"80":19,"81":20,"82":21,"83":22,"84":23,"85":24,"86":25,"87":26,"88":27,"89":28,"90":29,"49":30,"50":31,"51":32,"52":33,
"53":34,"54":35,"55":36,"56":37,"57":38,"48":39,"13":40,"27":41,"8":42,"9":43,"32":44,"189":45,"187":46,"219":47,"221":48,
"220":49,"186":51,"222":52,"192":53,"188":54,"190":55,"191":56,"20":57,"112":58,"113":59,"114":60,"115":61,"116":62,"117":63,
"118":64,"119":65,"120":66,"121":67,"122":68,"123":69,"44":70,"145":71,"19":72,"19":72,"45":73,"36":74,"33":75,"46":76,"35":77,
"34":78,"39":79,"37":80,"40":81,"38":82,"144":83,"111":84,"96":85,"109":86,"107":87,"108":88,"97":89,"98":90,"99":91,"100":92,
"101":93,"102":94,"103":95,"104":96,"105":97,"96":98,"110":99,"93":101,"146":103,"173":127,"175":128,"174":129,"162":224,"160":225,
"164":226,"91":227,"163":228,"161":229,"165":230,"92":231,"17":224,"16":225,"18":226
}
vcode=str(vcode)
if vcode in keymap:
return keymap[vcode]
else:
return 0
@staticmethod
def GetScanCodeFromKeyName(keyname):
keymap={
"a":4,"b":5,"c":6,"d":7,"e":8,"f":9,"g":10,"h":11,"i":12,"j":13,"k":14,"l":15,"m":16,"n":17,"o":18,"p":19,"q":20,
"r":21,"s":22,"t":23,"u":24,"v":25,"w":26,"x":27,"y":28,"z":29,"1":30,"2":31,"3":32,"4":33,"5":34,"6":35,"7":36,
"8":37,"9":38,"0":39,"enter":40,"esc":41,"backspace":42,"tab":43,"space":44,"空格键":44,"-":45,"=":46,"[":47,"]":48,
"\\":49,";":51,"'":52,"`":53,",":54,".":55,"/":56,"capslock":57,"f1":58,"f2":59,"f3":60,"f4":61,"f5":62,"f6":63,"f7":64,
"f8":65,"f9":66,"f10":67,"f11":68,"f12":69,"printscreen":70,"scrolllock":71,"pause":72,"break":72,"insert":73,"home":74,
"pageup":75,"delete":76,"end":77,"pagedown":78,"right":79,"left":80,"down":81,"up":82,"numlock":83,"小键盘/":84,"小键盘*":85,
"小键盘-":86,"小键盘+":87,"小键盘enter":88,"小键盘1":89,"小键盘2":90,"小键盘3":91,"小键盘4":92,"小键盘5":93,"小键盘6":94,
"小键盘7":95,"小键盘8":96,"小键盘9":97,"小键盘0":98,"小键盘.":99,"menu":101,"小键盘=":103,"静音":127,"音量加":128,"音量减":129,
"lctrl":224,"lshift":225,"lalt":226,"lwin":227,"rctrl":228,"rshift":229,"ralt":230,"rwin":231,
"ctrl":224,"shift":225,"alt":226,"win":227
}
keyname=keyname.lower()
if keyname in keymap:
return keymap[keyname]
else:
return 0
# -*- coding: utf-8 -*-
import win32con
import ctypes
import os
class CursorHider():
# 开始隐藏鼠标
def cursor_hider_open():
# 通过注册表生成透明的鼠标方案
cwd = os.getcwd()
command = 'reg add "HKCU\Control Panel\Cursors" /f /ve /t REG_SZ /d "videomouse"\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Scheme Source" /t REG_DWORD /d 1\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Arrow" /t REG_SZ /d "' + cwd + '/blank.cur"\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Help" /t REG_SZ /d "' + cwd + '/blank.cur"\
&& reg add "HKCU\Control Panel\Cursors" /f /v "AppStarting" /t REG_SZ /d "' + cwd + '/blank.cur"\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Wait" /t REG_SZ /d "' + cwd + '/blank.cur"\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Crosshair" /t REG_SZ /d "' + cwd + '/blank.cur"\
&& reg add "HKCU\Control Panel\Cursors" /f /v "IBeam" /t REG_SZ /d "' + cwd + '/blank.cur"\
&& reg add "HKCU\Control Panel\Cursors" /f /v "NWPen" /t REG_SZ /d "' + cwd + '/blank.cur"\
&& reg add "HKCU\Control Panel\Cursors" /f /v "No" /t REG_SZ /d "' + cwd + '/blank.cur"\
&& reg add "HKCU\Control Panel\Cursors" /f /v "SizeNS" /t REG_SZ /d "' + cwd + '/blank.cur"\
&& reg add "HKCU\Control Panel\Cursors" /f /v "SizeWE" /t REG_SZ /d "' + cwd + '/blank.cur"\
&& reg add "HKCU\Control Panel\Cursors" /f /v "SizeNWSE" /t REG_SZ /d "' + cwd + '/blank.cur"\
&& reg add "HKCU\Control Panel\Cursors" /f /v "SizeNESW" /t REG_SZ /d "' + cwd + '/blank.cur"\
&& reg add "HKCU\Control Panel\Cursors" /f /v "SizeAll" /t REG_SZ /d "' + cwd + '/blank.cur"\
&& reg add "HKCU\Control Panel\Cursors" /f /v "UpArrow" /t REG_SZ /d "' + cwd + '/blank.cur"\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Person" /t REG_EXPAND_SZ /d "' + cwd + '/blank.cur"\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Hand" /t REG_EXPAND_SZ /d "' + cwd + '/blank.cur"\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Pin" /t REG_EXPAND_SZ /d "' + cwd + '/blank.cur"\
&& reg add "HKCU\Control Panel\Cursors\Schemes" /f /v "videomouse" /t REG_EXPAND_SZ /d "' + cwd + '/blank.cur,' + cwd + '/blank.cur,' + cwd + '/blank.cur,' + cwd + '/blank.cur,' + cwd + '/blank.cur,' + cwd + '/blank.cur,' + cwd + '/blank.cur,' + cwd + '/blank.cur,' + cwd + '/blank.cur,' + cwd + '/blank.cur,' + cwd + '/blank.cur,' + cwd + '/blank.cur,' + cwd + '/blank.cur,' + cwd + '/blank.cur,' + cwd + '/blank.cur,' + cwd + '/blank.cur,' + cwd + '/blank.cur"'
os.system(command)
# 应用鼠标方案
dll = ctypes.windll.LoadLibrary('user32')
dll.SystemParametersInfoW(win32con.SPI_SETCURSORS,0,0,2)
# 取消鼠标隐藏
def cursor_hider_close():
# 删除注册表中透明的鼠标方案
command = 'reg add "HKCU\Control Panel\Cursors" /f /ve /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Scheme Source" /t REG_DWORD /d 0\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Arrow" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Help" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "AppStarting" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Wait" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Crosshair" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "IBeam" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "NWPen" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "No" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "SizeNS" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "SizeWE" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "SizeNWSE" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "SizeNESW" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "SizeAll" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "UpArrow" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Person" /t REG_EXPAND_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Hand" /t REG_EXPAND_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Pin" /t REG_EXPAND_SZ /d ""\
&& reg delete "HKCU\Control Panel\Cursors\Schemes" /f /v "videomouse"'
os.system(command)
# 应用鼠标方案
dll = ctypes.windll.LoadLibrary('user32')
dll.SystemParametersInfoW(win32con.SPI_SETCURSORS,0,0,2)
import win32api,win32con
class MouseEvent():
def mouse_move(x, y, main_screen_width, main_screen_height):
dx = round(x*65536/main_screen_width)
dy = round(y*65536/main_screen_height)
win32api.mouse_event(win32con.MOUSEEVENTF_ABSOLUTE | win32con.MOUSEEVENTF_MOVE, dx, dy, 0, 0)
def mouse_left_click():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN | win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
def mouse_left_dbclick():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN | win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN | win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
def mouse_right_click():
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN | win32con.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
def mouse_right_dbclick():
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN | win32con.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN | win32con.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
def mouse_middle_up():
win32api.mouse_event(win32con.MOUSEEVENTF_WHEEL, 0, 0, 100, 0)
def mouse_middle_down():
win32api.mouse_event(win32con.MOUSEEVENTF_WHEEL, 0, 0, -100, 0)
def mouse_left_down():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
def mouse_left_up():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
def mouse_right_down():
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
def mouse_right_up():
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
\ No newline at end of file
import win32api,win32con
from km import KM
class MouseEvent():
def mouse_move(x, y, main_screen_width, main_screen_height):
dx = round(x*65536/main_screen_width)
dy = round(y*65536/main_screen_height)
win32api.mouse_event(win32con.MOUSEEVENTF_ABSOLUTE | win32con.MOUSEEVENTF_MOVE, dx, dy, 0, 0)
def mouse_left_click():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN | win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
def mouse_left_dbclick():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN | win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN | win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
def mouse_right_click():
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN | win32con.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
def mouse_right_dbclick():
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN | win32con.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN | win32con.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
def mouse_middle_up():
win32api.mouse_event(win32con.MOUSEEVENTF_WHEEL, 0, 0, 100, 0)
def mouse_middle_down():
win32api.mouse_event(win32con.MOUSEEVENTF_WHEEL, 0, 0, -100, 0)
def mouse_left_down():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
def mouse_left_up():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
def mouse_right_down():
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
def mouse_right_up():
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
class RemoteMouseEvent():
#def __init__(self, sip1, sip2, main_screen_width, main_screen_height):
def __init__(self, sip1):
self.cx = None
self.cy = None
self.km1 = KM(sip1)
def setScreenRes(self, width, height):
self.km1.SetScreenRes(width, height)
def setSpeedMode(self, on):
self.km1.SetSpeedMode(on)
def _update(self, x, y):
self.x = int(x)
self.y = int(y)
def get_km(self):
return self.km1
#print(self.x, self.y, self.main_screen_width, self.main_screen_height)
#if self.x is None or self.main_screen_width is None:
#return None
#return self.km1 if self.x < self.main_screen_width else self.km2
def mouse_move(self, x, y, main_screen_width, main_screen_height):
self._update(x, y)
km = self.get_km()
km.MoveTo(int(x), int(y))
def mouse_left_click(self):
km = self.get_km()
km.LeftClick()
def mouse_left_dbclick(self):
km = self.get_km()
km.LeftDoubleClick()
def mouse_right_click(self):
km = self.get_km()
km.RightClick()
def mouse_right_dbclick(self):
km = self.get_km()
km.RightClick()
km.RightClick()
def mouse_wheel_up(self):
km = self.get_km()
km.MouseWheel(2)
def mouse_wheel_down(self):
km=self.get_km()
km.MouseWheel(-2)
def mouse_middle_up(self):
km = self.get_km()
km.MiddleUp()
def mouse_middle_down(self):
km = self.get_km()
km.MiddleDown()
def mouse_left_down(self):
km = self.get_km()
km.LeftDown()
def mouse_left_up(self):
km = self.get_km()
km.LeftUp()
def mouse_right_down(self):
km = self.get_km()
km.RightDown()
def mouse_right_up(self):
km = self.get_km()
km.RightUp()
class MultiScreenMouseEvent():
def __init__(self, screen_width, screen_height, layout, speed_mode = True) -> None:
self.total_screen_width = screen_width
self.total_screen_height = screen_height
self.layout = layout
self.speed_mode = speed_mode
self.kms = {}
for s in self.layout:
km = KM(s["ip"])
km.SetScreenRes(s["width"], s["height"])
km.SetSpeedMode(speed_mode)
self.kms[s["id"]] = km
self.current_screen = None
def find_screen_and_relative_coords(self, point):
for screen in self.layout:
x, y = point
anchor_x, anchor_y = screen['anchor']
width, height = screen['width'], screen['height']
if anchor_x <= x < anchor_x + width and anchor_y <= y < anchor_y + height:
#relative_coords = [x, y - anchor_y]
relative_coords = [x - anchor_x, y - anchor_y]
return screen, relative_coords
return None, None
def __getattr__(self, name):
if name == "mouse_move":
def method(ax, ay):
s, coords = self.find_screen_and_relative_coords((ax, ay))
km = self.kms[s["id"]]
self.current_screen = s["id"]
#self.current_screen = "screen1"
rx, ry = coords[0], coords[1]
print(self.current_screen, int(rx), int(ry))
km.MoveTo(int(rx), int(ry))
return method
else:
def method(*args, **kwargs):
km = self.kms[self.current_screen]
getattr(km, name)(*args, **kwargs)
return method
\ No newline at end of file
from ctypes import cast, POINTER
from comtypes import CLSCTX_ALL
from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume
import pythoncom
class VolumeEvent():
def volume_change():
pythoncom.CoInitialize()
devices = AudioUtilities.GetSpeakers()
interface = devices.Activate(IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
volume = cast(interface, POINTER(IAudioEndpointVolume))
# 判断是否静音,mute为1代表是静音,为0代表不是静音
mute = volume.GetMute()
if mute == 0:
volume.SetMute(1, None)
else:
volume.SetMute(0, None)
\ No newline at end of file
import sys
import threading
import msvcrt
import numpy as np
import time
from ctypes import *
sys.path.append("./MvImport")
from MvCameraControl_class import *
g_bExit = False
class GigeE():
def startCamera(nConnectionNum):
deviceList = MV_CC_DEVICE_INFO_LIST()
#tlayerType = MV_GIGE_DEVICE | MV_USB_DEVICE | MV_UNKNOW_DEVICE | MV_1394_DEVICE | MV_CAMERALINK_DEVICE
tlayerType = MV_GIGE_DEVICE
# ch:枚举设备 | en:Enum device
ret = MvCamera.MV_CC_EnumDevices(tlayerType, deviceList)
if ret != 0:
print("enum devices fail! ret[0x%x]" % ret)
#sys.exit()
return None
if deviceList.nDeviceNum == 0:
print("find no device!")
#sys.exit()
return None
print("Find %d devices!" % deviceList.nDeviceNum)
for i in range(0, deviceList.nDeviceNum):
mvcc_dev_info = cast(deviceList.pDeviceInfo[i], POINTER(MV_CC_DEVICE_INFO)).contents
if mvcc_dev_info.nTLayerType == MV_GIGE_DEVICE:
print("\ngige device: [%d]" % i)
strModeName = ""
for per in mvcc_dev_info.SpecialInfo.stGigEInfo.chModelName:
strModeName = strModeName + chr(per)
print("device model name: %s" % strModeName)
nip1 = ((mvcc_dev_info.SpecialInfo.stGigEInfo.nCurrentIp & 0xff000000) >> 24)
nip2 = ((mvcc_dev_info.SpecialInfo.stGigEInfo.nCurrentIp & 0x00ff0000) >> 16)
nip3 = ((mvcc_dev_info.SpecialInfo.stGigEInfo.nCurrentIp & 0x0000ff00) >> 8)
nip4 = (mvcc_dev_info.SpecialInfo.stGigEInfo.nCurrentIp & 0x000000ff)
print("current ip: %d.%d.%d.%d\n" % (nip1, nip2, nip3, nip4))
elif mvcc_dev_info.nTLayerType == MV_USB_DEVICE:
print("\nu3v device: [%d]" % i)
strModeName = ""
for per in mvcc_dev_info.SpecialInfo.stUsb3VInfo.chModelName:
if per == 0:
break
strModeName = strModeName + chr(per)
print("device model name: %s" % strModeName)
strSerialNumber = ""
for per in mvcc_dev_info.SpecialInfo.stUsb3VInfo.chSerialNumber:
if per == 0:
break
strSerialNumber = strSerialNumber + chr(per)
print("user serial number: %s" % strSerialNumber)
# nConnectionNum = input("please input the number of the device to connect:")
if int(nConnectionNum) >= deviceList.nDeviceNum:
print("intput error!")
#sys.exit()
return None
# ch:创建相机实例 | en:Creat Camera Object
cam = MvCamera()
# ch:选择设备并创建句柄 | en:Select device and create handle
stDeviceList = cast(deviceList.pDeviceInfo[int(nConnectionNum)], POINTER(MV_CC_DEVICE_INFO)).contents
ret = cam.MV_CC_CreateHandle(stDeviceList)
if ret != 0:
print("create handle fail! ret[0x%x]" % ret)
#sys.exit()
return None
# ch:打开设备 | en:Open device
ret = cam.MV_CC_OpenDevice(MV_ACCESS_Exclusive, 0)
if ret != 0:
print("open device fail! ret[0x%x]" % ret)
#sys.exit()
return None
# ch:探测网络最佳包大小(只对GigE相机有效) | en:Detection network optimal package size(It only works for the GigE camera)
if stDeviceList.nTLayerType == MV_GIGE_DEVICE:
nPacketSize = cam.MV_CC_GetOptimalPacketSize()
if int(nPacketSize) > 0:
ret = cam.MV_CC_SetIntValue("GevSCPSPacketSize", nPacketSize)
if ret != 0:
print("Warning: Set Packet Size fail! ret[0x%x]" % ret)
else:
print("Warning: Get Packet Size fail! ret[0x%x]" % nPacketSize)
stBool = c_bool(False)
ret = cam.MV_CC_GetBoolValue("AcquisitionFrameRateEnable", stBool)
if ret != 0:
print("get AcquisitionFrameRateEnable fail! ret[0x%x]" % ret)
#sys.exit()
return None
# ch:设置触发模式为off | en:Set trigger mode as off
ret = cam.MV_CC_SetEnumValue("TriggerMode", MV_TRIGGER_MODE_OFF)
if ret != 0:
print("set trigger mode fail! ret[0x%x]" % ret)
#sys.exit()
return None
# ch:开始取流 | en:Start grab image
ret = cam.MV_CC_StartGrabbing()
if ret != 0:
print("start grabbing fail! ret[0x%x]" % ret)
#sys.exit()
return None
return cam
##############################
# try:
# hThreadHandle = threading.Thread(target=work_thread, args=(cam, None, None))
# hThreadHandle.start()
# except:
# print ("error: unable to start thread")
# g_bExit = True
# hThreadHandle.join()
def closeCamera(cam):
# ch:停止取流 | en:Stop grab image
ret = cam.MV_CC_StopGrabbing()
if ret != 0:
print("stop grabbing fail! ret[0x%x]" % ret)
#sys.exit()
return None
# ch:关闭设备 | Close device
ret = cam.MV_CC_CloseDevice()
if ret != 0:
print("close deivce fail! ret[0x%x]" % ret)
#sys.exit()
return None
# ch:销毁句柄 | Destroy handle
ret = cam.MV_CC_DestroyHandle()
if ret != 0:
print("destroy handle fail! ret[0x%x]" % ret)
#sys.exit()
return None
def GetImage(cam, height, width):
sec = 0
data_buf = None
stOutFrame = MV_FRAME_OUT()
memset(byref(stOutFrame), 0, sizeof(stOutFrame))
ret = cam.MV_CC_GetImageBuffer(stOutFrame, 1000)
if None != stOutFrame.pBufAddr and 0 == ret:
if data_buf == None:
data_buf = (c_ubyte * stOutFrame.stFrameInfo.nFrameLen)()
# print("get one frame: Width[%d], Height[%d], nFrameNum[%d]" % (
# stOutFrame.stFrameInfo.nWidth, stOutFrame.stFrameInfo.nHeight, stOutFrame.stFrameInfo.nFrameNum))
cdll.msvcrt.memcpy(byref(data_buf), stOutFrame.pBufAddr, stOutFrame.stFrameInfo.nFrameLen)
temp = np.asarray(data_buf)
temp = temp.reshape((height, width)) #注意 这里要改成使用相机的宽和高
nRet = cam.MV_CC_FreeImageBuffer(stOutFrame)
return temp
else:
print("no data[0x%x]" % ret)
def GetFps(cam):
return cam.MV_CC_GetFrameRate()
from collections import deque
import itertools
import numpy as np
class WeightedMovingAverageFilter:
def __init__(self, weights, disabled=False, threshold=0.95):
self.weights = weights
self.values = deque(maxlen=len(weights))
self.disabled = disabled
self.threshold = threshold
def stable(self):
cv = np.std(self.values) / np.mean(self.values)
return cv >= self.threshold
def update(self, new_value):
if self.disabled:
return new_value
self.values.append(new_value)
if len(self.values) < len(self.weights):
return new_value
else:
if self.stable():
avg_x = sum(x for x, y in self.values) / len(self.values)
avg_y = sum(y for x, y in self.values) / len(self.values)
return (avg_x, avg_y)
return [sum(w * v[i] for w, v in zip(self.weights, reversed(self.values))) for i in range(2)]
class ExponentialMovingAverageFilter:
def __init__(self, alpha):
self.alpha = alpha
self.value = None
def update(self, new_value):
if self.value is None:
self.value = new_value
else:
self.value = [(1 - self.alpha) * old + self.alpha * new for old, new in zip(self.value, new_value)]
return self.value
if __name__ == "__main__":
filter = WeightedMovingAverageFilter(weights=[0.6, 0.3, 0.1])
coordinates = [(1920,1080), (1910, 1000), (1900, 990), (1890, 980)]
for coord in coordinates:
smoothed_value = filter.update(coord)
print(smoothed_value)
\ No newline at end of file
# #coding:utf-8
from twisted.internet.protocol import DatagramProtocol
from twisted.internet import reactor
gl_callback = None
# Here's a UDP version of the simplest possible protocol
class EchoUDP(DatagramProtocol):
def datagramReceived(self, datagram, address):
gl_callback(datagram.decode("utf-8"))
# self.transport.loseConnection()
# self.transport.stopListening()
class UdpService():
def start_service(port, callback):
global gl_callback
gl_callback = callback
reactor.listenUDP(port, EchoUDP())
reactor.run(installSignalHandlers = 0)
def stop_service():
reactor.stop()
# -*- coding: utf-8 -*-
import numpy as np
import cv2
from mm_event_mouse import MouseEvent
# from pymouse import PyMouse
from mm_gige import GigeE
from mm_cursor_hider import CursorHider
from win32 import win32api, win32gui, win32print
from win32.lib import win32con
from mm_mouse_filter import WeightedMovingAverageFilter
#import time
gl_cam_running = False
class MouseVideo():
#def start_mouse_follow(callback, pts1, pts2, point_area, video_size, light, show_frame,
# is_mouse_follow, process_ratio, monitor_ratio, is_merge, mousehandler=None):
def start_mouse_follow(callback, pts1, pts2, point_area, video_size, light, show_frame,
is_mouse_follow, process_ratio, monitor_ratio, screen_width, screen_height, mousehandler=None):
filter = WeightedMovingAverageFilter(weights=[0.8,0.1,0.1,0,0], disabled=False, threshold=0.90)
perspective1,maxWidth1,maxHeight1 = MouseVideo.get_perspective(pts1)
perspective2,maxWidth2,maxHeight2 = MouseVideo.get_perspective(pts2)
#hDC = win32gui.GetDC(0)
#main_screen_width = win32print.GetDeviceCaps(hDC, win32con.DESKTOPHORZRES)
#main_screen_height = win32print.GetDeviceCaps(hDC, win32con.DESKTOPVERTRES)
#screen_num = win32api.GetSystemMetrics(win32con.SM_CMONITORS);
#screen_width = main_screen_width if is_merge else main_screen_width * screen_num;
#screen_height = main_screen_height;
#screen_width = screen_size[0]
#screen_height = screen_size[1]
video_width = video_size[0]
video_height = video_size[1]
# mouse = PyMouse()
pX = -1
pY = -1
#error = []
min_area = point_area[0]
max_area = point_area[1]
process = 1
count = 0
cam1 = GigeE.startCamera(0)
cam2 = GigeE.startCamera(1)
if cam1 == None or cam2 == None:
callback(False)
return
#i = 0
callback(True)
#CursorHider.cursor_hider_open()
global gl_cam_running
gl_cam_running = True
while (gl_cam_running):
count = count + process_ratio
if count >= 1:
count = count - 1
img1 = GigeE.GetImage(cam1, video_height, video_width)
img1 = cv2.warpPerspective(img1, perspective1, (maxWidth1, maxHeight1))
img1 = cv2.resize(img1,(round(screen_width/2), screen_height))
img2 = GigeE.GetImage(cam2, video_height, video_width)
img2 = cv2.warpPerspective(img2, perspective2, (maxWidth2, maxHeight2))
img2 = cv2.resize(img2,(round(screen_width/2), screen_height))
img = np.hstack([img1, img2])
#i=i+1
#cv2.imwrite("./img_join/img_join_"+str(i)+'.png',img)
img = cv2.cvtColor(img, cv2.COLOR_BayerBG2BGR)
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) #Color to grayscale))
#sp = img.shape
#frame_height,frame_width = sp[:2]
#img = cv2.medianBlur(img,5) #median filtering
ret,thresh = cv2.threshold(img,light,255,0) #Binarization
image,contours,hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
if show_frame == True:
#cv2.drawContours(img,contours,-1,(255,255,0),15)
new_img = cv2.resize(img,(round(screen_width/2), round(screen_height/2)))
cv2.imshow("mouse_move", new_img)
found_cnt = None
processable = True
for cnt in contours:
area = cv2.contourArea(cnt)
if area <= max_area and area >= min_area:
if found_cnt is not None:
print("error: found multiple point, skip!")
processable = False
break
found_cnt = cnt
#if len(contours) != 1:
# print(len(contours))
if processable == True and found_cnt is not None:
M = cv2.moments(found_cnt)
if M["m00"] != 0:
cX = int(M["m10"]/M["m00"]) #Calculate the centroid
cX = int(cX + (cX - screen_width/2)*monitor_ratio)
#cX = int(cX + (cX - screen_width)*monitor_ratio)
if cX < 0:
cX = 0
if cX > screen_width:
cX = screen_width
cY = int(M["m01"]/M["m00"])
cY = int(cY + (cY - screen_height/2)*monitor_ratio)
#cY = int(cY + (cY - screen_height)*monitor_ratio)
if cY < 0:
cY = 0
if cY > screen_height:
cY = screen_height
if pX != cX or pY != cY:
pX = cX
pY = cY
#print("x:", round(cX*screen_width/frame_width), ", y:", round(cY*screen_height/frame_height))
if is_mouse_follow == True:
points = filter.update((cX, cY))
#MouseEvent.mouse_move(points[0], points[1], main_screen_width, main_screen_height)
if mousehandler is not None:
mousehandler.mouse_move(points[0], points[1])
if cv2.waitKey(10) & 0xFF == ord('q'):
break
GigeE.closeCamera(cam1)
GigeE.closeCamera(cam2)
cv2.destroyAllWindows()
def stop_mouse_follow():
global gl_cam_running
if gl_cam_running == True:
#CursorHider.cursor_hider_close()
gl_cam_running = False
def is_running():
global gl_cam_running
return gl_cam_running
def get_perspective(pts):
rect = MouseVideo.order_points(pts)
(tl, tr, br, bl) = rect
widthA = np.sqrt(((br[0] - bl[0]) ** 2) + ((br[1] - bl[1]) ** 2))
widthB = np.sqrt(((tr[0] - tl[0]) ** 2) + ((tr[1] - tl[1]) ** 2))
maxWidth = max(int(widthA), int(widthB))
heightA = np.sqrt(((tr[0] - br[0]) ** 2) + ((tr[1] - br[1]) ** 2))
heightB = np.sqrt(((tl[0] - bl[0]) ** 2) + ((tl[1] - bl[1]) ** 2))
maxHeight = max(int(heightA), int(heightB))
dst = np.array([
[0, 0],
[maxWidth - 1, 0],
[maxWidth - 1, maxHeight - 1],
[0, maxHeight - 1]], dtype = "float32")
perspective = cv2.getPerspectiveTransform(rect, dst)
return perspective,maxWidth,maxHeight
def order_points(pts):
rect = np.zeros((4, 2), dtype = "float32")
s = pts.sum(axis = 1)
rect[0] = pts[np.argmin(s)]
rect[2] = pts[np.argmax(s)]
diff = np.diff(pts, axis = 1)
rect[1] = pts[np.argmin(diff)]
rect[3] = pts[np.argmax(diff)]
return rect
# -*- coding: utf-8 -*-
import numpy as np
import cv2
import imutils
import time
from pymouse import PyMouse
import win32api,win32con
from configparser import ConfigParser
from mm_gige import GigeE
def start_mouse_follow(pts, video_url, point_area, screen_size, video_size, show_frame,
is_mouse_follow, process_ratio, monitor_ratio):
perspective1,maxWidth1,maxHeight1 = get_perspective(pts1)
perspective2,maxWidth2,maxHeight2 = get_perspective(pts2)
#screen_width = win32api.GetSystemMetrics(win32con.SM_CXSCREEN)
#screen_height = win32api.GetSystemMetrics(win32con.SM_CYSCREEN)
screen_width = screen_size[0]
screen_height = screen_size[1]
video_width = video_size[0]
video_height = video_size[1]
mouse = PyMouse()
pX = -1
pY = -1
#error = []
min_area = point_area[0]
max_area = point_area[1]
process = 1
count = 0
cam1 = GigeE.startCamera(0)
cam2 = GigeE.startCamera(1)
keyValue = 0
i = 0
while keyValue != ord('q'):
count = count + process_ratio
if count >= 1:
count = count - 1
frame1 = GigeE.GetImage(cam1, video_height, video_width)
frame1 = cv2.cvtColor(frame1, cv2.COLOR_BayerBG2BGR)
frame2 = GigeE.GetImage(cam2, video_height, video_width)
frame2 = cv2.cvtColor(frame2, cv2.COLOR_BayerBG2BGR)
i=i+1
cv2.imwrite("./img/img1_"+str(i)+'.png',frame1)
cv2.imwrite("./img/img2_"+str(i)+'.png',frame2)
# cv2.waitKey(10) # time.sleep 延时没有用
keyValue = cv2.waitKey(10)
cv2.destroyAllWindows()
GigeE.closeCamera(cam1)
keyValue = cv2.waitKey()
cv2.destroyAllWindows()
def create_cap(video_url, video_width, video_height):
cap = cv2.VideoCapture(video_url)
cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('M', 'J', 'P', 'G'))
cap.set(cv2.CAP_PROP_FRAME_WIDTH, video_width)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, video_height)
#cap.set(cv2.CAP_PROP_BUFFERSIZE, 3)
#cap.set(cv2.CAP_PROP_FPS, 30)
return cap
def order_points(pts):
rect = np.zeros((4, 2), dtype = "float32")
s = pts.sum(axis = 1)
rect[0] = pts[np.argmin(s)]
rect[2] = pts[np.argmax(s)]
diff = np.diff(pts, axis = 1)
rect[1] = pts[np.argmin(diff)]
rect[3] = pts[np.argmax(diff)]
return rect
def perspective_transformation(img):
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (5, 5), 0)
dilate = cv2.dilate(blurred, cv2.getStructuringElement(cv2.MORPH_RECT, (3, 3)))
# edged = cv2.Canny(dilate, 75, 200)
edged = cv2.Canny(dilate, 30, 120, 3)
cnts = cv2.findContours(edged.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
cnts = cnts[0] if imutils.is_cv2() else cnts[1]
screen_cnt = None
if len(cnts) > 0:
cnts = sorted(cnts, key=cv2.contourArea, reverse=True)
for c in cnts:
peri = cv2.arcLength(c, True)
approx = cv2.approxPolyDP(c, 0.02 * peri, True)
if len(approx) == 4:
screen_cnt = approx
break
return screen_cnt
if __name__ == "__main__":
cf = ConfigParser()
cf.read('config.ini', encoding='utf-8')
show_frame = cf.get('video', 'is_show')
video_size = json.loads(cf.get('video', 'size'))
point_area = json.loads(cf.get('point', 'area'))
point_light = cf.get('point', 'light')
mouse_follow = cf.get('point', 'is_mouse_follow')
fps_ratio = cf.get('point', 'fps_ratio')
monitor_ratio = cf.get('point', 'monitor_ratio')
screen_size = json.loads(cf.get('screen', 'size'))
is_show_frame = int(show_frame) == 1
is_mouse_follow = int(mouse_follow) == 1
process_ratio = float(fps_ratio)
monitor_ratio = float(monitor_ratio)
light = int(point_light)
if process_ratio > 1:
process_ratio = 1
pts1 = np.array(json.loads(cf.get('correct', 'position1')))
pts2 = np.array(json.loads(cf.get('correct', 'position2')))
start_mouse_follow(pts1, pts2, point_area, screen_size, video_size, light,
is_show_frame, is_mouse_follow, process_ratio, monitor_ratio)
# -*- coding: utf-8 -*-
import numpy as np
import cv2
import imutils
from pymouse import PyMouse
import win32api,win32con
from configparser import ConfigParser
from mm_gige import GigeE
import json
import time
def start_mouse_follow(pts1, pts2, point_area, screen_size, video_size, show_frame,
is_mouse_follow, process_ratio, monitor_ratio):
perspective1,maxWidth1,maxHeight1 = get_perspective(pts1)
perspective2,maxWidth2,maxHeight2 = get_perspective(pts2)
#screen_width = win32api.GetSystemMetrics(win32con.SM_CXSCREEN)
#screen_height = win32api.GetSystemMetrics(win32con.SM_CYSCREEN)
screen_width = screen_size[0]
screen_height = screen_size[1]
video_width = video_size[0]
video_height = video_size[1]
mouse = PyMouse()
pX = -1
pY = -1
#error = []
min_area = point_area[0]
max_area = point_area[1]
process = 1
count = 0
cam1 = GigeE.startCamera(0)
cam2 = GigeE.startCamera(1)
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
videoWrite = cv2.VideoWriter(r'./video/v_' + str(time.time()) + r'.mp4',fourcc,24,(screen_width,screen_height), isColor=False)
i = 0
while (True):
count = count + process_ratio
if count >= 1:
count = count - 1
img1=GigeE.GetImage(cam1, video_height, video_width)
img1=cv2.warpPerspective(img1, perspective1, (maxWidth1, maxHeight1))
img1=cv2.resize(img1,(round(screen_width/2), screen_height))
img2=GigeE.GetImage(cam2, video_height, video_width)
img2=cv2.warpPerspective(img2, perspective2, (maxWidth2, maxHeight2))
img2=cv2.resize(img2,(round(screen_width/2), screen_height))
img = np.hstack([img1, img2])
i=i+1
#cv2.imwrite("./img_join/img_join_"+str(i)+'.png',img)
#cv2.drawContours(img,contours,-1,(0,0,0),2)
if show_frame == True:
new_img = cv2.resize(img,(round(screen_width/2), round(screen_height/2)))
cv2.imshow("mouse_move", new_img)
videoWrite.write(img)
if cv2.waitKey(10) & 0xFF == ord('q'):
break
videoWrite.release()
GigeE.closeCamera(cam1)
GigeE.closeCamera(cam2)
cv2.destroyAllWindows()
def get_perspective(pts):
rect = order_points(pts)
(tl, tr, br, bl) = rect
widthA = np.sqrt(((br[0] - bl[0]) ** 2) + ((br[1] - bl[1]) ** 2))
widthB = np.sqrt(((tr[0] - tl[0]) ** 2) + ((tr[1] - tl[1]) ** 2))
maxWidth = max(int(widthA), int(widthB))
heightA = np.sqrt(((tr[0] - br[0]) ** 2) + ((tr[1] - br[1]) ** 2))
heightB = np.sqrt(((tl[0] - bl[0]) ** 2) + ((tl[1] - bl[1]) ** 2))
maxHeight = max(int(heightA), int(heightB))
dst = np.array([
[0, 0],
[maxWidth - 1, 0],
[maxWidth - 1, maxHeight - 1],
[0, maxHeight - 1]], dtype = "float32")
perspective = cv2.getPerspectiveTransform(rect, dst)
return perspective,maxWidth,maxHeight
def order_points(pts):
rect = np.zeros((4, 2), dtype = "float32")
s = pts.sum(axis = 1)
rect[0] = pts[np.argmin(s)]
rect[2] = pts[np.argmax(s)]
diff = np.diff(pts, axis = 1)
rect[1] = pts[np.argmin(diff)]
rect[3] = pts[np.argmax(diff)]
return rect
if __name__ == "__main__":
cf = ConfigParser()
cf.read('config.ini', encoding='utf-8')
show_frame = cf.get('video', 'is_show')
video_size = json.loads(cf.get('video', 'size'))
point_area = json.loads(cf.get('point', 'area'))
mouse_follow = cf.get('point', 'is_mouse_follow')
fps_ratio = cf.get('point', 'fps_ratio')
monitor_ratio = cf.get('point', 'monitor_ratio')
screen_size = json.loads(cf.get('screen', 'size'))
is_show_frame = int(show_frame) == 1
is_mouse_follow = int(mouse_follow) == 1
process_ratio = float(fps_ratio)
monitor_ratio = float(monitor_ratio)
if process_ratio > 1:
process_ratio = 1
pts1 = np.array(json.loads(cf.get('correct', 'position1')))
pts2 = np.array(json.loads(cf.get('correct', 'position2')))
start_mouse_follow(pts1, pts2, point_area, screen_size, video_size,
is_show_frame, is_mouse_follow, process_ratio, monitor_ratio)
pip install pymouse
pip install pywin32
pip install opencv-python==3.4.3.18
pip install pyuserinput
pip install imutils
pip install ffmpeg-python
pip install keyboard
pip install comtypes
pip install pycaw
pip install twisted
\ No newline at end of file
# -*- coding: utf-8 -*-
import numpy as np
import cv2
import imutils
from pymouse import PyMouse
import win32api,win32con
from configparser import ConfigParser
from mm_gige import GigeE
import json
import time
def start_mouse_follow(pts1, pts2, point_area, screen_size, video_size, show_frame,
is_mouse_follow, process_ratio, monitor_ratio):
perspective1,maxWidth1,maxHeight1 = get_perspective(pts1)
perspective2,maxWidth2,maxHeight2 = get_perspective(pts2)
#screen_width = win32api.GetSystemMetrics(win32con.SM_CXSCREEN)
#screen_height = win32api.GetSystemMetrics(win32con.SM_CYSCREEN)
screen_width = screen_size[0]
screen_height = screen_size[1]
video_width = video_size[0]
video_height = video_size[1]
mouse = PyMouse()
pX = -1
pY = -1
#error = []
min_area = point_area[0]
max_area = point_area[1]
process = 1
count = 0
cam1 = GigeE.startCamera(0)
cam2 = GigeE.startCamera(1)
i = 0
while (True):
count = count + process_ratio
if count >= 1:
count = count - 1
img1 = GigeE.GetImage(cam1, video_height, video_width)
img1 = cv2.warpPerspective(img1, perspective1, (maxWidth1, maxHeight1))
img1 = cv2.resize(img1,(round(screen_width/2), screen_height))
img2 = GigeE.GetImage(cam2, video_height, video_width)
img2 = cv2.warpPerspective(img2, perspective2, (maxWidth2, maxHeight2))
img2 = cv2.resize(img2,(round(screen_width/2), screen_height))
img = np.hstack([img1, img2])
img = cv2.cvtColor(img, cv2.COLOR_BayerBG2BGR)
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) #Color to grayscale))
#sp = img.shape
#frame_height,frame_width = sp[:2]
#img = cv2.medianBlur(img,5) #median filtering
ret,thresh = cv2.threshold(img,20,255,0) #Binarization
image,contours,hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
cv2.drawContours(img,contours,-1,(255,255,0),15)
img = cv2.resize(img,(round(screen_width/2), round(screen_height/2)))
cv2.imshow("mouse_move", img)
if cv2.waitKey(10) & 0xFF == ord('q'):
break
GigeE.closeCamera(cam1)
GigeE.closeCamera(cam2)
cv2.destroyAllWindows()
def get_perspective(pts):
rect = order_points(pts)
(tl, tr, br, bl) = rect
widthA = np.sqrt(((br[0] - bl[0]) ** 2) + ((br[1] - bl[1]) ** 2))
widthB = np.sqrt(((tr[0] - tl[0]) ** 2) + ((tr[1] - tl[1]) ** 2))
maxWidth = max(int(widthA), int(widthB))
heightA = np.sqrt(((tr[0] - br[0]) ** 2) + ((tr[1] - br[1]) ** 2))
heightB = np.sqrt(((tl[0] - bl[0]) ** 2) + ((tl[1] - bl[1]) ** 2))
maxHeight = max(int(heightA), int(heightB))
dst = np.array([
[0, 0],
[maxWidth - 1, 0],
[maxWidth - 1, maxHeight - 1],
[0, maxHeight - 1]], dtype = "float32")
perspective = cv2.getPerspectiveTransform(rect, dst)
return perspective,maxWidth,maxHeight
def order_points(pts):
rect = np.zeros((4, 2), dtype = "float32")
s = pts.sum(axis = 1)
rect[0] = pts[np.argmin(s)]
rect[2] = pts[np.argmax(s)]
diff = np.diff(pts, axis = 1)
rect[1] = pts[np.argmin(diff)]
rect[3] = pts[np.argmax(diff)]
return rect
if __name__ == "__main__":
cf = ConfigParser()
cf.read('config.ini', encoding='utf-8')
show_frame = cf.get('video', 'is_show')
video_size = json.loads(cf.get('video', 'size'))
point_area = json.loads(cf.get('point', 'area'))
mouse_follow = cf.get('point', 'is_mouse_follow')
fps_ratio = cf.get('point', 'fps_ratio')
monitor_ratio = cf.get('point', 'monitor_ratio')
screen_size = json.loads(cf.get('screen', 'size'))
is_show_frame = int(show_frame) == 1
is_mouse_follow = int(mouse_follow) == 1
process_ratio = float(fps_ratio)
monitor_ratio = float(monitor_ratio)
if process_ratio > 1:
process_ratio = 1
pts1 = np.array(json.loads(cf.get('correct', 'position1')))
pts2 = np.array(json.loads(cf.get('correct', 'position2')))
start_mouse_follow(pts1, pts2, point_area, screen_size, video_size,
is_show_frame, is_mouse_follow, process_ratio, monitor_ratio)
# -*- coding: utf-8 -*-
import numpy as np
from configparser import ConfigParser
import json
import ctypes
import tkinter
from tkinter import *
import keyboard
import inspect
from ctypes import cast, POINTER
from comtypes import CLSCTX_ALL
import pythoncom
from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume
from mm_video import MouseVideo
from mm_udp_service import UdpService
from mm_event_mouse import MouseEvent
from mm_event_remote_mouse import RemoteMouseEvent, MultiScreenMouseEvent
import datetime
from threading import Thread
MOUSEHANDLER = None
def volume_change():
pythoncom.CoInitialize()
devices = AudioUtilities.GetSpeakers()
interface = devices.Activate(IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
volume = cast(interface, POINTER(IAudioEndpointVolume))
# 判断是否静音,mute为1代表是静音,为0代表不是静音
mute = volume.GetMute()
if mute == 0:
volume.SetMute(1, None)
else:
volume.SetMute(0, None)
def start_open_point():
cfg = ConfigParser()
cfg.read('config.ini', encoding='utf-8')
show_frame = cfg.get('video', 'is_show')
video_size = json.loads(cfg.get('video', 'size'))
point_area = json.loads(cfg.get('point', 'area'))
point_light = cfg.get('point', 'light')
mouse_follow = cfg.get('point', 'is_mouse_follow')
fps_ratio = cfg.get('point', 'fps_ratio')
monitor_ratio = cfg.get('point', 'monitor_ratio')
is_merge = json.loads(cfg.get('screen', 'is_merge'))
is_show_frame = int(show_frame) == 1
is_mouse_follow = int(mouse_follow) == 1
process_ratio = float(fps_ratio)
monitor_ratio = float(monitor_ratio)
is_merge = int(is_merge) == 1
screen_width = int(cfg.get("screen", "screen_width"))
screen_height = int(cfg.get("screen", "screen_height"))
layout = json.loads(cfg.get("screen", "layout"))
light = int(point_light)
if process_ratio > 1:
process_ratio = 1
pts1 = np.array(json.loads(cfg.get('correct', 'position1')))
pts2 = np.array(json.loads(cfg.get('correct', 'position2')))
global MOUSEHANDLER
MOUSEHANDLER = MultiScreenMouseEvent(screen_width, screen_height, layout, speed_mode=True)
MouseVideo.start_mouse_follow(mouse_follow_callback, pts1, pts2, point_area, video_size, light,
is_show_frame, is_mouse_follow, process_ratio, monitor_ratio, screen_width, screen_height, mousehandler=MOUSEHANDLER)
#thread = Thread(target=start_mouse_follow)
#thread.start()
def mouse_follow_callback(flag):
global gl_win
if flag == True:
btn_disable(DISABLED, NORMAL)
print_info("打开激光笔成功")
gl_win.iconify()
else:
btn_disable(NORMAL, DISABLED)
print_info("打开摄像头失败")
def open_point():
if MouseVideo.is_running() == False:
btn_disable(DISABLED, DISABLED)
thread = Thread(target=start_open_point)
thread.start()
def keyboard_listen():
global gl_keyboard_open
global gl_keyboard_close
gl_keyboard_open = Thread(target=start_open_listener)
gl_keyboard_open.start()
gl_keyboard_close = Thread(target=start_close_listener)
gl_keyboard_close.start()
def start_open_listener():
keyboard.add_hotkey('ctrl+alt+z', open_point)
keyboard.wait('ctrl+shift+alt+esc+z')
def start_close_listener():
keyboard.add_hotkey('ctrl+alt+x', close_point)
keyboard.wait('ctrl+shift+alt+esc+x')
def stop_keyboard_listen():
global gl_keyboard_open
global gl_keyboard_close
_async_raise(gl_keyboard_open.ident, SystemExit)
_async_raise(gl_keyboard_close.ident, SystemExit)
def _async_raise(tid, exctype):
"""raises the exception, performs cleanup if needed"""
tid = ctypes.c_long(tid)
if not inspect.isclass(exctype):
exctype = type(exctype)
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype))
if res == 0:
raise ValueError("invalid thread id")
elif res != 1:
# """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed")
def open_udp_service():
thread = Thread(target=start_udp_service)
thread.start()
gl_left_clicked = None
gl_left_long_clicked = None
gl_left_long_clicked_release = None
gl_left_double_clicked = None
gl_right_clicked = None
gl_right_long_clicked = None
gl_right_long_clicked_release = None
gl_right_double_clicked = None
gl_page_up_clicked = None
gl_page_down_clicked = None
gl_switch_clicked = None
gl_audio_clicked = None
def start_udp_service():
global gl_left_clicked
global gl_left_long_clicked
global gl_left_long_clicked_release
global gl_left_double_clicked
global gl_right_clicked
global gl_right_long_clicked
global gl_right_long_clicked_release
global gl_right_double_clicked
global gl_page_up_clicked
global gl_page_down_clicked
global gl_switch_clicked
global gl_audio_clicked
cf = ConfigParser()
cf.read('config.ini', encoding='utf-8')
gl_left_clicked = replaceWrap(cf.get('order', 'left_clicked'))
gl_left_long_clicked = replaceWrap(cf.get('order', 'left_long_clicked'))
gl_left_long_clicked_release = replaceWrap(cf.get('order', 'left_long_clicked_release'))
gl_left_double_clicked = replaceWrap(cf.get('order', 'left_double_clicked'))
gl_right_clicked = replaceWrap(cf.get('order', 'right_clicked'))
gl_right_long_clicked = replaceWrap(cf.get('order', 'right_long_clicked'))
gl_right_long_clicked_release = replaceWrap(cf.get('order', 'right_long_clicked_release'))
gl_right_double_clicked = replaceWrap(cf.get('order', 'right_double_clicked'))
gl_page_up_clicked = replaceWrap(cf.get('order', 'page_up_clicked'))
gl_page_down_clicked = replaceWrap(cf.get('order', 'page_down_clicked'))
gl_switch_clicked = replaceWrap(cf.get('order', 'switch_clicked'))
gl_audio_clicked = replaceWrap(cf.get('order', 'audio_clicked'))
port = int(cf.get('udp_service', 'port'))
UdpService.start_service(port, udp_revice)
def replaceWrap(str):
return str.replace('\\r', '\r').replace('\\n', '\n')
def udp_revice(str):
global MOUSEHANDLER
global gl_left_clicked
global gl_left_long_clicked
global gl_left_long_clicked_release
global gl_left_double_clicked
global gl_right_clicked
global gl_right_long_clicked
global gl_right_long_clicked_release
global gl_right_double_clicked
global gl_page_up_clicked
global gl_page_down_clicked
global gl_switch_clicked
global gl_audio_clicked
print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"), "received udp msg:", str)
if str == gl_left_clicked:
#MouseEvent.mouse_left_click()
MOUSEHANDLER.LeftClick()
elif str == gl_left_long_clicked:
#MouseEvent.mouse_left_down()
MOUSEHANDLER.LeftDown()
elif str == gl_left_long_clicked_release:
#MouseEvent.mouse_left_up()
MOUSEHANDLER.LeftUp()
elif str == gl_left_double_clicked:
#MouseEvent.mouse_left_dbclick()
MOUSEHANDLER.LeftDoubleClick()
elif str == gl_right_clicked:
#MouseEvent.mouse_right_click()
MOUSEHANDLER.RightClick()
elif str == gl_right_long_clicked:
#MouseEvent.mouse_right_down()
MOUSEHANDLER.RightDown()
elif str == gl_right_long_clicked_release:
#MouseEvent.mouse_right_up()
MOUSEHANDLER.RightUp()
elif str == gl_right_double_clicked:
#MouseEvent.mouse_right_dbclick()
MOUSEHANDLER.RightClick()
MOUSEHANDLER.RightClick()
elif str == gl_page_up_clicked:
#MOUSEHANDLER.mouse_middle_up()
MOUSEHANDLER.MouseWheel(2)
elif str == gl_page_down_clicked:
#MOUSEHANDLER.mouse_middle_down()
MOUSEHANDLER.MouseWheel(-2)
elif str == gl_switch_clicked:
if MouseVideo.is_running() == True:
close_point()
else:
open_point()
elif str == gl_audio_clicked:
volume_change()
def close_point():
MouseVideo.stop_mouse_follow()
btn_disable(NORMAL, DISABLED)
print_info("关闭激光笔成功")
def print_info(info):
global gl_info_label
gl_info_label.config(text = info)
def btn_disable(disable_open_btn, disable_close_btn):
global gl_open_btn
global gl_close_btn
gl_open_btn.config(state = disable_open_btn)
gl_close_btn.config(state = disable_close_btn)
def close_win():
global gl_win
print_info("正在关闭激光笔...")
MouseVideo.stop_mouse_follow()
stop_keyboard_listen()
UdpService.stop_service()
#time.sleep(1)
gl_win.destroy()
def show_win():
global gl_open_btn
global gl_close_btn
global gl_info_label
global gl_win
ctypes.windll.user32.ShowWindow(ctypes.windll.kernel32.GetConsoleWindow(), 6)
gl_win = tkinter.Tk()
gl_win.geometry('420x160')
gl_win.title('云和激光笔')
gl_win.resizable(False, False)
gl_open_btn = Button(gl_win, text='打开激光笔', width=14, height=2, bg='pink', command=open_point)
gl_open_btn.place(x=70, y=40)
gl_close_btn= Button(gl_win, text='关闭激光笔', width=14, height=2, bg='pink', command=close_point)
gl_close_btn.place(x=220, y=40)
gl_info_label = Label(gl_win, text='')
gl_info_label.place(x=70, y=100)
tip_open_label = Label(gl_win, text='打开激光笔快捷键:Ctrl+Alt+Z')
tip_open_label.place(x=215, y=100)
tip_close_label = Label(gl_win, text='关闭激光笔快捷键:Ctrl+Alt+X')
tip_close_label.place(x=215, y=120)
btn_disable(NORMAL, DISABLED)
gl_win.protocol('WM_DELETE_WINDOW', close_win)
keyboard_listen()
open_udp_service()
gl_win.mainloop()
gl_keyboard_open = None
gl_keyboard_close = None
gl_info_label = None
gl_open_btn = None
gl_close_btn = None
gl_win = None
if __name__ == "__main__":
show_win()
\ No newline at end of file
# -*- coding: utf-8 -*-
import numpy as np
import cv2
import imutils
from pymouse import PyMouse
import win32api,win32con
from configparser import ConfigParser
import json
import ctypes
import tkinter
from tkinter import *
from tkinter import ttk
import subprocess,os
from threading import Thread
def show_win():
command = 'reg add "HKCU\Control Panel\Cursors" /f /ve /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Scheme Source" /t REG_DWORD /d 0\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Arrow" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Help" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "AppStarting" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Wait" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Crosshair" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "IBeam" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "NWPen" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "No" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "SizeNS" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "SizeWE" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "SizeNWSE" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "SizeNESW" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "SizeAll" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "UpArrow" /t REG_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Person" /t REG_EXPAND_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Hand" /t REG_EXPAND_SZ /d ""\
&& reg add "HKCU\Control Panel\Cursors" /f /v "Pin" /t REG_EXPAND_SZ /d ""\
&& reg delete "HKCU\Control Panel\Cursors\Schemes" /f /v "videomouse"'
os.system(command)
dll = ctypes.windll.LoadLibrary('user32')
dll.SystemParametersInfoW(87,0,0,2)
if __name__ == "__main__":
show_win()
from win32 import win32api, win32gui, win32print
from win32.lib import win32con
from mm_event_mouse import MouseEvent
#MouseEvent.test()
hDC = win32gui.GetDC(0)
main_screen_width = win32print.GetDeviceCaps(hDC, win32con.DESKTOPHORZRES)
main_screen_height = win32print.GetDeviceCaps(hDC, win32con.DESKTOPVERTRES)
print(main_screen_width, main_screen_height);
#MouseEvent.mouse_move(-2860, 800, main_screen_width, main_screen_height)
count = win32api.GetSystemMetrics(win32con.SM_CMONITORS);
print(count);
\ No newline at end of file
@echo off
@echo off
python print_video.py
\ No newline at end of file
@echo off
@echo off
python print_img.py
\ No newline at end of file
@echo off
@echo off
python start.py
\ No newline at end of file
@echo off
@echo off
python stop_cursor.py
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论