Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HI, now .i want to use a video local to test this model , help me please #15

Open
phungthengoc opened this issue Jul 23, 2020 · 2 comments

Comments

@phungthengoc
Copy link

No description provided.

@wnklmx
Copy link
Contributor

wnklmx commented Feb 5, 2021

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")

@LeonLok
Copy link
Owner

LeonLok commented Feb 9, 2021

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants