Python 3 OpenCV + Numpy + Imutils Library Script to Connect PC to Android Phone and Streaming Live Webcam Video and Save Image Full Project For Beginners

Python 3 OpenCV + Numpy + Imutils Library Script to Connect PC to Android Phone and Streaming Live Webcam Video and Save Image Full Project For Beginners

 

Welcome folks today in this blog post we will be connecting android phone to pc using python and opencv library. All the full source code of the application is shown below.

 

 

Get Started

 

 

In order to get started you need to install the following library using the pip command as shown below

 

pip install opencv-python

 

pip install imutils

 

pip install numpy

 

And after this just download the ip webcam android app from the play store here

 

 

And after it open this app on phone and then start the server you will receive a unique url you need to open the url inside the browser as shown below

 

 

 

After installing this library make an app.py file and copy paste the following code

 

app.py

 

# Import essential libraries 
import requests 
import cv2 
import numpy as np 
import imutils 

# Replace the below URL with your own. Make sure to add "/shot.jpg" at last. 
url = "http://192.168.1.4:8080/shot.jpg"

# While loop to continuously fetching data from the Url 
while True: 
    img_resp = requests.get(url) 
    img_arr = np.array(bytearray(img_resp.content), dtype=np.uint8) 
    img = cv2.imdecode(img_arr, -1) 
    img = imutils.resize(img, width=1000, height=1800) 
    cv2.imshow("Android_cam", img) 

    # Press Esc key to exit 
    if cv2.waitKey(1) == 27: 
        break

cv2.destroyAllWindows()

 

See also  Python 3 Mortgage Interest Monthly Loan Payment Calculator in Command Line or Terminal Full Project For Beginners

 

Inside the python script you need to replace the unique url and then run the script by typing the below command

 

python app.py

 

 

Leave a Reply