Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CC = gcc
CC = g++
CFLAGS += -O3
BIN_DIR = ./bin
SRC_DIR = ./src
Expand All @@ -7,12 +7,12 @@ INC_DIR = ./include
LIB_DIR = ./lib
BIN = siftfeat match dspfeat match_num

all: $(BIN) libopensift.a docs
all: $(BIN) libopensift.so docs

docs:
doxygen Doxyfile

libopensift.a:
libopensift.so:
make -C $(SRC_DIR) $@

$(BIN):
Expand All @@ -29,4 +29,4 @@ distclean: clean
docsclean:
rm -rf $(DOC_DIR)/html/

.PHONY: docs clean docsclean libopensift.a
.PHONY: docs clean docsclean libopensift.so
6 changes: 3 additions & 3 deletions include/imgfeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef IMGFEATURES_H
#define IMGFEATURES_H

#include "cxcore.h"
#include <opencv2/core/core_c.h>

/** FEATURE_OXFD <BR> FEATURE_LOWE */
enum feature_type
Expand All @@ -28,8 +28,8 @@ enum feature_match_type


/* colors in which to display different feature types */
#define FEATURE_OXFD_COLOR CV_RGB(255,255,0)
#define FEATURE_LOWE_COLOR CV_RGB(255,0,255)
#define FEATURE_OXFD_COLOR {255,255,0}
#define FEATURE_LOWE_COLOR {255,0,255}

/** max feature descriptor length */
#define FEATURE_MAX_D 128
Expand Down
2 changes: 1 addition & 1 deletion include/kdtree.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#ifndef KDTREE_H
#define KDTREE_H

#include "cxcore.h"
#include <opencv2/core/core_c.h>


/********************************* Structures ********************************/
Expand Down
2 changes: 1 addition & 1 deletion include/sift.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef SIFT_H
#define SIFT_H

#include "cxcore.h"
#include <opencv2/core/core_c.h>

/******************************** Structures *********************************/

Expand Down
4 changes: 2 additions & 2 deletions include/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef UTILS_H
#define UTILS_H

#include "cxcore.h"
#include <opencv2/imgproc/imgproc_c.h>

#include <stdio.h>
#include <dirent.h>
Expand Down Expand Up @@ -156,7 +156,7 @@ extern char* prepend_path( const char* path, const char* file );

@return Returns the basename of \a pathname.
*/
extern char* basename( const char* pathname );
extern char* sift_basename( const char* pathname );


/**
Expand Down
2 changes: 1 addition & 1 deletion include/xform.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef XFORM_H
#define XFORM_H

#include <cxcore.h>
#include <opencv2/core/core_c.h>


/********************************** Structures *******************************/
Expand Down
31 changes: 15 additions & 16 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
CC = gcc
CFLAGS +=
CC = g++
CFLAGS += -fpermissive -Wno-deprecated-declarations -Wno-write-strings -fPIC
BIN_DIR = ../bin
INC_DIR = ../include
LIB_DIR = ../lib
INCL = -I$(INC_DIR) `pkg-config --cflags opencv gtk+-2.0`
LIBS = -L$(LIB_DIR) -lopensift -lm `pkg-config --libs opencv gtk+-2.0`
INCL = -I$(INC_DIR) `pkg-config --cflags opencv4 gtk+-2.0`
LIBS = -L$(LIB_DIR) -lm -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_core
OBJ = imgfeatures.o utils.o sift.o kdtree.o minpq.o xform.o
BIN = siftfeat match dspfeat match_num

all: $(BIN) libopensift.a
all: $(BIN) libopensift.so

libopensift.a: $(OBJ)
ar rc $(LIB_DIR)/$@ $(OBJ)
ranlib $(LIB_DIR)/$@
libopensift.so: $(OBJ)
g++ -shared $(CFLAGS) $(LDFLAGS) -o $(LIB_DIR)/$@ $^ $(LIBS)

siftfeat: libopensift.a siftfeat.c
$(CC) $(CFLAGS) $(INCL) siftfeat.c -o $(BIN_DIR)/$@ $(LIBS)
siftfeat: libopensift.so siftfeat.c
$(CC) $(CFLAGS) $(INCL) siftfeat.c -o $(BIN_DIR)/$@ -lopensift $(LIBS)

match: libopensift.a match.c
$(CC) $(CFLAGS) $(INCL) match.c -o $(BIN_DIR)/$@ $(LIBS)
match: libopensift.so match.c
$(CC) $(CFLAGS) $(INCL) match.c -o $(BIN_DIR)/$@ -lopensift $(LIBS)

match_num: libopensift.a match.c
$(CC) $(CFLAGS) $(INCL) match_num.c -o $(BIN_DIR)/$@ $(LIBS)
match_num: libopensift.so match.c
$(CC) $(CFLAGS) $(INCL) match_num.c -o $(BIN_DIR)/$@ -lopensift $(LIBS)

dspfeat: libopensift.a dspfeat.c
$(CC) $(CFLAGS) $(INCL) dspfeat.c -o $(BIN_DIR)/$@ $(LIBS)
dspfeat: libopensift.so dspfeat.c
$(CC) $(CFLAGS) $(INCL) dspfeat.c -o $(BIN_DIR)/$@ -lopensift $(LIBS)

imgfeatures.o: imgfeatures.c $(INC_DIR)/imgfeatures.h
$(CC) $(CFLAGS) $(INCL) -c imgfeatures.c -o $@
Expand Down
16 changes: 8 additions & 8 deletions src/dspfeat.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "imgfeatures.h"
#include "utils.h"

#include <cxcore.h>
#include <highgui.h>
#include <opencv2/highgui/highgui_c.h>
#include <opencv2/imgcodecs.hpp>

#include <unistd.h>

Expand All @@ -34,24 +34,24 @@ int feat_type = FEATURE_LOWE;

int main( int argc, char** argv )
{
IplImage* img;
IplImage img;
struct feature* feat;
char* name;
int n;

arg_parse( argc, argv );

img = cvLoadImage( img_file, 1 );
if( ! img )
img = cvIplImage(cv::imread( img_file, 1 ));
if( ! img.imageSize )
fatal_error( "unable to load image from %s", img_file );
n = import_features( feat_file, feat_type, &feat );
if( n == -1 )
fatal_error( "unable to import features from %s", feat_file );
name = feat_file;

draw_features( img, feat, n );
draw_features( &img, feat, n );
cvNamedWindow( name, 1 );
cvShowImage( name, img );
cvShowImage( name, &img );
cvWaitKey( 0 );
return 0;
}
Expand Down Expand Up @@ -85,7 +85,7 @@ static void usage( char* name )
*/
static void arg_parse( int argc, char** argv )
{
pname = basename( argv[0] );
pname = sift_basename( argv[0] );
int arg;
while( 1 )
{
Expand Down
8 changes: 4 additions & 4 deletions src/imgfeatures.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "utils.h"
#include "imgfeatures.h"

#include <cxcore.h>
#include <opencv2/imgproc.hpp>

static int import_oxfd_features( char*, struct feature** );
static int export_oxfd_features( char*, struct feature*, int );
Expand Down Expand Up @@ -336,7 +336,7 @@ static int export_oxfd_features( char* filename, struct feature* feat, int n )
*/
static void draw_oxfd_features( IplImage* img, struct feature* feat, int n )
{
CvScalar color = CV_RGB( 255, 255, 255 );
CvScalar color ({ 255, 255, 255 });
int i;

if( img-> nChannels > 1 )
Expand Down Expand Up @@ -374,7 +374,7 @@ static void draw_oxfd_feature( IplImage* img, struct feature* feat,
alpha *= 180 / M_PI;

cvEllipse( img, cvPoint( feat->x, feat->y ), cvSize( l2, l1 ), alpha,
0, 360, CV_RGB(0,0,0), 3, 8, 0 );
0, 360, {0,0,0}, 3, 8, 0 );
cvEllipse( img, cvPoint( feat->x, feat->y ), cvSize( l2, l1 ), alpha,
0, 360, color, 1, 8, 0 );
cvLine( img, cvPoint( feat->x+2, feat->y ), cvPoint( feat->x-2, feat->y ),
Expand Down Expand Up @@ -543,7 +543,7 @@ static int export_lowe_features( char* filename, struct feature* feat, int n )
*/
static void draw_lowe_features( IplImage* img, struct feature* feat, int n )
{
CvScalar color = CV_RGB( 255, 255, 255 );
CvScalar color ({ 255, 255, 255 });
int i;

if( img-> nChannels > 1 )
Expand Down
2 changes: 0 additions & 2 deletions src/kdtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#include "imgfeatures.h"
#include "utils.h"

#include <cxcore.h>

#include <stdio.h>

struct bbf_data
Expand Down
27 changes: 12 additions & 15 deletions src/match.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
#include "utils.h"
#include "xform.h"

#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include <opencv2/highgui/highgui_c.h>
#include <opencv2/imgcodecs.hpp>

#include <stdio.h>

Expand All @@ -28,7 +27,7 @@

int main( int argc, char** argv )
{
IplImage* img1, * img2, * stacked;
IplImage img1, img2, * stacked;
struct feature* feat1, * feat2, * feat;
struct feature** nbrs;
struct kd_node* kd_root;
Expand All @@ -39,18 +38,18 @@ int main( int argc, char** argv )
if( argc != 3 )
fatal_error( "usage: %s <img1> <img2>", argv[0] );

img1 = cvLoadImage( argv[1], 1 );
if( ! img1 )
img1 = cvIplImage(cv::imread( argv[1], 1 ));
if( ! img1.imageSize )
fatal_error( "unable to load image from %s", argv[1] );
img2 = cvLoadImage( argv[2], 1 );
if( ! img2 )
img2 = cvIplImage(cv::imread( argv[2], 1 ));
if( ! img2.imageSize )
fatal_error( "unable to load image from %s", argv[2] );
stacked = stack_imgs( img1, img2 );
stacked = stack_imgs( &img1, &img2 );

fprintf( stderr, "Finding features in %s...\n", argv[1] );
n1 = sift_features( img1, &feat1 );
n1 = sift_features( &img1, &feat1 );
fprintf( stderr, "Finding features in %s...\n", argv[2] );
n2 = sift_features( img2, &feat2 );
n2 = sift_features( &img2, &feat2 );
fprintf( stderr, "Building kd tree...\n" );
kd_root = kdtree_build( feat2, n2 );
for( i = 0; i < n1; i++ )
Expand All @@ -65,8 +64,8 @@ int main( int argc, char** argv )
{
pt1 = cvPoint( cvRound( feat->x ), cvRound( feat->y ) );
pt2 = cvPoint( cvRound( nbrs[0]->x ), cvRound( nbrs[0]->y ) );
pt2.y += img1->height;
cvLine( stacked, pt1, pt2, CV_RGB(255,0,255), 1, 8, 0 );
pt2.y += img1.height;
cvLine( stacked, pt1, pt2, {255,0,255}, 1, 8, 0 );
m++;
feat1[i].fwd_match = nbrs[0];
}
Expand Down Expand Up @@ -109,8 +108,6 @@ int main( int argc, char** argv )
*/

cvReleaseImage( &stacked );
cvReleaseImage( &img1 );
cvReleaseImage( &img2 );
kdtree_release( kd_root );
free( feat1 );
free( feat2 );
Expand Down
14 changes: 6 additions & 8 deletions src/match_num.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
#include "utils.h"
#include "xform.h"

#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include <opencv2/highgui/highgui_c.h>
#include <opencv2/imgcodecs.hpp>

#include <stdio.h>
#include <pthread.h>
Expand Down Expand Up @@ -43,15 +42,14 @@ struct thread_data {
void* process_image(void* arg) {
int n;
struct thread_data* ctx;
IplImage* img;
IplImage img;

ctx = (struct thread_data*)arg;
img = cvLoadImage(ctx->filename, 1);
if (!img) fatal_error("Unable to load image from %s", ctx->filename);
ctx->fdata.count = sift_features(img, &(ctx->fdata.features));
img = cvIplImage(cv::imread(ctx->filename, 1));
if (!img.imageSize) fatal_error("Unable to load image from %s", ctx->filename);
ctx->fdata.count = sift_features(&img, &(ctx->fdata.features));
if (DEBUG)
fprintf(stderr, "Found %d features in %s...\n", ctx->fdata.count, ctx->filename);
cvReleaseImage(&img);
pthread_exit(NULL);
}

Expand Down
3 changes: 0 additions & 3 deletions src/sift.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
#include "imgfeatures.h"
#include "utils.h"

#include <cxcore.h>
#include <cv.h>

/************************* Local Function Prototypes *************************/

static IplImage* create_init_img( IplImage*, int, double );
Expand Down
Loading