Python微信机器人-调用电脑摄像头实现监控功能

我想要做的就是遥控电脑,让电脑拍照发送到微信里,这样我的手机端就能接收到了,达到的效果就是远程查看电脑的周边环境,达到一种监控的效果。

调用摄像头我们需要安装VideoCapture库,直接pip是搜不到的,需要我们自己下载来安装。
VideoCapture库下载
Python微信机器人-调用电脑摄像头实现监控功能
这3行代码就可以实现调用摄像头并保存照片的功能。

from VideoCapture import Device

cam = Device()
cam.saveSnapshot('camera.jpg')

下面这个就是完整版的:
我们设定的口令是“拍照”,当接收到这个消息后,机器人就会执行命令,调用摄像头,拍照保存,然后把照片传给发送消息的人。

from VideoCapture import Device
import itchat

# 执行拍照功能
def cameraRecord():
    cam = Device()
    cam.saveSnapshot('camera.jpg')
    
@itchat.msg_register(itchat.content.TEXT,isFriendChat=True)
def camera_itchat(msg): 
    msg_from=msg['FromUserName']
    if '拍照'==msg['Text']:
        cameraRecord()
        itchat.send_image(fileDir='camera.jpg', toUserName=msg_from)

itchat.auto_login(hotReload=True)
itchat.run()

Python微信机器人-调用电脑摄像头实现监控功能
如果运行时出现"fromstring() has been removed. Please call frombytes() instead."错误,下面有解决办法:
Python的VideoCapture库-运行时报错"fromstring() has been removed. Please call frombytes() instead."原因及解决办法