Deep learning Library to work easily with opencv on window environment.

I was wrapping caffe library to use easy with opencv and window os environment(named MareDeepDLL).

MareDeepDll is referenced on

The dll is made on this environment
Window 10 64bit,
VS 2013 64bit
OpenCV 3.0 64bit
cuda 6.5 64bit
tbb 64bit
All dependency is as follows:

This code is example to use the dll
#include < iostream>  
#include < stdio.h>
#include < vector>
#include < time.h>

#include <  opencv2\opencv.hpp>    
#include <  opencv2\core.hpp>  
#include <  opencv2\highgui.hpp>   
#include <  opencv2\videoio.hpp>    
#include <  opencv2\imgproc.hpp>  

#include "DeepDll_B.h"

#ifdef _DEBUG            
#pragma comment(lib, "opencv_core300d.lib")  
#pragma comment(lib, "opencv_highgui300d.lib")    
#pragma comment(lib, "opencv_imgcodecs300d.lib")  
#pragma comment(lib, "opencv_imgproc300d.lib") //line, circle  
#pragma comment(lib, "opencv_core300.lib")  
#pragma comment(lib, "opencv_highgui300.lib")  
#pragma comment(lib, "opencv_imgcodecs300.lib")  
#pragma comment(lib, "opencv_imgproc300.lib") //line, circle  

//DEEP lib
#pragma comment(lib, "MareDeepDLL.lib")  

using namespace cv;
using namespace std;

void main()

 //DEEP Class
 MareDeepDll_B cDeep;

 //load model and structure
 cDeep.SetNet("lenet_test-memory-1.prototxt", "lenet_iter_10000.caffemodel");
 //gpu using on

 for (int i = 1; i <  14; ++i)
  // time check..
  unsigned long AAtime = 0, BBtime = 0;
  AAtime = getTickCount();

  //make file name
  char str[256];  
  sprintf_s(str, "%d.jpg", i);
  printf("%s\n", str);

  //img load and preprocessing
  Mat img = imread(str);
  resize(img, img, Size(28, 28));
  cvtColor(img, img, CV_BGR2GRAY);  

  vector< double> rV;
  //image and class num (caution!! class num is dependented by learning condition.) lenet is classify one number in 10 digits.
  rV = cDeep.eval(img, 10);

  //result out
  for (int i = 0; i <  rV.size(); i++) {
   printf("Probability to be Number %d is %.3f\n", i, rV[i]);   

  // processing time check.
  BBtime = getTickCount();
  printf("%.2lf sec / %.2lf fps\n", (BBtime - AAtime) / getTickFrequency(), 1 / ((BBtime - AAtime) / getTickFrequency()));

  namedWindow("test", 0);
  imshow("test", img);


Lenet model was used to test the deep learning classification.
Many other models are introduced on github model zoo.
You can apply other case, on code cDeep.SetNet("lenet_test-memory-1.prototxt", "lenet_iter_10000.caffemodel"); , first param means model structure and second param means the result of deep learning.

If you request to Google Plus to me, I will send the dll with the application code(project).


  1. Hii, can you post the training process? I have some problems to set training parameters

    1. I plan to post the code about learning method of deep learning.
      However, it is difficult for the parameter settings.
      because it require understanding of deep learning algorithm.
      I think tensor flow is good to study deep learning.
      I plan to post later about tensor flow.

      Can you open your learning data and parameter?
      Then I also try learning.

      Thank you.

  2. 안녕하세요? 블로그 및 openCV강좌 유용하게 잘보고있습니다!! 다름이아니라 caffe설치에 의문점이 있습니다. 일단 github에서 구성요소들을 받았는데 caffe를 추가하려면 opencv설치할때 사용한 cmake프로그램에서 경로지정해주고 똑같이 진행하면 되나요? 그리고 include 디렉토리는 바로 찾았는데 caffe_libs는 무슨 파일로 지정해줘야할지 모르겠네요.. 아무쪼록 답변기다리겠습니다.