91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 53.02MB
    文件類型: .rar
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2022-11-05
  • 語言: C/C++
  • 標簽: 深度學習??c++??

資源簡介

HED深度學習邊緣提取的c++接口測試程序

資源截圖

代碼片段和文件信息

#include?
#include?
#include?
#include?
#include?
#include?“caffe/data_transformer.hpp“
#include?“caffe/util/io.hpp“
#include?“caffe/util/math_functions.hpp“
#include?“caffe/util/rng.hpp“

using?namespace?caffe;
using?namespace?cv;
using?namespace?std;


#define?PRINT_SHAPE1(x)?\
????std::cout?<#define?PRINT_SHAPE2(x)?\
????std::cout?<num()?<channels()?<height()?<width()?<#define?PRINT_DATA(x)?\
????std::cout?<


class?EdgeDetect
{
public:
????Mat?mean_;
????Size?input_geometry;
????int?num_channels;
????shared_ptr??>?net;

public:
????EdgeDetect(const?string&?model_file?const?string&?trained_fileconst?string&?mean_file);
????void?WrapInputlayer(std::vector*?input_channels);
????void?Preprocess(const?cv::Mat&?imgstd::vector*?input_channels);
????void?SetMean(const?string&?mean_file);
};



EdgeDetect::EdgeDetect(const?string&?model_fileconst?string&?trained_fileconst?string&?mean_file)
{
??Caffe::set_mode(Caffe::CPU);



??net.reset(new?Net(model_file?TEST));

??net->CopyTrainedlayersFrom(trained_file);

??CHECK_EQ(net->num_inputs()?1)?<??//CHECK_EQ(net->num_outputs()?1)?<
??Blob*?input_layer?=?net->input_blobs()[0];
??num_channels?=?input_layer->channels();

??CHECK(num_channels?==?3?||?num_channels?==?1)<yer?should?have?1?or?3?channels.“;

??input_geometry?=?cv::Size(input_layer->width()?input_layer->height());


??SetMean(mean_file);
}




void?EdgeDetect::Preprocess(const?cv::Mat&?imgstd::vector*?input_channels)
{

??cv::Mat?sample;

??if?(img.channels()?==?3?&&?num_channels?==?1)
????cv::cvtColor(img?sample?CV_BGR2GRAY);
??else?if?(img.channels()?==?4?&&?num_channels?==?1)
????cv::cvtColor(img?sample?CV_BGRA2GRAY);

??else?if?(img.channels()?==?4?&&?num_channels?==?3)
????cv::cvtColor(img?sample?CV_BGRA2BGR);
??else?if?(img.channels()?==?1?&&?num_channels?==?3)
????cv::cvtColor(img?sample?CV_GRAY2BGR);
??else
????sample?=?img;

??cv::Mat?sample_resized;
??if?(sample.size()?!=?input_geometry)
????cv::resize(sample?sample_resized?input_geometry);
??else
????sample_resized?=?sample;

??imshow(“resize“sample_resized);

??cv::Mat?sample_float;
??if?(num_channels?==?3)
????sample_resized.convertTo(sample_float?CV_32FC3);
??else
????sample_resized.convertTo(sample_float?CV_32FC1);

??cv::Mat?sample_normalized;
??cv::subtract(sample_float?mean_?sample_normalized);

??/*?3通道數(shù)據(jù)分開存儲?*/
??cv::split(sample_normalized?*input_channels);

??CHECK(reinterpret_cast(input_channels->at(0).data)?==?net->input_blobs()[0]->cpu_data())?<yer?of?the?network.“;
}

//加載均值文件
void

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????47609??2015-10-01?10:38??HEDC++\3063.jpg

?????文件???????8186??2017-02-28?11:50??HEDC++\deploy.prototxt

?????文件???58876104??2017-03-31?09:17??HEDC++\hed_pretrained_bsds.caffemodel

?????文件?????786446??2014-02-25?16:24??HEDC++\imagenet_mean.binaryproto

?????文件??????10130??2017-06-21?15:34??HEDC++\main.cpp

?????目錄??????????0??2017-06-21?15:34??HEDC++

-----------?---------??----------?-----??----

?????????????59728475????????????????????6


評論

共有 條評論