Last active
May 1, 2021 12:04
-
-
Save chilin0525/b60aa0a2c90f783b8bd301b3d5fb6268 to your computer and use it in GitHub Desktop.
Using android phone as webcam by opencv 4.x version.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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
Steps: