Ask Your Question

Should the execution time change when I am running MOG2 extractor on image in GPU?

asked 2017-10-14 04:06:36 -0500

NoobProgrammer gravatar image

Image size is 640x480 and MOG2 is applied, it executes in 1ms. While if I take above image and copy it 4 times I will get execution time of 3.2ms(This execution time is only of GPU when I am applying the extractor not memory transfer). The time shouldn't jump from 1ms to 3.2ms in my opinion because it is parallel. My system has Cuda 8.0, OpenCV 3.3.0 and 850M Graphics Card.

edit retag flag offensive close merge delete


MOG2 has an opencl implementation, but there is no cuda one.

berak gravatar imageberak ( 2017-10-14 04:14:23 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2017-10-14 13:20:36 -0500

Tetragramm gravatar image

Ah, berak?

As to your question, it is important to know how the GPU works. The 640x480 image is 307200 pixels, which is far more than the number of cores on the GPU. In the ideal case, where each pixel is operated upon once, for example, adding one to every pixel. If you had a GPU with 640 cores, each core would operate on 480 pixels. If you resized the image to be 4 times larger (2x width 2x height), then each core would operate on 4x480 pixels, taking about 4x as long.

So, as you can see, MOG2, which is much more complicated than simple addition, will definitely take longer if you use larger images like you say.

edit flag offensive delete link more


Ah i see. So basically the only bottleneck is the GPU cores.... I get it. Thanks buddy. And also it will happen on different algorithms too right?

NoobProgrammer gravatar imageNoobProgrammer ( 2017-10-14 13:24:07 -0500 )edit

Yes. Now, for many algorithms, the GPU is faster than the CPU, so that's good.

Also, there are many things that can speed up or slow down a particular algorithm or function on a GPU. If you're interested, there are many books that can help you, such as THESE.

Tetragramm gravatar imageTetragramm ( 2017-10-14 13:31:02 -0500 )edit

Yeah I know more or less about them. Thanks again.

NoobProgrammer gravatar imageNoobProgrammer ( 2017-10-14 13:32:22 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-10-14 04:06:36 -0500

Seen: 88 times

Last updated: Oct 14 '17