GithubHelp home page GithubHelp logo

socket-video-streaming's Introduction

Socket-Video-Streaming

Socket programming to send and receive webcam video

What is socket?

A socket is a software abstraction that allows communication between two computers over a network. It provides an interface for programs to send and receive data across a network or between processes on the same machine.

In the context of computer networking, a socket is identified by an IP address and a port number, which together uniquely identify a specific endpoint of communication. The combination of IP address and port number on a system is often referred to as a socket address.

Sockets can be used in various network protocols, such as TCP (Transmission Control Protocol) or UDP (User Datagram Protocol), to establish a connection and exchange data between client and server applications.

A socket can be either a client or a server. The client socket initiates a connection to a server socket, and the server socket listens for incoming connections from client sockets. Once a connection is established, both the client and server sockets can send and receive data.

In programming, sockets are typically implemented through socket libraries or APIs provided by the operating system. These libraries provide functions and methods to create, configure, and manage sockets, as well as send and receive data over the network.

Overall, sockets form the foundation of network communication, enabling applications to communicate and exchange data in a networked environment.

How to run the code

Step 1: Open SocketWebCam folder (VSCode)

Open SocketWebCam folder There is 2 files:

  • server.py - This code is for setting up a server that captures video frames from a webcam using OpenCV and sends them over a socket connection to a client
  • client.py - This code represents the client-side implementation to receive and display video frames from the server

Step 2: Run the server

Open the server.py file

Open Terminal and run $python3 server.py to start the server (Make sure you have already installed all necessary libraries like socket, cv2, imutils,... before running the server.py file)

Get the server's socket address: IP address (xxx.xxx.xxx.xxx), the defined port (9999), copy it so the client can make a connection to the HOST (server)

Step 3: Run the client

Open the client.py file

Replace 'xxx.xxx.xxx' with the actual IP address of the server Open Terminal and run $python3 client.py to start the client (Make sure you have already installed all necessary libraries like socket, cv2,... before running the client.py file)

THAT'S IT

The client is now continuously receives data packets from the server and reconstructs the video frames. The received frames are then displayed using cv2.imshow.

Make sure the client code is executed after the server code is running, and replace 'xxx.xxx.xxx' with the actual IP address of the server you want to connect to.

Pressing 'q' will break the loop and close the client socket.

socket-video-streaming's People

Contributors

qyt0109 avatar

Watchers

 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.