Live Streaming Video Chat App without voice
OpenCV-Python is a library of Python bindings designed to solve computer vision problems. It is a cross-platform library using which we can develop real-time computer vision applications. It mainly focuses on image processing, video capture and analysis including features like face detection and object detection.
When it is integrated with various libraries, such as Numpy which is a highly optimized library for numerical operations, then whatever operations one can do in Numpy can be combined with OpenCV.
Client Server Model in Python Programming
A client and server networking model is a model in which computers such as servers provide the network services to the other computers such as clients to perform a user based tasks. This model is known as client-server networking model.
- A client is a program that runs on the local machine requesting service from the server. A client program is a finite program means that the service started by the user and terminates when the service is completed.
- A server is a program that runs on the remote machine providing services to the clients. When the client requests for a service, then the server opens the door for the incoming requests, but it never initiates the service.
Socket programming is a way of connecting two nodes on a network to communicate with each other. One socket(node) listens on a particular port at an IP, while other socket reaches out to the other to form a connection. Server forms the listener socket while client reaches out to the server.
They are the real backbones behind web browsing. In simpler terms there is a server and a client.
Three types of Network Sockets:
- Stream sockets allow processes to communicate using TCP. A stream socket provides bidirectional, reliable, sequenced, and unduplicated flow of data with no record boundaries. …
- Datagram sockets allow processes to use UDP to communicate. …
- Raw sockets provide access to ICMP.
TCP stands for Transmission Control Protocol a communications standard that enables application programs and computing devices to exchange messages over a network. It is designed to send packets across the internet and ensure the successful delivery of data and messages over networks.
AF_INET is the Internet address family for IPv4. SOCK_STREAM is the socket type for TCP, the protocol that will be used to transport our messages in the network. The values passed to bind() depend on the address family of the socket.
A port number is the logical address of each application or process that uses a network or the Internet to communicate. A port number uniquely identifies a network-based application on a computer.
OpenCV allows a straightforward interface to capture live stream with the camera (webcam). It converts video into grayscale and display it. We need to create a Video Capture object to capture a video.
- To read the images cv2.imread() method is used.
- socket.sendall is a high-level Python-only method that sends the entire buffer you pass or throws an exception.
- First of all, We have to import Some Python Libraries to make our chat app those Libraries are cv2, socket, struct, and pickle.
- we are creating a network socket using the python socket library to make our work easier.
- We are creating a network socket using the python socket library to make our work easier.
- We are selecting the webcam to use for the video chat.
- Then we are using a while loop that will capture our video feed.
- Then imshow function is used to display the webcam window
When we execute these two files you will get two windows with webcam on .
The proposed Video Chat app can be used as a communication system for face-to-face interaction. Due to the growing use of internet-based communication systems, the scope of similar applications is getting bigger. It can be used from anywhere by anyone having an internet connection.
We have Successfully Created a Simple Video Chat application in Python. It can be improved further by adding more functionality and a UI can also be implemented to make it easier to use.