constStringkeys="{help | | this demo will convert a set of images in a particular path into leveldb database for feature extraction using Caffe. If there little variance in data such as human faces, you can add a mean_file, otherwise it is not so useful}"
constStringkeys="{help | | This sample will extract featrues from reference images and target image for classification. You can add a mean_file if there little variance in data such as human faces, otherwise it is not so useful}"
"{src_dir | ../data/images_all/ | Source direction of the images ready for being used for extract feature as gallery.}"
"{src_dir | ../data/images_all/ | Source direction of the images ready for being used for extract feature as gallery.}"
"{caffemodel | ../../testdata/cv/3d_triplet_iter_30000.caffemodel | caffe model for feature exrtaction.}"
"{caffemodel | ../../testdata/cv/3d_triplet_iter_30000.caffemodel | caffe model for feature exrtaction.}"
"{network_forIMG | ../../testdata/cv/3d_triplet_testIMG.prototxt | Network definition file used for extracting feature from a single image and making a classification}"
"{network_forIMG | ../../testdata/cv/3d_triplet_testIMG.prototxt | Network definition file used for extracting feature from a single image and making a classification}"
...
@@ -80,10 +91,12 @@ int main(int argc, char** argv)
...
@@ -80,10 +91,12 @@ int main(int argc, char** argv)
"{target_img | ../data/images_all/1_8.png | Path of image waiting to be classified.}"
"{target_img | ../data/images_all/1_8.png | Path of image waiting to be classified.}"
"{feature_blob | feat | Name of layer which will represent as the feature, in this network, ip1 or feat is well.}"
"{feature_blob | feat | Name of layer which will represent as the feature, in this network, ip1 or feat is well.}"
"{num_candidate | 15 | Number of candidates in gallery as the prediction result.}"
"{num_candidate | 15 | Number of candidates in gallery as the prediction result.}"
"{device | CPU | device}"
"{device | CPU | Device type: CPU or GPU}"
"{dev_id | 0 | dev_id}";
"{dev_id | 0 | Device id}";
/* get parameters from comand line */
cv::CommandLineParserparser(argc,argv,keys);
cv::CommandLineParserparser(argc,argv,keys);
parser.about("Demo for object data classification and pose estimation");
parser.about("Feature extraction and classification");
if(parser.has("help"))
if(parser.has("help"))
{
{
parser.printMessage();
parser.printMessage();
...
@@ -99,13 +112,18 @@ int main(int argc, char** argv)
...
@@ -99,13 +112,18 @@ int main(int argc, char** argv)
* @brief Generating training data for CNN with triplet loss.
* @author Yida Wang
*/
#define HAVE_CAFFE
#define HAVE_CAFFE
#include <opencv2/cnn_3dobj.hpp>
#include <opencv2/cnn_3dobj.hpp>
#include <opencv2/viz/vizcore.hpp>
#include <opencv2/viz/vizcore.hpp>
...
@@ -44,14 +49,15 @@ int main(int argc, char *argv[])
...
@@ -44,14 +49,15 @@ int main(int argc, char *argv[])
{
{
constStringkeys="{help | | demo :$ ./sphereview_test -ite_depth=2 -plymodel=../data/3Dmodel/ape.ply -imagedir=../data/images_all/ -labeldir=../data/label_all.txt -num_class=4 -label_class=0, then press 'q' to run the demo for images generation when you see the gray background and a coordinate.}"
constStringkeys="{help | | demo :$ ./sphereview_test -ite_depth=2 -plymodel=../data/3Dmodel/ape.ply -imagedir=../data/images_all/ -labeldir=../data/label_all.txt -num_class=4 -label_class=0, then press 'q' to run the demo for images generation when you see the gray background and a coordinate.}"
"{ite_depth | 2 | Iteration of sphere generation.}"
"{ite_depth | 2 | Iteration of sphere generation.}"
"{plymodel | ../data/3Dmodel/ape.ply | path of the '.ply' file for image rendering. }"
"{plymodel | ../data/3Dmodel/ape.ply | Path of the '.ply' file for image rendering. }"
"{imagedir | ../data/images_all/ | path of the generated images for one particular .ply model. }"
"{imagedir | ../data/images_all/ | Path of the generated images for one particular .ply model. }"
"{labeldir | ../data/label_all.txt | path of the generated images for one particular .ply model. }"
"{labeldir | ../data/label_all.txt | Path of the generated images for one particular .ply model. }"
"{num_class | 4 | total number of classes of models}"
"{num_class | 4 | Total number of classes of models}"
"{label_class | 0 | class label of current .ply model}"
"{label_class | 0 | Class label of current .ply model}"
"{rgb_use | 0 | use RGB image or grayscale}";
"{rgb_use | 0 | Use RGB image or grayscale}";
/* Get parameters from comand line. */
cv::CommandLineParserparser(argc,argv,keys);
cv::CommandLineParserparser(argc,argv,keys);
parser.about("Demo for Sphere View data generation");
parser.about("Generating training data for CNN with triplet loss");
if(parser.has("help"))
if(parser.has("help"))
{
{
parser.printMessage();
parser.printMessage();
...
@@ -70,23 +76,25 @@ int main(int argc, char *argv[])
...
@@ -70,23 +76,25 @@ int main(int argc, char *argv[])
char*p=(char*)labeldir.data();
char*p=(char*)labeldir.data();
imglabel.open(p,fstream::app|fstream::out);
imglabel.open(p,fstream::app|fstream::out);
boolcamera_pov=(true);
boolcamera_pov=(true);
/// Create a window
/* Create a window using viz. */
viz::Viz3dmyWindow("Coordinate Frame");
viz::Viz3dmyWindow("Coordinate Frame");
/* Set window size as 64*64, we use this scale as default. */