MotionDetection icon indicating copy to clipboard operation
MotionDetection copied to clipboard

cannot run the code

Open yahiafarghaly opened this issue 8 years ago • 9 comments

Hi, thank you for amazing work of what you did in this area of computer vision. it seems an impressive result. currently i am still reading your paper and i was trying to test the code but i faced a problem of running it. you didn't commit a test folder which contain some images to test the code. but i tried to make my own as you said in the paper it should be 320240 . what i was able to get is 320180 like these( https://goo.gl/K7UL8p ). Also i modified the PATH variable to point to the new location. when i run it it gets me the error of

OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /home/yahia/Desktop/opencv2.4/opencv-2.4.13/modules/highgui/src/window.cpp

which mean that imshow cannot display the result. so my following questions

  • Have it must image size to be 320*240 ?
  • is any other modification in the test code should i do according to my picture set ?
  • can you commit your test pictures ?

yahiafarghaly avatar Feb 04 '17 09:02 yahiafarghaly

The test images we used are the CDNet dataset:

http://www.cv-foundation.org/openaccess/content_cvpr_workshops_2014/W12/papers/Wang_CDnet_2014_An_2014_CVPR_paper.pdf

Breakend avatar Feb 17 '17 21:02 Breakend

I'm assuming you're using the TBB implementation?

Breakend avatar Feb 17 '17 22:02 Breakend

A writeup for our implementation can be found here: https://arxiv.org/abs/1702.05156

Breakend avatar Feb 23 '17 21:02 Breakend

Hello. I got the same problem about the imshow in DualSGM.cpp. In the run_test function in the main.cpp file, I plot the size of the new frame and sometimes the new frame size is 0x0. I don't understand why because the path to the frame is correct (it works for the 3 or 4 first frames). (I use the TBB implementation.)

mnchapel avatar May 03 '17 09:05 mnchapel

It seems that the function nextImagePathForIndex is the problem. I changed the function by:

std::string nextImagePathForIndex(int i)
{
  char buff[100];
  sprintf(buff, "%sin%06d.jpg", PATH, i);
  std::string buffAsStdStr = buff;
  return buffAsStdStr;
} 

and the run_test function:

void run_test(int num_threads, int use_opencv_blur, int do_motion_comp, DualSGM::Timing *run_times)
{
  double t_exec_start = timer();
  Mat frame = imread(nextImagePathForIndex(1),  CV_LOAD_IMAGE_GRAYSCALE);
  DualSGM dsgm(&frame, 10);
  for (int i = start + 1; i < end_bis; i++) {
    std::string frame_path = nextImagePathForIndex(i);
    frame = imread(frame_path.c_str(), CV_LOAD_IMAGE_GRAYSCALE);
    nextImagePathForIndex(i);
    dsgm.updateModel(&frame, num_threads, use_opencv_blur, do_motion_comp, run_times);
  }
  run_times->t_exec = timer() - t_exec_start;
}

and now it works for me.

mnchapel avatar May 03 '17 11:05 mnchapel

Ah, ok thanks. It may be that the dataset changed format? if you'd like to submit a pull request i can take a look at integrating it.

Breakend avatar Jun 04 '17 20:06 Breakend

Hi Guys..

Please can someone help me out here... I have been trying the TBB implementation for a while now and im facing the same error mentioned above. tried to follow what @mnchapel did and still facing the same problem.

Im using the dataset from CDNet as used it the original work. im not sure If my opencv is th eproblem or the path to the images is the problem. Below is the error as well as the my PATH....Any idea will be appreciated.

PATH: "/home/vip/Videos/sofa/input/

OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /home/vip/Documents/zSetup_vip_computer/OpenCV/modules/highgui/src/window.cpp, line 269

Gasethata avatar Dec 15 '17 08:12 Gasethata

hi, maybe try adding a print statement right before the assertion to see if you're getting the same problem that @mnchapel got where the frames are zero? Also, which version of opencv and C++ are you using?

Breakend avatar Dec 22 '17 18:12 Breakend

Hi @Breakend I'm using the opencv 2.4.6 and C++ 11 is these the right versions?

Gasethata avatar Jan 10 '18 09:01 Gasethata