Skip to content

Instantly share code, notes, and snippets.

@chilin0525
Last active May 1, 2021 12:04
Show Gist options
  • Save chilin0525/b60aa0a2c90f783b8bd301b3d5fb6268 to your computer and use it in GitHub Desktop.
Save chilin0525/b60aa0a2c90f783b8bd301b3d5fb6268 to your computer and use it in GitHub Desktop.
Using android phone as webcam by opencv 4.x version.
import urllib.request
import cv2
import numpy as np
import time
import requests
URL = "http://192.168.1.101:8080/shot.jpg"
while True:
img_arr = np.array(
bytearray(urllib.request.urlopen(URL).read()), dtype=np.uint8)
img = cv2.imdecode(img_arr, -1)
cv2.imshow('IPWebcam', img)
if cv2.waitKey(0) & 0xFF == ord('q'):
break
@chilin0525
Copy link
Author

Warning: QT_DEVICE_PIXEL_RATIO is deprecated. Instead use:
   QT_AUTO_SCREEN_SCALE_FACTOR to enable platform plugin controlled per-screen factors.
   QT_SCREEN_SCALE_FACTORS to set per-screen DPI.
   QT_SCALE_FACTOR to set the application global scale factor.

solution:

export QT_DEVICE_PIXEL_RATIO=0
export QT_AUTO_SCREEN_SCALE_FACTOR=1
export QT_SCREEN_SCALE_FACTORS=1
export QT_SCALE_FACTOR=1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment