So to create a Video Chat app using OpenCV is very easy.
Here is the code for creating a normal Live video.
In the above code first, we have imported the cv2.
Then we have used cv2.VedioCapture(0) command to enable our camera.
Then we have used a while condition which will remain true until we press the enter button. Inside this loop we have used cap.read() function to start capturing the image from our camera and cv2.imshow() function to show the captured images. Next we have used waitKey which defines for how much time the image window will remain open and here we have put 1 which gives us a continuous shot of images and seems like a video.
So this was the code for the live video capturing.
Now for the video chat, we will be using ssh to run this code in the other locally connected os and from that os we will remotely run this code in this os.
So the main objective is to remotely run this code on each other devices. For this first we will create same python code file in both the os and then we will be running this file remotely on each others machine.
For running it on the other’s machine we will be using this command:
ssh -X <username>@<host> python3 <file_name>
In my case this was like:
So that’s all for creating a video chat app and here is the final result