Ask Your Question
0

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

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

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

Comments

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

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

1 answer

Sort by ยป oldest newest most voted
2

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

Tetragramm gravatar image

Ah, berak? https://docs.opencv.org/3.3.0/df/d23/classcv_1_1cuda_1_1BackgroundSubtractorMOG2.html

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

Comments

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 -0600 )edit
1

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 -0600 )edit

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

NoobProgrammer gravatar imageNoobProgrammer ( 2017-10-14 13:32:22 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 198 times

Last updated: Oct 14 '17