Permalink
Browse files

g++ support

  • Loading branch information...
Pashkoff Pashkoff
Pashkoff authored and Pashkoff committed Dec 9, 2011
1 parent 04ba744 commit 83833bc98f064a273f45a03a52786ef00177c5e0
View
@@ -1,4 +1,6 @@
+#include <cmath>
#include <exception>
+#include <stdexcept>
#include <fstream>
#include "HIKMTree.hpp"
@@ -35,7 +37,7 @@ void HIKMTree::Init(int dims, int clusters, VlIKMAlgorithms method)
{
mTree = vl_hikm_new(method);
if (!mTree)
- throw std::bad_alloc("vl_hikm_new returned nullptr");
+ throw std::bad_alloc();
int depth = VL_MAX(1, ceil (log ((double)mLeaves * 1.0) / log((double)clusters)));
@@ -128,63 +130,63 @@ void HIKMTree::load(std::istream& is)
//////////////////////////////////////////////////////////////////////////
-
-std::ostream& operator<<(std::ostream& os, HIKMTree const & tree)
-{
- WRITE(tree.mLeaves);
- if (!tree.mTree)
- throw std::runtime_error("mTree in HIKMTree is nullptr. Cannot save it");
- os << *tree.mTree;
- return os;
-}
-
-std::istream& operator>>(std::istream& is, HIKMTree & tree)
+std::ostream& operator<<(std::ostream& os, VlIKMFilt const& filt)
{
- READ(tree.mLeaves);
+ WRITE(filt.M);
+ WRITE(filt.K);
+ WRITE(filt.method);
+ WRITE(filt.max_niters);
+ WRITE(filt.verb);
+ if (!filt.centers)
+ throw std::runtime_error("centers in VlIKMFilt is nullptr. Cannot save it");
- vl_hikm_delete(tree.mTree);
- tree.mTree = vl_hikm_new(0);
+ os.write(reinterpret_cast<char const *>(filt.centers),
+ sizeof(filt.centers[0]) * filt.M * filt.K);
- is >> *tree.mTree;
- return is;
-}
+ if (filt.method == VL_IKM_ELKAN)
+ {
+ if (!filt.inter_dist)
+ throw std::runtime_error("inter_dist in VlIKMFilt is nullptr. Cannot save it");
+ os.write(reinterpret_cast<char const *>(filt.inter_dist),
+ sizeof(filt.inter_dist[0]) * filt.K * filt.K);
+ }
-std::ostream& operator<<(std::ostream& os, VlHIKMTree const& tree)
-{
- WRITE(tree.M);
- WRITE(tree.K);
- WRITE(tree.max_niters);
- WRITE(tree.method);
- WRITE(tree.verb);
- WRITE(tree.depth);
- if (!tree.root)
- throw std::runtime_error("root in VlHIKMTree is nullptr. Cannot save it");
- os << *tree.root;
return os;
}
-std::istream& operator>>(std::istream& is, VlHIKMTree & tree)
+std::istream& operator>>(std::istream& is, VlIKMFilt & filt)
{
- READ(tree.M);
- READ(tree.K);
- READ(tree.max_niters);
- READ(tree.method);
- READ(tree.verb);
- READ(tree.depth);
+ READ(filt.M);
+ READ(filt.K);
+ READ(filt.method);
+ READ(filt.max_niters);
+ READ(filt.verb);
+
+ size_t sctr = sizeof(filt.centers[0]) * filt.M * filt.K;
+ filt.centers = static_cast<vl_ikm_acc*>(vl_malloc(sctr));
+ is.read(reinterpret_cast<char*>(filt.centers), sctr);
+
+ if (filt.method == VL_IKM_ELKAN)
+ {
+ size_t sidst = sizeof(filt.inter_dist[0]) * filt.K * filt.K;
+ filt.inter_dist = static_cast<vl_ikm_acc*>(vl_malloc(sidst));
+ is.read(reinterpret_cast<char*>(filt.inter_dist), sidst);
+ }
+ else
+ {
+ filt.inter_dist = nullptr;
+ }
- tree.root = static_cast<VlHIKMNode*>(vl_malloc(sizeof(*tree.root)));
- is >> *tree.root;
return is;
}
-
std::ostream& operator<<(std::ostream& os, VlHIKMNode const& node)
{
if (!node.filter)
throw std::runtime_error("filter in VlHIKMNode is nullptr. Cannot save it");
os << *node.filter;
- bool chld = (node.children != nullptr);
+ bool chld = (nullptr != node.children);
WRITE(chld);
if (chld)
{
@@ -222,53 +224,54 @@ std::istream& operator>>(std::istream& is, VlHIKMNode & node)
return is;
}
-std::ostream& operator<<(std::ostream& os, VlIKMFilt const& filt)
+std::ostream& operator<<(std::ostream& os, VlHIKMTree const& tree)
{
- WRITE(filt.M);
- WRITE(filt.K);
- WRITE(filt.method);
- WRITE(filt.max_niters);
- WRITE(filt.verb);
- if (!filt.centers)
- throw std::runtime_error("centers in VlIKMFilt is nullptr. Cannot save it");
-
- os.write(reinterpret_cast<char const *>(filt.centers),
- sizeof(filt.centers[0]) * filt.M * filt.K);
+ WRITE(tree.M);
+ WRITE(tree.K);
+ WRITE(tree.max_niters);
+ WRITE(tree.method);
+ WRITE(tree.verb);
+ WRITE(tree.depth);
+ if (!tree.root)
+ throw std::runtime_error("root in VlHIKMTree is nullptr. Cannot save it");
+ os << *tree.root;
+ return os;
+}
- if (filt.method == VL_IKM_ELKAN)
- {
- if (!filt.inter_dist)
- throw std::runtime_error("inter_dist in VlIKMFilt is nullptr. Cannot save it");
+std::istream& operator>>(std::istream& is, VlHIKMTree & tree)
+{
+ READ(tree.M);
+ READ(tree.K);
+ READ(tree.max_niters);
+ READ(tree.method);
+ READ(tree.verb);
+ READ(tree.depth);
- os.write(reinterpret_cast<char const *>(filt.inter_dist),
- sizeof(filt.inter_dist[0]) * filt.K * filt.K);
- }
+ tree.root = static_cast<VlHIKMNode*>(vl_malloc(sizeof(*tree.root)));
+ is >> *tree.root;
+ return is;
+}
+std::ostream& operator<<(std::ostream& os, HIKMTree const & tree)
+{
+ WRITE(tree.mLeaves);
+ if (!tree.mTree)
+ throw std::runtime_error("mTree in HIKMTree is nullptr. Cannot save it");
+ os << *tree.mTree;
return os;
}
-std::istream& operator>>(std::istream& is, VlIKMFilt & filt)
+std::istream& operator>>(std::istream& is, HIKMTree & tree)
{
- READ(filt.M);
- READ(filt.K);
- READ(filt.method);
- READ(filt.max_niters);
- READ(filt.verb);
-
- size_t sctr = sizeof(filt.centers[0]) * filt.M * filt.K;
- filt.centers = static_cast<vl_ikm_acc*>(vl_malloc(sctr));
- is.read(reinterpret_cast<char*>(filt.centers), sctr);
+ READ(tree.mLeaves);
- if (filt.method == VL_IKM_ELKAN)
- {
- size_t sidst = sizeof(filt.inter_dist[0]) * filt.K * filt.K;
- filt.inter_dist = static_cast<vl_ikm_acc*>(vl_malloc(sidst));
- is.read(reinterpret_cast<char*>(filt.inter_dist), sidst);
- }
- else
- {
- filt.inter_dist = nullptr;
- }
+ vl_hikm_delete(tree.mTree);
+ tree.mTree = vl_hikm_new(0);
+ is >> *tree.mTree;
return is;
-}
+}
+
+
+
+
View
@@ -0,0 +1,19 @@
+LOCAL_TOP := $(dir $(lastword $(MAKEFILE_LIST)))
+
+OUT_NAME := HIKMTree
+FNAME := lib$(OUT_NAME).a
+
+SRC_DIR := $(LOCAL_TOP)
+SRC := HIKMTree.cpp
+
+
+LIBS :=
+STD_LIBS :=
+
+LOCAL_LDFLAGS :=
+LOCAL_CXXFLAGS := -I$(LOCAL_TOP)include
+
+include build-static.mk
+
+ALL += $(OUT_NAME)
+.PHONY: $(OUT_NAME)
View
@@ -1,4 +1,5 @@
#include <exception>
+#include <stdexcept>
#include <fstream>
#include "Image.hpp"
@@ -14,5 +14,6 @@ Image_pimpl::~Image_pimpl(void)
void Image_pimpl::open( std::string const & fname )
{
- mImage = toGrayscale(CIMG(fname.c_str()));
-}
+ CIMG tmp(fname.c_str());
+ mImage = toGrayscale(tmp);
+}
@@ -11,14 +11,14 @@ class Image_pimpl
~Image_pimpl(void);
void open(std::string const & fname);
+ typedef cimg_library::CImg<float> CIMG;
- template<typename T>
- T toGrayscale(T& img)
+ CIMG toGrayscale(CIMG& img)
{
return (img.get_channel(0) + img.get_channel(1) + img.get_channel(2))/3;
}
- typedef cimg_library::CImg<float> CIMG;
+
CIMG mImage;
};
View
@@ -0,0 +1,19 @@
+LOCAL_TOP := $(dir $(lastword $(MAKEFILE_LIST)))
+
+OUT_NAME := Image
+FNAME := lib$(OUT_NAME).a
+
+SRC_DIR := $(LOCAL_TOP)
+SRC := Image.cpp Image_pimpl.cpp
+
+
+LIBS :=
+STD_LIBS :=
+
+LOCAL_LDFLAGS :=
+LOCAL_CXXFLAGS := -I$(LOCAL_TOP)include
+
+include build-static.mk
+
+ALL += $(OUT_NAME)
+.PHONY: $(OUT_NAME)
View
@@ -1,3 +1,3 @@
#define XMD_H
#define cimg_use_jpeg
-#include <Cimg.h>
+#include <CImg.h>
View
@@ -0,0 +1,85 @@
+TOP := $(dir $(lastword $(MAKEFILE_LIST)))
+
+CLEAN_FILES :=
+
+# First rule
+ALL :=
+all:
+
+# copy command
+# CP := ln -s -f
+CP := cp
+
+
+VL_PATH :=/home/pashkoff/vlfeat-0.9.13/
+VL_BIN :=$(VL_PATH)bin/glnxa64/
+CIMG_PATH :=/home/pashkoff/d/code/CImg-1.4.9/
+
+
+ARCH := linux
+
+CONF := debug
+#CONF := release
+
+TARGET := $(ARCH)-$(CONF)
+OBJDIR := obj/$(TARGET)
+BINDIR := bin
+
+CFLAGS := -I$(TOP) -Wall -I$(VL_PATH) -I$(CIMG_PATH)
+CXXFLAGS := $(CFLAGS) -std=c++0x
+LDFLAGS := -L$(BINDIR) -L$(VL_BIN) -lvl -lX11 -ljpeg -lboost_system -lboost_filesystem -lboost_program_options
+
+ARCH_linux_CFLAGS := -pthread
+ARCH_linux_LDFLAGS := -lrt -lpthread
+
+
+TARGET_linux-debug_CFLAGS := -ggdb -DDEBUG -O0
+
+TARGET_linux-release_CFLAGS := -ggdb -DNDEBUG -O2
+
+
+CFLAGS += $(ARCH_$(ARCH)_CFLAGS) $(TARGET_$(TARGET)_CFLAGS)
+CXXFLAGS += $(ARCH_$(ARCH)_CFLAGS) $(TARGET_$(TARGET)_CFLAGS)
+LDFLAGS += $(ARCH_$(ARCH)_LDFLAGS)
+
+ARCH_linux_CC = $(CC)
+ARCH_linux_CXX = $(CXX)
+
+CC := $(ARCH_$(ARCH)_CC)
+CXX := $(ARCH_$(ARCH)_CXX)
+
+export LD_RUN_PATH=.:$(VL_BIN)
+
+VL_SO :=$(BINDIR)/libvl.so
+
+### List of included makefiles
+include HIKMTree/Makefile
+include Image/Makefile
+include isifter/Makefile
+include ivf_creator/Makefile
+include ivfile/Makefile
+include iwords/Makefile
+include query_maker/Makefile
+include Sift/Makefile
+include tree_creator/Makefile
+include Util/Makefile
+
+
+$(VL_SO): $(VL_BIN)libvl.so
+ $(CP) $^ $@
+
+$(BINDIR):
+ mkdir -p $@
+
+$(OBJDIR):
+ mkdir -p $@
+
+clean:
+ -$(RM) -r $(OBJDIR)
+ # -$(RM) -r $(BINDIR)
+ -$(RM) $(CLEAN_FILES)
+
+all: $(ALL)
+ @echo $(ALL)
+
+.PHONY: all clean
View
@@ -0,0 +1,19 @@
+LOCAL_TOP := $(dir $(lastword $(MAKEFILE_LIST)))
+
+OUT_NAME := Sift
+FNAME := lib$(OUT_NAME).a
+
+SRC_DIR := $(LOCAL_TOP)
+SRC := Sift.cpp
+
+
+LIBS :=
+STD_LIBS :=
+
+LOCAL_LDFLAGS :=
+LOCAL_CXXFLAGS := -I$(LOCAL_TOP)include
+
+include build-static.mk
+
+ALL += $(OUT_NAME)
+.PHONY: $(OUT_NAME)
Oops, something went wrong.

0 comments on commit 83833bc

Please sign in to comment.