Using OpenCV Output as a Webcam

So, I want to write a program so that the processed output from OpenCV is considered as a webcam. I want to use it to create effects for a program like Skype. I got stuck and googling didn't help. Please help me. Do I need to get a driver for this? How about saving as AVI and streaming 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 talking with the people I teach, and I personally don’t know!

By the way, I'm a little new to C ++. However, this is the language that I prefer. However, I also understand Java and Python.

Are you suggesting I try to get another library / library collection, like OpenFrameworks?

I am programming OpenCV in C ++. Here are all 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, recent 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 processes derived from an open CV and send them to another program such as Skype. The main intention is that I am going to teach elementary school programming and OpenCV. I would like to stream directly, so I don’t need to share my desktop.

+6
4

, ; , .

, SplitCam; - , IP- / .

, - OpenGV highgui, SplitCam, , Skype. , .!

+3

, Mat Mat, , OpenCV . - Mjpeg ibternet , OpenCV .

Socket

Mat.data , BGR BGR BGR.... , . (BGR BGR... array) , .

: -

Mat frame;
frame = (frame.reshape(0,1)); // to make it continuous

int  imgSize = frame.total()*frame.elemSize();

// Send data here
bytes = send(clientSock, frame.data, imgSize, 0))

: -

Mat  img = Mat::zeros( height,width, CV_8UC3);
   int  imgSize = img.total()*img.elemSize();
   uchar sockData[imgSize];

 //Receive data here

   for (int i = 0; i < imgSize; i += bytes) {
   if ((bytes = recv(connectSock, sockData +i, imgSize  - i, 0)) == -1) {
     quit("recv failed", 1);
    }
   }

 // Assign pixel value to img

 int ptr=0;
 for (int i = 0;  i < img.rows; i++) {
  for (int j = 0; j < img.cols; j++) {                                     
   img.at<cv::Vec3b>(i,j) = cv::Vec3b(sockData[ptr+ 0],sockData[ptr+1],sockData[ptr+2]);
   ptr=ptr+3;
   }
  }

Mjpeg Streamer

Mjpeg streamer software , - , OpenCV , -, OpenCV VideoCapture,

Cap.open("http://192.168.1.30:8080/?dummy=param.mjpg");
0

gstreamer. OpenCV VideoCapture gstreamer, - . Gstreamer , opencv , .

I have no experience marrying skype, but it seems to be possible. You just need to create the right conveyor , something like: gst-launch videotestsrc ! ffmpegcolorspace ! "video/x-raw-yuv,format=(fourcc)YUY2" ! v4l2sink device=/dev/video1 gst-launch videotestsrc ! ffmpegcolorspace ! "video/x-raw-yuv,format=(fourcc)YUY2" ! v4l2sink device=/dev/video1 gst-launch videotestsrc ! ffmpegcolorspace ! "video/x-raw-yuv,format=(fourcc)YUY2" ! v4l2sink device=/dev/video1.

0
source

Source: https://habr.com/ru/post/1524404/


All Articles