What to do without a USB camera.
It's okay to have an Android phone, we can turn it into a webcam.
1. Install a mobile phone called [IP Camera] app, get IP address, account password
2. Install Python and OpenCV
3. Execute the Python script below, and notice that you want to change the IP address to the one displayed on your phone.
#coding =utf-8
Import CV2.CV as CV
import time
if __name__ = ' __main__ ':
cv. Namedwindow ("Camera", 1)
#开启ip摄像头
video= "http://admin:admin@192.168.0.123:8081/"
capture =CV. Capturefromfile (VIDEO)
num = 0;
While True:
img = cv. Queryframe (Capture)
CV. ShowImage ("Camera", IMG)
#按键处理, note that the focus should be in the camera window, not in the Terminal Command Line window
key = CV. Waitkey (a)
if key = =
#esc键退出
print "Esc break ..." Break
if key = = Ord ('):
#保存一张图像 C19/>num = num+1
filename = "frames_%s.jpg"% num
cv. SaveImage (filename,img)
del (capture)
CV. DestroyWindow ("Camera")
Run the APP:IP camera on the phone first, click on the button at the bottom [turn the device into an IP camera],
Then run the python script in Ubuntu, wait a few seconds, and you'll see the camera content.