Help with Sift Flow Algorithm - debugging the demo

Hello I'm trying to run the demo for this SIFT Flow code you can find here:
It takes two similar images, finds their similarities, and combines them into one essentially...
I'm getting this error when running demo.m:
Here's the full demo.m code:
im1=imread('Mars-1.jpg');
im2=imread('Mars-2.jpg');
im1=imresize(imfilter(im1,fspecial('gaussian',7,1.),'same','replicate'),0.5,'bicubic');
im2=imresize(imfilter(im2,fspecial('gaussian',7,1.),'same','replicate'),0.5,'bicubic');
im1=im2double(im1);
im2=im2double(im2);
%figure;imshow(im1);figure;imshow(im2);
cellsize=3;
gridspacing=1;
addpath(fullfile(pwd,'mexDenseSIFT'));
addpath(fullfile(pwd,'mexDiscreteFlow'));
sift1 = mexDenseSIFT(im1,cellsize,gridspacing);
sift2 = mexDenseSIFT(im2,cellsize,gridspacing);
SIFTflowpara.alpha=2*255;
SIFTflowpara.d=40*255;
SIFTflowpara.gamma=0.005*255;
SIFTflowpara.nlevels=4;
SIFTflowpara.wsize=2;
SIFTflowpara.topwsize=10;
SIFTflowpara.nTopIterations = 60;
SIFTflowpara.nIterations= 30;
tic;[vx,vy,energylist]=SIFTflowc2f(sift1,sift2,SIFTflowpara);toc
warpI2=warpImage(im2,vx,vy);
figure;imshow(im1);figure;imshow(warpI2);
% display flow
clear flow;
flow(:,:,1)=vx;
flow(:,:,2)=vy;
figure;imshow(flowToColor(flow));
return;
% this is the code doing the brute force matching
tic;[flow2,energylist2]=mexDiscreteFlow(Sift1,Sift2,[alpha,alpha*20,60,30]);toc
figure;imshow(flowToColor(flow2));
Anyway I'm assuming this is probably an easy fix, I just don't generally use MATLAB, any help or guidance much appreciated...

5 comentarios

"Please run demo.h first. If error appears, please go to "mexDenseSIFT" and "mexDiscreteFlow" subfolders and follow the instructions in readme.txt (yes, there is readme.txt in each folder) to compile the cpp files. "
Did you follow the instructions in the readme.txt files to compile the cpp files?
Steven Rudolph
Steven Rudolph el 15 de En. de 2022
Editada: Steven Rudolph el 16 de En. de 2022
Hello thanks for your response!
I did try this already and got an unspeakable amount of errors, and I was under the assumption it came precompiled already...
this is what the readme.txt says:
"The *.cpp and *.h files in this folder are used to mex a matlab dll file for computing dense SIFT features. Use the following command to compile in Matlab (tested on version 7.6 or later)
mex mexDenseSIFT.cpp Matrix.cpp Vector.cpp
It has been tested in Windows 7 x64, Linux x64 and Mac OS 10.6. Precompiled versions of Windows 7 x64 and Mac OS 10.6 are included in the folder.
------------------------- Important -------------------------
You must change one line in order to compile correctly. On line 5 of project.h, you should comment this line if you are compiling using visual studio in windows, or uncomment if you are in linux or mac os."
I am on Mac OS Catalina 10.15 so I'm assuming these precompiled versions could be out of date?
Starting from scratch again I noticed a library hasn't loaded from mexDenseSIFT.mexmaci64
How do I fix this?
& from otool I see this inside mexDenseSIFT.meximaci64
The code needs to be recompiled.
Unfortunately there are a lot of problems with the code. It was designed in the time when MATLAB arrays could not exceed 2 gigabytes. Plus it had other random bugs.
I have gotten a clean compile for one of the two libraries (but not tested yet). The work is pretty tedious, so I have not gotten very far on the other library yet.
Thanks Walter as always for even trying to debug the issue.... I definitely understand how tedious it could be... I do understand the original code itself is over 10 years old so I know there could a lot of bugs there... Would be interested to know more about any modifications you made to fix this, and thanks again!
I got a clean compile for both sides, except:
  • one of the two has no mexFunction() routine and so cannot be called from MATLAB, which is a problem
  • there are functions to save and load binary images that are coded in terms of using int to hold sizes, which is not compatible with MATLAB (only supports 31 bits, whereas MATLAB supports 48 bits). I changed everything else to be compatible with MATLAB sizes, but not those routines yet, as I do not know whether compatibility with external formats is needed.

Iniciar sesión para comentar.

Respuestas (2)

Steven Rudolph
Steven Rudolph el 16 de En. de 2022

0 votos

Just to update:
I was able to run the code in an older 2016 version of MATLAB without issue compiling the mex file... for some reason my 2021 MATLAB version wouldn't allow me to compile the C++ code leading to an error...
I suspect that my Xcode compiler isn't up to date which is causing the error in the newer version... but I'm happy with using an older version of MATLAB to get this done for now.
yanqi liu
yanqi liu el 17 de En. de 2022

0 votos

yes,sir,may be use vlfeat toolbox,and vl_sift to get sift points and discripters

Categorías

Preguntada:

el 15 de En. de 2022

Comentada:

el 17 de En. de 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by