当前位置:网站首页>[opencv] use OpenCV to call mobile camera
[opencv] use OpenCV to call mobile camera
2022-07-29 02:48:00 【Mr Yunduo_】
One 、 Preface
Droidcam It is a tool that can turn a mobile phone into a webcam , We can use Droidcam Give Way OpenCV Have the ability to call mobile camera .

Two 、 step
2.1 install DroidCam
Install on mobile phone and computer respectively DroidCam The client and server of
Download address :https://pan.baidu.com/s/1DrBn3P1Bx-SXa4d6oziifA?pwd=gr1o
Extraction code :gr1o
2.2 Test connection status
Mobile phones and computers need to be connected to the same Wifi( Or the hotspot where computers connect to mobile phones ).
Turn on the DroidCam Server side , Use your computer browser to visit the following website

If the following page appears , Express DroidCam Installed successfully , Finally, exit the browser .
Only one software can call the mobile camera at a time , If you don't close the browser , Use... In the back OpenCV Calling the mobile camera will report an error .

2.3 Connect the phone camera
At this time, the mobile phone has become a webcam , You can access its video stream through the following link
http://<IP>:<Port>/mjpegfeed?[ The resolution of the ]
- Resolution can be selected
- 320x240
- 640x480
- 960x720
- 1280x720
- 1920x1080
Be careful : Do not exit from the mobile phone during the call of the mobile phone camera DroidCam.
example : Mobile terminal DroidCam The screenshot is as follows , Then the video stream link of the mobile camera is :
http://192.168.31.211:4747/mjpegfeed

Now you can go through OpenCV Call the phone camera
cap = cv2.VideoCapture("http://192.168.31.211:4747/mjpegfeed")
Complete code
''' Author: CloudSir @Github: https://github.com/CloudSir Date: 2022-05-13 10:24:00 LastEditTime: 2022-07-27 11:47:08 LastEditors: CloudSir Description: '''
import cv2
def get_DroidCam_url(ip, port=4747, res='480p'):
res_dict = {
'240p': '320x240',
'480p': '640x480',
'720p': '1280x720',
'1080p': '1920x1080',
}
url = f'http://{
ip}:{
port}/mjpegfeed?{
res_dict[res]}'
return url
# DroidCam According to the IP Address 、 Port number and camera resolution ( Optional 240p,480p,720p,1080p)
cap = cv2.VideoCapture(get_DroidCam_url('192.168.31.211', 4747, '720p'))
while True:
ret, frame = cap.read()
if ret:
cv2.imshow('image', frame)
key = cv2.waitKey(1)
# Press q Exit procedure
if key == ord('q'):
break
# Release VideoCapture
cap.release()
# Destroy all windows
cv2.destroyAllWindows()
3、 ... and 、 Reference material
- Use OpenCV Read DroidCam Camera data for ( In LAN ):https://www.jianshu.com/p/523867890957
- DroidCam - Let the mobile phone act as a wireless camera [Android] - Niche software :https://www.appinn.com/droidcam-for-android/
边栏推荐
- Source code of Jiugongge heart puzzle Applet / source code of main wechat applet with traffic
- Etcd implementation of large-scale service governance application practice
- Why is redis fast? Message queue, single thread
- C language: judging letters
- Others' happiness
- QT screen adaptive automatic layout, drag the window to automatically grow larger and smaller (I)
- 并发模式之生产者消费者模式
- Introduction to network foundation
- CatchAdmin实战教程(四)Table组件相关功能实现
- Which is a good automatic account distribution system?
猜你喜欢

DataGrip 如何导出和恢复整个数据库数据,使用单个 SQL 文件

云开发口袋工具箱微信小程序源码

Where, having, group by, order by, is null, not in, subquery, delete, date function

Asemi rectifier bridge s25vb100, s25vb100 parameters, s25vb100 application

以科技传递温度,vivo亮相数字中国建设峰会

Multimodal Unsupervised Image-to-Image Translation多通道无监督图像翻译

云开发打工人必备上班摸鱼划水微信小程序源码

K210 - sound source location and sound recognition

Flink内核源码(七)Flink SQL提交流程

Double write consistency of MySQL and redis
随机推荐
11.书写规则-伪目标
第九天笔记
FFmpeg+SDL+QT实现简单是视频播放器
Three expiration strategies
C语言:判断字母
Redis队列实现秒杀
ES6 detailed quick start!
Driverless obstacle avoidance technology
云开发口袋工具箱微信小程序源码
Quickly master nodejs installation and getting started
并发模式之单例和不变模式
【OpenCV】使用OpenCV调用手机摄像头
Comic algorithm_ Xiaohuihui interview
FTP协议详解
【无标题】
Multimodal unsupervised image to image translation
童年的快乐时光
Self organization is the two-way rush of managers and members
etcd实现大规模服务治理应用实战
DataGrip 如何导出和恢复整个数据库数据,使用单个 SQL 文件