Multi-Camera-Live-Object-Tracking
Multi-Camera-Live-Object-Tracking copied to clipboard
HI, now .i want to use a video local to test this model , help me please
Hi,
it is probably easiest to emulate an IP camera with a server that streams a video. I appended some code that does that, of course you can also start multiple servers with different videos.
@LeonLok Since the question came up multiple times, should I make a pull request with this code? I also have a conda environment file that I could push.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 5 21:20:37 2021
@author: wnklmx
"""
import cv2
import imagezmq
import socket
def create_streamer(file, connect_to="tcp://127.0.0.1:5555", loop=True):
sender = imagezmq.ImageSender(connect_to=connect_to)
host_name = socket.gethostname()
cap = cv2.VideoCapture(file)
ret, frame = cap.read()
while True:
sender.send_image(host_name, frame)
ret, frame = cap.read()
if loop and not ret:
cap = cv2.VideoCapture(file)
ret, frame = cap.read()
if __name__ == "__main__":
streamer = create_streamer("video.mp4")
Hi @wnklmx, yes I think that's how I would do it too, it certainly seems the easiest given the structure of the code.
Please feel free to do a pull request and I'll have a look :)