Ask Your Question

Yan Foto's profile - activity

2014-05-29 13:14:31 -0600 received badge  Critic (source)
2014-04-17 16:42:27 -0600 received badge  Student (source)
2014-04-17 15:17:21 -0600 received badge  Editor (source)
2014-04-17 15:10:48 -0600 asked a question Correct way to use accumulator (SOLVED)

I have been trying to create a foreground subtractor which accumulates a number of frames upon program starts and uses the generated image to detect foreground objects which may enter the view in a later time. However I am confused which image type I should use here in order to avoid "Assertion failed (func != 0) in accumulate" in one hand and end results with wrong colors on the other hand.

Code:

void Test::initBackgroundImage() {
    int totalCount = 3;
    int currentCount = 0;

    Mat camFrame;
    while(currentCount < totalCount) {
        cam >> camFrame;

        if(bgImg.empty()) {
            cam >> bgImg;
            bgImg.create(camFrame.size(), CV_32FC3);
        }

        accumulate(camFrame, bgImg);

        currentCount++;
    }
}

NOTE: Variables are all initialized in the constrcuctor.

Why does my code generate an image with wrong colors?

UPDATE:

I found out on this blog that adding the following line:

convertScaleAbs(bgImg, bgImg);

after the loop corrects the colors. Can someone please explain what exactly happens here?

UPDATE 2:

I just found out that the produced image has been correct. But since it was a 32 bit integer image, it was shown with different colors when calling imshow. See docs for more.

2014-04-17 14:57:38 -0600 received badge  Supporter (source)
2014-04-15 10:04:14 -0600 asked a question VIDIOC_STREAMON malfunctions after crash

If for any reason the my program crashes, I cannot run it again without getting the following error:

VIDIOC_STREAMON: Invalid argument

in an endless loop. I have tried to unload some kernel modules (such as ucvideo) and reloading them again but it didn't help. The only solution is to restart the whole system. This is however not feasible. I would appreciate any comments.

I use OpenCV 2.4.8 on Ubuntu 13.10.