Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/Makefile b/Makefile
- index 63e15e6..3955f12 100644
- --- a/Makefile
- +++ b/Makefile
- @@ -1,14 +1,17 @@
- -GPU=0
- -CUDNN=0
- -OPENCV=0
- -OPENMP=0
- +GPU=1
- +CUDNN=1
- +OPENCV=1
- +OPENMP=1
- DEBUG=0
- -ARCH= -gencode arch=compute_30,code=sm_30 \
- - -gencode arch=compute_35,code=sm_35 \
- - -gencode arch=compute_50,code=[sm_50,compute_50] \
- - -gencode arch=compute_52,code=[sm_52,compute_52]
- -# -gencode arch=compute_20,code=[sm_20,sm_21] \ This one is deprecated?
- +ARCH= -gencode=arch=compute_60,code=sm_60 \
- + -gencode=arch=compute_61,code=sm_61 \
- + -gencode=arch=compute_70,code=sm_70 \
- + -gencode=arch=compute_75,code=sm_75 \
- + -gencode=arch=compute_80,code=sm_80 \
- + -gencode=arch=compute_86,code=sm_86 \
- + -gencode=arch=compute_89,code=sm_89 \
- + -gencode=arch=compute_89,code=compute_89
- # This is what I use, uncomment if you know your arch and want to specify
- # ARCH= -gencode arch=compute_52,code=compute_52
- @@ -42,8 +45,8 @@ CFLAGS+=$(OPTS)
- ifeq ($(OPENCV), 1)
- COMMON+= -DOPENCV
- CFLAGS+= -DOPENCV
- -LDFLAGS+= `pkg-config --libs opencv` -lstdc++
- -COMMON+= `pkg-config --cflags opencv`
- +LDFLAGS+= `pkg-config --libs opencv4` -lstdc++
- +COMMON+= `pkg-config --cflags opencv4`
- endif
- ifeq ($(GPU), 1)
- diff --git a/src/image_opencv.cpp b/src/image_opencv.cpp
- index 7511280..04103a8 100644
- --- a/src/image_opencv.cpp
- +++ b/src/image_opencv.cpp
- @@ -9,31 +9,35 @@ using namespace cv;
- extern "C" {
- -IplImage *image_to_ipl(image im)
- -{
- +Mat image_to_mat(image im)
- + {
- + assert(im.c == 3 || im.c == 1);
- int x,y,c;
- - IplImage *disp = cvCreateImage(cvSize(im.w,im.h), IPL_DEPTH_8U, im.c);
- - int step = disp->widthStep;
- - for(y = 0; y < im.h; ++y){
- - for(x = 0; x < im.w; ++x){
- - for(c= 0; c < im.c; ++c){
- - float val = im.data[c*im.h*im.w + y*im.w + x];
- - disp->imageData[y*step + x*im.c + c] = (unsigned char)(val*255);
- - }
- - }
- - }
- - return disp;
- -}
- + image copy = copy_image(im);
- + constrain_image(copy);
- + if(im.c == 3) rgbgr_image(copy);
- + Mat m(im.h, im.w, CV_MAKETYPE(CV_8U, im.c));
- + for(y = 0; y < im.h; ++y){
- + for(x = 0; x < im.w; ++x){
- + for(c= 0; c < im.c; ++c){
- + float val = copy.data[c*im.h*im.w + y*im.w + x];
- + m.data[y*im.w*im.c + x*im.c + c] = (unsigned char)(val*255);
- + }
- + }
- + }
- + free_image(copy);
- + return m;
- + }
- -image ipl_to_image(IplImage* src)
- -{
- - int h = src->height;
- - int w = src->width;
- - int c = src->nChannels;
- - image im = make_image(w, h, c);
- - unsigned char *data = (unsigned char *)src->imageData;
- - int step = src->widthStep;
- - int i, j, k;
- +image mat_to_image(Mat m)
- + {
- + int h = m.rows;
- + int w = m.cols;
- + int c = m.channels();
- + image im = make_image(w, h, c);
- + unsigned char *data = (unsigned char*)m.data;
- + int step = m.step;
- + int i, j, k;
- for(i = 0; i < h; ++i){
- for(k= 0; k < c; ++k){
- @@ -42,26 +46,7 @@ image ipl_to_image(IplImage* src)
- }
- }
- }
- - return im;
- -}
- -
- -Mat image_to_mat(image im)
- -{
- - image copy = copy_image(im);
- - constrain_image(copy);
- - if(im.c == 3) rgbgr_image(copy);
- - IplImage *ipl = image_to_ipl(copy);
- - Mat m = cvarrToMat(ipl, true);
- - cvReleaseImage(&ipl);
- - free_image(copy);
- - return m;
- -}
- -
- -image mat_to_image(Mat m)
- -{
- - IplImage ipl = m;
- - image im = ipl_to_image(&ipl);
- rgbgr_image(im);
- return im;
- }
- @@ -72,9 +57,9 @@ void *open_video_stream(const char *f, int c, int w, int h, int fps)
- if(f) cap = new VideoCapture(f);
- else cap = new VideoCapture(c);
- if(!cap->isOpened()) return 0;
- - if(w) cap->set(CV_CAP_PROP_FRAME_WIDTH, w);
- - if(h) cap->set(CV_CAP_PROP_FRAME_HEIGHT, w);
- - if(fps) cap->set(CV_CAP_PROP_FPS, w);
- + if(w) cap->set(CAP_PROP_FRAME_WIDTH, w);
- + if(h) cap->set(CAP_PROP_FRAME_HEIGHT, w);
- + if(fps) cap->set(CAP_PROP_FPS, w);
- return (void *) cap;
- }
- @@ -123,7 +108,7 @@ void make_window(char *name, int w, int h, int fullscreen)
- {
- namedWindow(name, WINDOW_NORMAL);
- if (fullscreen) {
- - setWindowProperty(name, CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN);
- + setWindowProperty(name, WND_PROP_FULLSCREEN, WINDOW_FULLSCREEN);
- } else {
- resizeWindow(name, w, h);
- if(strcmp(name, "Demo") == 0) moveWindow(name, 0, 0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement