jheinly / sfm_duplicate_structure_correction

This is the code that corresponds to the paper: J. Heinly, E. Dunn, and J.M. Frahm, "Correcting for Duplicate Scene Structure in Sparse 3D Reconstruction", ECCV 2014.
26 stars 9 forks source link

Problem in running code #1

Open ChrisyehGone opened 8 years ago

ChrisyehGone commented 8 years ago

Hi, I met an mistake when running code in matlab. the problem is: Error using parallel_function (line 589)

To RESHAPE the number of elements must not change.

Error stack: compute_image_segmentations>(parfor body) at 47 Error in compute_image_segmentations (line 15) parfor cam_idx = 1:camera_data.num_cameras Error in main (line 40) compute_image_segmentations(camera_data, image_folder,... could you please help to find out what's going on?

jheinly commented 8 years ago

Do you have any other information about how the error occurred? For instance, looking at the code in compute_image_segmentations.m,

(line 33) imwrite(transformed_img, image_path); % This will write the image to disk. (line 35) system([segmentation_exe ' ' image_path ' ' num2str(num_superpixels)]); % This will read that image, compute the superpixel segmentation, and write an output file. (line 37 and 38) % Determine the width and height of the image that was written to disk. (line 42) segmentation = fread(file, trans_width * trans_height, 'int'); % This will read in the output file, and should have successfully read (trans_width * trans_height) elements. (line 47) segmentation = reshape(segmentation, trans_width, trans_height)'; % This reshapes the data that was just read in.

So, it's not clear to me why this would fail, but you could check for the existence of the transformed jpg image on disk (from line 32). Then, make sure that its dimensions match what you would expect them to be. Based on these dimensions, the size of the output data file should be equal to (trans_width * trans_height) 32-bit ints. Finally, you could make sure that line 42 actually read in (trans_width * trans_height) elements from the file.

ChrisyehGone commented 8 years ago

ok, i will try that again and catch more infomation for you. thx for your reply ~!

ChrisyehGone commented 8 years ago

I found that in the following codes(starts from line 40 in function 'compute_image_segmentations'):


dat_path = [segmentation_folder '/' camera_data.names{cam_idx} '_trans.dat'];
file = fopen(dat_path, 'r');
segmentation = fread(file, trans_width * trans_height, 'int');
fclose(file);
delete(dat_path);
delete(image_path);
segmentation = reshape(segmentation, trans_width, trans_height)';
  1. The value of _datpath is : C:\Users\Chrisyeh\Desktop\sfm_duplicate_structure_correction-master\datasets/street/segmentations/a007_trans.dat(after system() the size of _a007trans.dat is zero)
  2. Then the value of file is a double value: 3
  3. Next I got the value of segmentation which is empty 0x0 double

I thought it would be the reason why it failed

or the segmentation_exe(SLICO.EXE) couldnt work?

Finally, I figured it out~! The reason is that I use the wrong version of SLICO.EXE The SLICO.EXE I used is a debug version, but I use release lib (opencv_core2411.dll、opencv_highgui2411.dll ), so SLICO.EXE can not work. Then I rebuilded it under release version and it worked~! Thx all the same. By the way, how long does it take while computing camera spanning tree...?