使用OpenCV Python从Android智能手机捕获视频 [英] Capturing Video from Android Smartphone using OpenCV Python

查看:322
本文介绍了使用OpenCV Python从Android智能手机捕获视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用Python学习OpenCV,第一个教程从使用内置笔记本电脑网络摄像头或外部网络摄像头捕获视频开始.而且,正如可能发生的那样,我都没有.因此,我认为是否有可能使用我的Android智能手机的摄像头,然后使用IP捕获该视频以进行进一步处理.

I have just started learning OpenCV using Python and the first tutorial starts with capturing video using either in built laptop webcam or external webcam. And as it would happen, I have neither. So I thought if it would be possible to use Camera of my Android Smartphone and then capture that video using IP for further processing.

我的智能手机:Moto E

My Smartphone: Moto E

操作系统:Windows 7

OS: Windows 7

语言:Python

Android应用程序:IP网络摄像头

Android Application : IP Webcam

我已经在网上进行了广泛搜索,但是找不到任何可行的解决方案,所以任何人都可以指导我如何使用IP网络摄像头从智能手机捕获视频.

I have searched the net extensively but am unable to find any working solution, so can anyone please guide me on how to capture the video from my smartphone using IP Webcam.

很抱歉没有发布任何代码,因为我正趋向这一领域,所以毫无头绪.

Sorry for posting no code as I am just trending into this field so am completely clueless.

谢谢.

推荐答案

Android"IP网络摄像头"应用视频流使用urllib和numpy导入到Python OpenCV;)

Android 'IP Webcam' App video stream import to Python OpenCV using urllib and numpy;)

import urllib
import cv2
import numpy as np
import time

# Replace the URL with your own IPwebcam shot.jpg IP:port
url='http://192.168.2.35:8080/shot.jpg'

while True:

    # Use urllib to get the image and convert into a cv2 usable format
    imgResp=urllib.urlopen(url)
    imgNp=np.array(bytearray(imgResp.read()),dtype=np.uint8)
    img=cv2.imdecode(imgNp,-1)

    # put the image on screen
    cv2.imshow('IPWebcam',img)

    #To give the processor some less stress
    #time.sleep(0.1) 

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

这篇关于使用OpenCV Python从Android智能手机捕获视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆