Capturing video from an Android smartphone using OpenCV Python

I just started learning OpenCV using Python, and the first tutorial starts with capturing video using the built-in webcam or an external webcam. And how it will be, I do not have them. So I wondered if it was possible to use the camera of my Android smartphone and then capture this video using IP for further processing.

My smartphone: Moto E

OS: Windows 7

Language: Python

Android App: IP Webcam

I searched the network many times, but could not find any working solution, so someone can advise me how to capture video from my smartphone using an IP webcam.

Sorry for the lack of code, as I just go into this field, so I don’t know at all.

Thank.

+4
source share
3

, , , , .

. (640x480 , 8 , 30 ) 200 /. USB (2) , , .

- 1080p - ?

, , , MPEG4, H.264 VP8. , .

! .

! .

-, , , () . , , ( ) , .

, , , () OpenCV ! , ( OpenCV).

, $15 - ( :)

+6

Android 'IP Webcam' Python OpenCV urllib 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
+2

Source: https://habr.com/ru/post/1598392/


All Articles