Ask Your Question
0

Use BackgroundSubtractorMOG2 in OpenCV 2.4.13 with Java

asked 2016-10-12 04:05:22 -0600

SniFFzoR gravatar image

Hi,

I have been running my openCV setup on windows until now, but now I need to change to Ubuntu. Because of this, I was unable to create a .jar file for openCV version 3.x so I ended up with version 2.4.13.

This means that some of the lines of code that I had (perfectly working in Windows with openCV 3.1) no longer work.

I had the following line:

BackgroundSubtractorMOG2 mog2 = Video.createBackgroundSubtractorMOG2();

Now, I am trying to change this to work with openCV version 2.4.13, but I'm simply not able to.

I have tried the following line

mog2 = org.opencv.video.BackgroundSubtractorMOG();

but this gives me the following: org.opencv.video cannot be resolved to a type.

What can I do to make this run on my current setup?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-10-12 04:25:43 -0600

berak gravatar image

try: mog = new org.opencv.video.BackgroundSubtractorMOG();

edit flag offensive delete link more

Comments

It worked. So all it needed was the "new" added before. Btw, it also seems to work with BackgroundSubtractorMOG2, not just the ordinary MOG.

SniFFzoR gravatar imageSniFFzoR ( 2016-10-12 04:31:40 -0600 )edit

you need a newin java for any object, that is not a simple number.

(opencv3 avoided that by having a "factory pattern" instead of a constructor)

berak gravatar imageberak ( 2016-10-12 04:34:02 -0600 )edit

Yeah, I know that. I simply overlooked the fact due to I looked to much on the old code. Anyway, thanks again.

SniFFzoR gravatar imageSniFFzoR ( 2016-10-12 06:46:28 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-10-12 04:05:22 -0600

Seen: 625 times

Last updated: Oct 12 '16