Hi everyone,
I'm trying to write a cpp code to perform inference with DetectNet. Up to this point I've been using python for this (by modifying example.py from
Classification Example and it worked fine. Now for some reasons I have decided to move to cpp. I have built nv-caffe from source (the version is 0.15.13) and for compiling the code I'm using a makefile like this:
CXX=g++
CFLAGS = -c -Wall -std=c++0x -g3 -Ofast -msse2
#include directories
INCLUDE = -I. -I/usr/local/cuda/include -I/path/to/nv-caffe/include/ -I/path/to/nv-caffe/src/
#library paths in addition to /usr/lib
LDFLAGS = -L/usr/local/lib -L/usr/local/cuda/lib64 -L/usr/local/cuda/lib -lcudart -lcublas -lcurand -lglog -lgflags -lprotobuf -lleveldb -lsnappy -llmdb -lboost_system -lhdf5_hl -lhdf5 -lm -lopencv_core -lopencv_highgui -lopencv_imgproc -lboost_thread -lstdc++ -lcblas -latlas -L/path/to/nv-caffe/build/lib/ -lcaffe-nv -lproto
#cpp source file
SRC = Detection_v1.2.cpp
OBJS = $(SRC:.c=.o)
EXE = Detection
all: $(SRC) $(EXE)
clean:
rm -f *.o
rm -f $(EXE)
find ./ -name \*.o -delete
$(EXE): $(OBJS)
$(CXX) $(OBJS) $(INCLUDE) $(LDFLAGS) -o $@
.cpp.o:
$(CXX) $(CFLAGS) $< -o $@
Now when I compile a very simple code like this one bellow, I get a segmentation file when running it
#include <caffe/caffe.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <algorithm>
#include <iosfwd>
#include <memory>
#include <string>
#include <utility>
#include <vector>
using namespace caffe;
using std::string;
int main(int argc, char** argv) {
::google::InitGoogleLogging(argv[0]);
string model_file = argv[1];
string trained_file = argv[2];
string mean_file = argv[3];
//string label_file = argv[4];
//shared_ptr<Net<float> > net_;
// Set Caffe mode
#ifdef CPU_ONLY
Caffe::set_mode(Caffe::CPU);
#else
Caffe::set_mode(Caffe::GPU);
#endif
}
what do you think could be the problem? I have used a similar makefile to compile a classification example and it works just fine (there I use the standard caffe instead of nv-caffe and everything else is the same) I can't use detectnet with standard caffe because it doesn't recognize it's python layers. I appreciate any help. thanks in advance!