Videocall app using Opencv And Socket programming

Ever wondered about how all this video call apps works? Curious right!!!In this article I am going to show you how to create video call app using tcp socket programming and opencv.

Let’s start with concepts / modules used in code for better undestanding of code.

1.socket module

The “socket” module defines how server and client machines can communicate at hardware level using socket endpoints on top of the operating system. The ‘socket’ API supports both connection-oriented and connectionless network protocols.

We are using TCP (connection oriented ) in this example.

2.cv2 module-

OpenCV-Python is a library of Python bindings designed to solve computer vision problems. This package is created to assist the smooth workflow with OpenCV by providing essentials functions such as creating Color Masks of any image/video feed or resizing and rotating it.

3.pickle module-

The pickle module is used for implementing binary protocols for serializing and de-serializing a Python object structure.

  • Pickling: It is a process where a Python object hierarchy is converted into a byte stream.
  • Unpickling: It is the inverse of Pickling process where a byte stream is converted into an object hierarchy.

Module interface-

  • dumps() — This function is called to serialize an object hierarchy.
  • loads() — This function is called to de-serialize a data stream.

4.struct module -

The module struct is used to convert the native data types of Python into string of bytes and vice versa. We don’t have to install it. It’s a built-in module available in Python3.


The method struct.pack() is used to convert the data types into bytes. It takes multiple arguments based on the first string.


We have another method struct.unpack() that converts bytes to native Python data types. It takes two arguments, the first one is similar to the pack() method and the second one is the result of struct.pack() method.

The method struct.unpack() always returns a tuple.

Server Side Code :

Client Side code:

Code output:

We have to first run server side program:

After this run client side code so it will connect to server side

After connecting client with server side it will automatically starts camera and start streaming video.

For demo Video:

For source code checkout github link:

Thanks for reading this article!!!

Show some love on article by giving claps and comments!!!!!!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store