Ask Your Question

flakes's profile - activity

2019-01-13 20:46:31 -0500 received badge  Enthusiast
2019-01-06 15:16:43 -0500 commented answer cmake options for opencv, what happen if I uncheck

@blaisexen The Java and Python wrappers do not use opencv_worldXXX.dll directly; they require extra components. If you d

2019-01-06 15:15:31 -0500 commented answer cmake options for opencv, what happen if I uncheck

@blaisexen The Java and Python wrappers do not use opencv_worldXXX.dll directly; they require extra components. If you d

2019-01-06 14:05:50 -0500 answered a question cmake options for opencv, what happen if I uncheck

At its core, OpenCV is a C/C++ library where the main interface is written in C++, and C for older API's. All other imp

2019-01-05 14:23:40 -0500 edited question How to use G-API with GPU?

How to use G-API with GPU? I've been reading about using the Graph API, and the syntax seems very nice. There's a sectio

2019-01-05 14:21:33 -0500 edited question How to use G-API with GPU?

How to use G-API with GPU? I've been reading about using the Graph API, and the syntax seems very nice. There's a sectio

2019-01-05 14:21:28 -0500 edited question How to use G-API with GPU?

How to use G-API with GPU? I've been reading about using the Graph API, and the syntax seems very nice. There's a sectio

2019-01-03 12:54:52 -0500 commented answer How to use G-API with GPU?

I'm still not quite sure how I could apply this to basic operations like bitwise_x or copyTo. I'm imaginging its somehow

2019-01-02 15:24:11 -0500 received badge  Editor (source)
2019-01-02 15:24:11 -0500 edited question How to use G-API with GPU?

How to use G-API with GPU? I've been reading about using the Graph API, and the syntax seems very nice. There's a sectio

2019-01-02 15:23:22 -0500 asked a question How to use G-API with GPU?

How to use G-API with GPU? I've been reading about using the Graph API, and the syntax seems very nice. There's a sectio

2019-01-02 14:48:58 -0500 marked best answer Applying operations to video feed. Determining when to use CPU vs GPU

I'm working on an OpenCV project to monitor a video feed and also apply animations to this feed. In the following example operation I am resizing a video frame and applying an overlay to the resized frame. My process looks like the link of the image

Here is the implementation of the process (currently done in C# opencvsharp, however, I can shift to any language at this point):

private void updateFrame(Mat currentFrame, Mat background, Mat mask, Mat invertedMask)
{
    int w = 400, h = 224;

    using (var resizedFrame = new Mat(
        new OpenCvSharp.Size(currentFrame.Size().Width - w, currentFrame.Size().Height - h), 
        currentFrame.Type()))
    using (var resizedBorderFrame = new Mat(currentFrame.Size(), currentFrame.Type()))
    using (var maskedFrame = new Mat(currentFrame.Size(), currentFrame.Type()))
    using (var maskedBackground = new Mat(currentFrame.Size(), currentFrame.Type()))
    using (var output = new Mat(currentFrame.Size(), currentFrame.Type()))
    {
        Cv2.Resize(currentFrame, resizedFrame, resizedFrame.Size());
        Cv2.CopyMakeBorder(resizedFrame, resizedBorderFrame, h/4, h*3/4, w/2, w/2, BorderTypes.Constant, new Scalar(0));
        Cv2.BitwiseAnd(resizedBorderFrame, mask, maskedFrame);
        Cv2.BitwiseAnd(background, invertedMask, maskedBackground);
        Cv2.BitwiseOr(maskedBackground, maskedFrame, output);
        pictureBox.Image = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(output);
    }
}

This process (along with a few other operations) is beginning to take longer than the framerate of the video, creating a noticeable lag. Currently the process is being performed using CPU based operations, however, I read that applying GPU operations could speed up the runtime a considerable amount. Further, I read that creating a custom kernel to combine operations (or creating the whole series as a compound-kernel operation) could speed this up even more (That said, certain operations might not be constrained by the CPU and adding a GPU operation would be overkill?).

If you were to evaluate this problem from the start, how would you go about determining which operations to put on CPU vs GPU vs custom kernel? What optimizations could I be making to speed up the application, or are there other processes I can employ to make this job easier?

2019-01-02 14:48:58 -0500 received badge  Scholar (source)
2019-01-02 14:48:43 -0500 commented answer Applying operations to video feed. Determining when to use CPU vs GPU

Great answer! I also got a lot of speed up from applying this trick and also about a 3x speedup by converting my code to

2019-01-02 10:50:54 -0500 received badge  Supporter (source)
2019-01-01 15:41:06 -0500 received badge  Student (source)
2019-01-01 14:18:58 -0500 commented question Applying operations to video feed. Determining when to use CPU vs GPU

@berak I'm not asking a question specific to this wrapper. The snippet was just to present the problem in code as well.

2018-12-31 09:15:47 -0500 asked a question Applying operations to video feed. Determining when to use CPU vs GPU

Applying operations to video feed. Determining when to use CPU vs GPU I'm working on an OpenCV project to monitor a vide