So, I want to write a program to make the processed output from OpenCV be seen as a WebCam. I want to use it to create effects for a program like Skype. I am stuck and Googling has led to no help. Please help me. Do I need to get a driver for this? What about storing as an AVI and streaming that AVI with some other application?
I want to write a program to mask my face so I don't need to worry about my privacy when Skype-ing with people I am tutoring and don't personally know!
By the way, I am kinda new with C++. However, that is the language I prefer. However, I understand Java and Python as well.
Would you suggest I try to get another library/collection of libraries, like OpenFrameworks?
I am programming OpenCV in C++. Here are all the available platforms for me: Ubuntu: OpenCV from apt-get, with pkg-config, QT Creator Ubuntu: OpenCV from apt-get, with pkg-config, and libfreenect, QT Creator Windows 7: OpenCV 2.4.8.0, latest binaries, x86, Visual Studio 2010 express Windows 7: OpenCV Not Installed Windows 8.1 Pro: OpenCV 2.4.8.0, latest binaries, x86, Visual Studio Express 2013 Express Desktop, Hyper-V, Same configuration as Windows 7:1
I noticed a bit of confusion. I am trying to use the processes output from open CV and send it to another program like Skype. Main intention is that I am going to teach elementary school kids programming and OpenCV. I'd like to directly stream the output so I don't have to share my desktop.
To quit, hit the key q "on" the video window(s) to stop the camera.
Closing video window using close "X" button in OpenCV, Python.
Capture Video from CameraOpenCV 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 VideoCapture object to capture a video. It accepts either the device index or the name of a video file.
I had the same problem: My grandmother hears poorly so I wanted to be able to add subtitles to my Skype video feed. I also wanted to add some effects for laughs. I could not get webcamoid working. Screen capture method (mentioned above) seemed too hacky, and I could not get Skype to detect ffmpegs dummy output camera (guvcview detects though). Then I ran across this:
https://github.com/jremmons/pyfakewebcam
It is not C++ but Python. Still, it is fast enough on my non-fancy laptop. It can create multiple dummy webcams (I only need two). It works with Python3 as well. The steps mentioned in readme were easy to reproduce on Ubuntu 18.04. Within 2-3 minutes, the example code was running. At the time of this writing, the given examples there do not use input from a real webcam. So I add my code, which processes the real webcam's input and outputs it to two dummy cameras:
import cv2 import time import pyfakewebcam import numpy as np IMG_W = 1280 IMG_H = 720 cam = cv2.VideoCapture(0) cam.set(cv2.CAP_PROP_FRAME_WIDTH, IMG_W) cam.set(cv2.CAP_PROP_FRAME_HEIGHT, IMG_H) fake1 = pyfakewebcam.FakeWebcam('/dev/video1', IMG_W, IMG_H) fake2 = pyfakewebcam.FakeWebcam('/dev/video2', IMG_W, IMG_H) while True: ret, frame = cam.read() flipped = cv2.flip(frame, 1) # Mirror effect frame[0 : IMG_H, IMG_W//2 : IMG_W] = flipped[0 : IMG_H, IMG_W//2 : IMG_W] fake1.schedule_frame(frame) fake2.schedule_frame(flipped) time.sleep(1/15.0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With