Python 3 Tkinter Script to Access Live IP Camera RTSP Video Stream Using FFMPEG & OpenCV Library GUI Desktop App
capture = cv2.VideoCapture(<span class="hljs-string">'rtsp://192.168.1.64/1'</span>)
capture = cv2.VideoCapture(<span class="hljs-string">'rtsp://username:[email protected]/1'</span>)
import cv2 #print("Before URL")cap = cv2.VideoCapture('rtsp://admin:[email protected]/H264?ch=1&subtype=0')#print("After URL") while True: #print('About to start the Read command') ret, frame = cap.read() #print('About to show frame of Video.') cv2.imshow("Capturing",frame) #print('Running..') if cv2.waitKey(1) & 0xFF == ord('q'): break cap.release()cv2.destroyAllWindows()
<span class="hljs-keyword">import</span> cv2 <span class="hljs-comment">#print("Before URL")</span>cap = cv2.VideoCapture(<span class="hljs-string">'rtsp://admin:[email protected]/H264?ch=1&subtype=0'</span>)<span class="hljs-comment">#print("After URL")</span> <span class="hljs-keyword">while</span> <span class="hljs-literal">True</span>: <span class="hljs-comment">#print('About to start the Read command')</span> ret, frame = cap.read() <span class="hljs-comment">#print('About to show frame of Video.')</span> cv2.imshow(<span class="hljs-string">"Capturing"</span>,frame) <span class="hljs-comment">#print('Running..')</span> <span class="hljs-keyword">if</span> cv2.waitKey(<span class="hljs-number">1</span>) & <span class="hljs-number">0xFF</span> == <span class="hljs-built_in">ord</span>(<span class="hljs-string">'q'</span>): <span class="hljs-keyword">break</span> cap.release()cv2.destroyAllWindows()
import cv2 cap = cv2.VideoCapture('http://192.168.18.37:8090/video') while(True): ret, frame = cap.read() cv2.imshow('frame',frame) if cv2.waitKey(1) & 0xFF == ord('q'): cv2.destroyAllWindows() break
"""Access IP Camera in Python OpenCV""" import cv2 stream = cv2.VideoCapture('protocol://IP:port/1') # Use the next line if your camera has a username and password# stream = cv2.VideoCapture('protocol://username:password@IP:port/1') while True: r, f = stream.read() cv2.imshow('IP Camera stream',f) if cv2.waitKey(1) & 0xFF == ord('q'): break cv2.destroyAllWindows()