GithubHelp home page GithubHelp logo

pingf / grpc-video-streaming Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nirvan101/grpc-video-streaming

0.0 0.0 0.0 17 KB

This code streams a video over the internet using Google remote procedural calls. The video is streamed from server to client, it is processed at the client and the results are sent back to the server.

Python 100.00%

grpc-video-streaming's Introduction

Introduction

Using gRPC (Google remote procedural calls) for transferring video over the internet and receiving the results back. The video is sent from the server to the client. The client processes the received video, generates some results and passes these results back to the server. This code uses bi-directinal streaming. Video is streamed from server to client. Results are streamed back from client to server.

Use

This is used to stream live footage from cctv cameras. Video from a CCTV camera is transferred in real-time to a distant proccessing facility. This is because computationally intensive hardware is not located near the camera. At the facility we can use some heavy computational procedure on it like deep learning and transfer the results back to the place at which the camera is located.

In this code, I've performed 'people counting' on the video. The video from the camera is transferred via gRPC. The client, running on another machine, receives this video via the internet. The client performs people counting on the video in real-time and continously transfers the results back i.e the number of people counted till now.

Main requirements:

Grpc openCV skvideo.io

Grpc: https://grpc.io/docs/quickstart/python.html

Install Grpc: python -m pip install grpcio

Install Grpc tools: $ python -m pip install grpcio-tools

Install openCV: sudo apt-get install libopencv-dev python-opencv

Install skvideo: sudo pip install scikit-video

Running the code

First we make the .proto file and place it in the grpcTest/protos folder. We execute the following command from the folder grpcTest.

python -m grpc_tools.protoc -I protos --python_out=. --grpc_python_out=. protos/imageTest.proto

This creates the files imageTest_pb2_grpc.py and imageTest_pb2.py in the folder grpcTest.

We then write the files imageTest_server.py and imageTest_client.py which use the above 2 generated files.

The server sends the video file via a stream of frames. The client receives these frames and continuously processes each frame and counts the number of people entering the video. This count is sent back to the server using streaming.

Note: Use internet through LAN for fastest transfer.

To start server,

python imageTest_server.py

To start client,

python imageTest_client.py

Links for reference

https://grpc.io/docs/tutorials/basic/python.html https://grpc.io/docs/quickstart/python.html https://grpc.io/docs/guides/concepts.html https://grpc.io/docs/guides/concepts.html#bidirectional-streaming-rpc https://stackoverflow.com/questions/47867440/cv2-imshow-giving-black-screen/47867865#47867865 https://stackoverflow.com/questions/47883841/grpc-not-working-when-i-use-2-computers-instead-of-1/47887825#47887825

grpc-video-streaming's People

Contributors

nirvan101 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.