Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in SAD_blockmatching #6

Open
nmajid2 opened this issue Dec 24, 2020 · 4 comments
Open

Error in SAD_blockmatching #6

nmajid2 opened this issue Dec 24, 2020 · 4 comments

Comments

@nmajid2
Copy link

nmajid2 commented Dec 24, 2020

Hello, I've just tried the code and it works with no error based on the default settings.
However, when I changed the code in Edgeflow_prepare_data.m and replace the 'forward_camera' with 'downward_camera' and got the following error:

Index exceeds the number of array elements (128).

Error in SAD_blockmatching (line 35)
        SAD_temp(r+D+1)=sum(abs(hist_previous(x-W+pixel_shift:x+W+pixel_shift)-hist_current(x+r-W:x+r+W)));

Error in edge_flow_v2 (line 50)
[displacement.x, match_error.x,
fit_quality.x]=SAD_blockmatching(window,max_search_distance,edge_histogram(1).x,
edge_histogram(frame_previous_number.x+1).x,derot.x,1);

Error in calcEdgeFlow (line 33)
    edge_flow_v2(Fx_hist_left,Fy_hist_left,edge_histogram,previous_parameters,...

Error in calculate_OF_on_images (line 72)
        calcEdgeFlow

Error in Edgeflow_generate_results (line 61)
        calculate_OF_on_images

I try to fix the issue, but in case you have the solution in mind I appreciate your help. Thank you very much.

@knmcguire
Copy link
Owner

Hi!

It will be difficult for me to test this out for you since I no longer have access to matlab. Probably I should also upload some python version of this if I will find time, since it is difficult to debug this without the proper tools...

Have you checked the size of the downward camera's images? maybe they are not 128 px long?

@nmajid2
Copy link
Author

nmajid2 commented Dec 28, 2020

Hi,

I realized the error also happens for forward_camera. The way to reproduce the error is to change chosen_tracks(2).track = [2] to chosen_tracks(2).track = [7] in the edgeflow_generate_results.m.

After debugging more of the code, it sounds that the problem is here:

SAD_temp(r+D+1)=sum(abs(hist_previous(x-W+pixel_shift:x+W+pixel_shift)-hist_current(x+r-W:x+r+W)));

Sometimes the value of x+W+pixel_shift goes above 131, some other times the values of x-W+pixel_shift become -12 and maybe less. So the root of the issue might be the calculation of pixel_shift, because its values based on my observation become a negative number like -28. The boundaries for hist_previous and hist_current are [1,128].

I checked the size of the images, they all have the same size, 256 X 96 pixels.

@knmcguire
Copy link
Owner

hmmm that could be but I haven't see this happen before, and it should be limiters in the code to handle this.

I will try to get my hands on a PC with matlab again but this will take some time. In the mean time you can double check those limits that are on there and maybe arrange something for that. However considering my inability to help out I might consider to rewrite everything in python instead in the future.

@nmajid2
Copy link
Author

nmajid2 commented Dec 29, 2020

Thanks a lot, having the code in python would be very helpful.
I can also check later to see whether I can use the Matlab Coder to convert the code into c/c++. And then python binding technologies can be used to access the library from python.
For now, as you suggested, I keep debugging the Matlab code, since fixing the error in Matlab is easier than in c/c++.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants