parent
ba770cd524
commit
a0d5630117
4 changed files with 93 additions and 2 deletions
@ -0,0 +1,70 @@ |
||||
/*
|
||||
* Created on: Aug 14, 2015 |
||||
* Author: yidawang |
||||
*/ |
||||
|
||||
#include "test_precomp.hpp" |
||||
|
||||
using namespace cv; |
||||
using namespace cv::cnn_3dobj; |
||||
|
||||
class CV_CNN_Feature_Test : public cvtest::BaseTest |
||||
{ |
||||
public: |
||||
CV_CNN_Feature_Test(); |
||||
protected: |
||||
void run(int); |
||||
}; |
||||
|
||||
CV_CNN_Feature_Test::CV_CNN_Feature_Test() |
||||
{ |
||||
} |
||||
|
||||
/**
|
||||
* This test checks the following: |
||||
* Feature extraction by the triplet trained CNN model |
||||
*/ |
||||
void CV_CNN_Feature_Test::run(int) |
||||
{ |
||||
string caffemodel = ts->get_data_path() + "cnn_3dobj/samples/data/3d_triplet_iter_20000.caffemodel"; |
||||
string network_forIMG = ts->get_data_path() + "cnn_3dobj/samples/data/3d_triplet_testIMG.prototxt"; |
||||
string mean_file = "no"; |
||||
string target_img = ts->get_data_path() + "cnn_3dobj/samples/data/images_all/2_24.png"; |
||||
string feature_blob = "feat"; |
||||
string device = "CPU"; |
||||
int dev_id = 0; |
||||
|
||||
cv::cnn_3dobj::descriptorExtractor descriptor; |
||||
bool set_succeed = descriptor.setNet(device, dev_id); |
||||
if (!set_succeed) { |
||||
ts->printf(cvtest::TS::LOG, "Net parameters which is GPU or CPU could not be set"); |
||||
ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA); |
||||
return; |
||||
} |
||||
int net_ready; |
||||
if (strcmp(mean_file.c_str(), "no") == 0) |
||||
net_ready = descriptor.loadNet(set_succeed, network_forIMG, caffemodel); |
||||
else |
||||
net_ready = descriptor.loadNet(set_succeed, network_forIMG, caffemodel, mean_file); |
||||
if (!net_ready) { |
||||
ts->printf(cvtest::TS::LOG, "No model loaded"); |
||||
ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA); |
||||
return; |
||||
} |
||||
cv::Mat img = cv::imread(target_img, -1); |
||||
if (img.empty()) { |
||||
ts->printf(cvtest::TS::LOG, "could not read image %s\n", target_img.c_str()); |
||||
ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA); |
||||
return; |
||||
} |
||||
cv::Mat feature_test; |
||||
descriptor.extract(net_ready, img, feature_test, feature_blob); |
||||
if (feature_test.empty()) { |
||||
ts->printf(cvtest::TS::LOG, "could not extract feature from image %s\n", target_img.c_str()); |
||||
ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA); |
||||
return; |
||||
} |
||||
|
||||
} |
||||
|
||||
TEST(VIDEO_BGSUBGMG, accuracy) { CV_CNN_Feature_Test test; test.safe_run(); } |
@ -0,0 +1,3 @@ |
||||
#include "test_precomp.hpp" |
||||
|
||||
CV_TEST_MAIN("cv") |
@ -0,0 +1,18 @@ |
||||
#ifdef __GNUC__ |
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations" |
||||
# if defined __clang__ || defined __APPLE__ |
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes" |
||||
# pragma GCC diagnostic ignored "-Wextra" |
||||
# endif |
||||
#endif |
||||
|
||||
#ifndef __OPENCV_TEST_PRECOMP_HPP__ |
||||
#define __OPENCV_TEST_PRECOMP_HPP__ |
||||
|
||||
#include <iostream> |
||||
#include "opencv2/ts.hpp" |
||||
#include "opencv2/imgproc.hpp" |
||||
#include "opencv2/cnn_3dobj_config.hpp" |
||||
#include "opencv2/cnn_3dobj.hpp" |
||||
|
||||
#endif |
Loading…
Reference in new issue