caffe textboxes++测试(c++版本)-mainlib.cpp

这里是测试主函数mainlib.cpp

#include   // for snprintf
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include "boost/algorithm/string.hpp"
#include "google/protobuf/text_format.h"
#include "leveldb/db.h"
#include "leveldb/write_batch.h"

#include "caffe/blob.hpp"
#include "caffe/common.hpp"
#include "caffe/net.hpp"
#include "caffe/proto/caffe.pb.h"
#include "caffe/util/io.hpp"

#include "caffe/layers/memory_data_layer.hpp"
#include "caffe/caffe.hpp"

#include "opencv2/opencv.hpp"

#include 
#include 
#include 

#include 
#include 
#include 
#include "caffe/Cut2Image.h"
#include "caffe/ocr.h"
#include "caffe/boxDetect.h"
#include "caffe/cutImage.h"
#include "caffe/ctc_ocr.h"
#include "classification.hpp"

#include "caffe/nms.h"

#include  
#include  

#define K 4//4

using namespace caffe;
using namespace std;

extern "C" {
    Classifier *classifier[K];
    Classifier *classifier_isCWB;
    Detector *detector_textbox;
    ICNNPredict* pCNN;

    void getBoxImg(IplImage* img,vector &box_imgs, int num,const char* imgfolder)
    {
        if(img==NULL)
        {
            cout<< "Unable to decode image "< > detections = detector_textbox->Detect(cv::Mat(img));
        // vector > detections = detector_textbox->Multi_Scale_Detect(cv::Mat(img));  
        vector proposals;
        // vector proposals;//nms
        //std::vector scores;

        /* Print the detection results. */
        for (int i = 0; i < detections.size(); ++i)
        {
            const vector& d = detections[i];
            // Detection format: [det_conf, det_x1, det_y2, det_x2, det_y2, det_x3, det_y3, det_x4, det_y4].
            CHECK_EQ(d.size(), 9);
            const float score = d[0];
            float confidence_threshold=0.6;//0.01;
            //cout<<"score="<= confidence_threshold)
            {
                int det_x1=static_cast(d[1] * cv::Mat(img).cols);
                int det_y1=static_cast(d[2] * cv::Mat(img).rows);
                int det_x2=static_cast(d[3] * cv::Mat(img).cols);
                int det_y2=static_cast(d[4] * cv::Mat(img).rows);
                int det_x3=static_cast(d[5] * cv::Mat(img).cols);
                int det_y3=static_cast(d[6] * cv::Mat(img).rows);
                int det_x4=static_cast(d[7] * cv::Mat(img).cols);
                int det_y4=static_cast(d[8] * cv::Mat(img).rows);
                det_x1 = max(1, min(det_x1, img->width-1));
                det_x2 = max(1, min(det_x2, img->width-1));
                det_x3 = max(1, min(det_x3, img->width-1));
                det_x4 = max(1, min(det_x4, img->width-1));
                det_y1 = max(1, min(det_y1, img->height-1));
                det_y2 = max(1, min(det_y2, img->height-1));
                det_y3 = max(1, min(det_y3, img->height-1));
                det_y4 = max(1, min(det_y4, img->height-1));
               
                 
                proposal_type pro;
                pro.x1=det_x1;
                pro.x2=det_x2;
                pro.x3=det_x3;
                pro.x4=det_x4;
                pro.y1=det_y1;
                pro.y2=det_y2;
                pro.y3=det_y3;
                pro.y4=det_y4;
                pro.score=score;
                proposals.push_back(pro);
            }
        }
        //cout<<"detection"<& BoxImg)
    {
        if(Img == NULL)
        {
            cout << "Image is NULL" << endl;
            return;
        }
        Cut2ImagesByBlank(Img, BoxImg);
        for(int i=0; i ImgNames;
        char str3[1000];
        //strcpy(str3, str1);
        //strcat(str3, str2);
        //得到图片路径
        sprintf(str3,"%s%s",rootname,imgfolder);
        cout< box_imgs;
            getBoxImg(Img_ipl,box_imgs, i,imgfolder);

        }
    }

}

你可能感兴趣的:(caffe textboxes++测试(c++版本)-mainlib.cpp)