_sdk = windll.MVCAMSDK if

博客内容涉及工业相机的使用,指出在_x86和_x64环境下可能缺少MindVision相机SDK。解决方案是下载并安装MindVisionCameraPlatformSetup(2.1.10.135)来修复这个问题。
摘要由CSDN通过智能技术生成

_sdk = windll.MVCAMSDK if is_x86 else windll.MVCAMSDK_X64
缺少工业相机插件
下载一个MindVision Camera Platform Setup(2.1.10.135)
在这里插入图片描述

#精准延迟包: from ctypes import windll import cv2 ##检测模式 import numpy as np #为睡眠做准备 TimeBeginPeriod = windll.winmm.timeBeginPeriod HPSleep = windll.kernel32.Sleep TimeEndPeriod = windll.winmm.timeEndPeriod #精准延迟 def Precise_delay(num): # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TimeBeginPeriod(1) HPSleep(int(num)) # 减少报错 TimeEndPeriod(1) #截图模式 def Screenshot_Mode(ps_mode , pos_x,pos_y,mcx,mcy): if ps_mode == 0: from mss import mss Screenshot_value = mss() #目标检测范围 window_size_mss = (pos_x- mcx , pos_y - mcy , pos_x + mcx , pos_y + mcy) # monitor = 960-320,540-320,960+320,540+320 window_size = { "left":pos_x- mcx, "top":pos_y - mcy, "width":pos_x + mcx, "height":pos_y + mcy, } #目标检测中心点 core_x = int((window_size_mss[2]-window_size_mss[0])/2) core_y = int((window_size_mss[3]-window_size_mss[1])/2) elif ps_mode == 1: print("使用DXGI截图") from d3dshot import create # pip install d3dshot -i https://pypi.tuna.tsinghua.edu.cn/simple Screenshot_value = create("numpy",frame_buffer_size = 100) #目标检测范围 window_size = (pos_x- mcx , pos_y - mcy , pos_x + mcx , pos_y + mcy) #目标检测中心点 core_x = int((window_size[2]-window_size[0])/2) core_y = int((window_size[3]-window_size[1])/2) return window_size,core_x,core_y,Screenshot_value #检测模式 def Detection_mode(test_mode,Screenshot_value,window_size): if test_mode == 0: img = Screenshot_value.grab(window_size) img = np.array(img) img = cv2.cvtColor(img, cv2.COLOR_BGRA2BGR)#原版 elif test_mode == 1: img = Screenshot_value.screenshot(region=window_size) #使用opencv删除一个通道 img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR) return img window_size,core_x,core_y,Screenshot_value = Screenshot_Mode(0, 960, 540, 150, 150) print(window_size,core_x,core_y,Screenshot_value) img = Detection_mode(0, Screenshot_value, window_size) print(img) 这个代码实现了什么功能
07-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值