Skip to content

Commit 197fba6

Browse files
committed
modify the test of module cnn_3dobj
1 parent cabd5d4 commit 197fba6

19 files changed

+453
-159
lines changed

modules/cnn_3dobj/README.md

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
#Convolutional Neural Network for 3D object classification and pose estimation.
2-
============================================
2+
===========================================================
33
#Module Description on cnn_3dobj:
4-
This learning structure construction and feature extraction concept is based on Convolutional Neural Network, the main reference paper could be found at:
5-
https://cvarlab.icg.tugraz.at/pubs/wohlhart_cvpr15.pdf
6-
The author provided Codes on Theano on:
7-
https://cvarlab.icg.tugraz.at/projects/3d_object_detection/
8-
I implemented the training and feature extraction codes mainly based on CAFFE project which will be compiled as libcaffe for the cnn_3dobj OpenCV module, codes are mainly concentrating on triplet and pair-wise jointed loss layer, the training data arrangement is also important which basic training information.
9-
Codes about my triplet version of caffe are released on GIthub, you can git it through:
4+
####This learning structure construction and feature extraction concept is based on Convolutional Neural Network, the main reference paper could be found at:
5+
<https://cvarlab.icg.tugraz.at/pubs/wohlhart_cvpr15.pdf>.
6+
####The author provided Codes on Theano on:
7+
<https://cvarlab.icg.tugraz.at/projects/3d_object_detection/>.
8+
####I implemented the training and feature extraction codes mainly based on CAFFE project(<http://caffe.berkeleyvision.org/>) which will be compiled as libcaffe for the cnn_3dobj OpenCV module, codes are mainly concentrating on triplet and pair-wise jointed loss layer, the training data arrangement is also important which basic training information.
9+
####Codes about my triplet version of caffe are released on Github:
10+
<https://github.com/Wangyida/caffe/tree/cnn_triplet>.
11+
####You can git it through:
1012
```
1113
$ git clone https://github.com/Wangyida/caffe/tree/cnn_triplet.
1214
```
13-
============================================
15+
===========================================================
1416
#Module Building Process:
15-
###Prerequisite for this module: protobuf and caffe, for the libcaffe installation, you can install it on standard system path for the aim of being able to be linked by this OpenCV module when compiling and function using. Using: -D CMAKE_INSTALL_PREFIX=/usr/local as an building option when you cmake, the building process on Caffe on system could be like this:
17+
####Prerequisite for this module: protobuf and caffe, for the libcaffe installation, you can install it on standard system path for the aim of being able to be linked by this OpenCV module when compiling and function using. Using: -D CMAKE_INSTALL_PREFIX=/usr/local as an building option when you cmake, the building process on Caffe on system could be like this:
1618
```
1719
$ cd <caffe_source_directory>
1820
$ mkdir biuld
@@ -21,26 +23,26 @@ $ cmake -D CMAKE_INSTALL_PREFIX=/usr/local ..
2123
$ make all -j4
2224
$ sudo make install
2325
```
24-
###After all these steps, the headers and libs of CAFFE will be set on /usr/local/ path, and when you compiling opencv with opencv_contrib modules as below, the protobuf and caffe will be recognized as already installed while building. Protobuf is needed.
26+
####After all these steps, the headers and libs of CAFFE will be set on /usr/local/ path, and when you compiling opencv with opencv_contrib modules as below, the protobuf and caffe will be recognized as already installed while building. Protobuf is needed.
2527

2628
#Compiling OpenCV
2729
```
2830
$ cd <opencv_source_directory>
2931
$ mkdir build
3032
$ cd build
31-
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=OFF -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_VTK=ON -D OPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules ..
33+
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=OFF -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_VTK=ON -D INSTALL_TESTS=ON -D OPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules ..
3234
$ make -j4
3335
$ sudo make install
3436
```
3537
##Tips on compiling problems:
36-
###If you encouter the no declaration errors when you 'make', it might becaused that you have installed the older version of cnn_3dobj module and the header file changed in a newly released version of codes. This problem is the cmake and make can't detect the header should be updated and it keeps the older header remains in /usr/local/include/opencv2 whithout updating. This error could be solved by remove the installed older version of cnn_3dobj module by:
38+
####If you encouter the no declaration errors when you 'make', it might becaused that you have installed the older version of cnn_3dobj module and the header file changed in a newly released version of codes. This problem is the cmake and make can't detect the header should be updated and it keeps the older header remains in /usr/local/include/opencv2 whithout updating. This error could be solved by remove the installed older version of cnn_3dobj module by:
3739
```
3840
$ cd /
3941
$ cd usr/local/include/opencv2/
4042
$ sudo rm -rf cnn_3dobj.hpp
4143
```
42-
###And redo the compiling steps above again.
43-
================================================
44+
####And redo the compiling steps above again.
45+
===========================================================
4446
#Building samples
4547
```
4648
$ cd <opencv_contrib>/modules/cnn_3dobj/samples
@@ -49,50 +51,60 @@ $ cd build
4951
$ cmake ..
5052
$ make
5153
```
52-
53-
=============
54+
===========================================================
5455
#Demos
5556
##Demo1: training data generation
56-
###Imagas generation from different pose, by default there are 4 models used, there will be 276 images in all which each class contains 69 iamges, if you want to use additional .ply models, it is necessary to change the class number parameter to the new class number and also give it a new class label. If you will train net work and extract feature from RGB images set the parameter rgb_use as 1.
57+
####Imagas generation from different pose, by default there are 4 models used, there will be 276 images in all which each class contains 69 iamges, if you want to use additional .ply models, it is necessary to change the class number parameter to the new class number and also give it a new class label. If you will train net work and extract feature from RGB images set the parameter rgb_use as 1.
5758
```
58-
$ ./sphereview_test -plymodel=../3Dmodel/ape.ply -label_class=0
59+
$ ./sphereview_test -plymodel=../data/3Dmodel/ape.ply -label_class=0
5960
```
60-
###press 'Q' to start 2D image genaration
61+
####press 'Q' to start 2D image genaration
6162
```
62-
$ ./sphereview_test -plymodel=../3Dmodel/ant.ply -label_class=1
63+
$ ./sphereview_test -plymodel=../data/3Dmodel/ant.ply -label_class=1
6364
```
64-
###press 'Q' to start
65+
####press 'Q' to start
6566
```
66-
$ ./sphereview_test -plymodel=../3Dmodel/cow.ply -label_class=2
67+
$ ./sphereview_test -plymodel=../data/3Dmodel/cow.ply -label_class=2
6768
```
68-
###press 'Q' to start
69+
####press 'Q' to start
6970
```
70-
$ ./sphereview_test -plymodel=../3Dmodel/plane.ply -label_class=3
71+
$ ./sphereview_test -plymodel=../data/3Dmodel/plane.ply -label_class=3
7172
```
72-
###press 'Q' to start
73+
####press 'Q' to start
7374

74-
###When all images are created in images_all folder as a collection of training images for network tranining and as a gallery of reference images for the classification part, then proceed on.
75-
###After this demo, the binary files of images and labels will be stored as 'binary_image' and 'binary_label' in current path, you should copy them into the leveldb folder in Caffe triplet training, for example: copy these 2 files in <caffe_source_directory>/data/linemod and rename them as 'binary_image_train', 'binary_image_test' and 'binary_label_train', 'binary_label_train'. Here I use the same as trianing and testing data, you can use different data for training and testing the performance in the CAFFE training process. It's important to observe the loss of testing data to check whether training data is suitable for the your aim. Loss should be obseved as keep decreasing and remain on a much smaller number than the initial loss.
76-
###You could start triplet tranining using Caffe like this:
75+
####When all images are created in images_all folder as a collection of training images for network tranining and as a gallery of reference images for the classification part, then proceed on.
76+
####After this demo, the binary files of images and labels will be stored as 'binary_image' and 'binary_label' in current path, you should copy them into the leveldb folder in Caffe triplet training, for example: copy these 2 files in <caffe_source_directory>/data/linemod and rename them as 'binary_image_train', 'binary_image_test' and 'binary_label_train', 'binary_label_train'. Here I use the same as trianing and testing data, you can use different data for training and testing the performance in the CAFFE training process. It's important to observe the loss of testing data to check whether training data is suitable for the your aim. Loss should be obseved as keep decreasing and remain on a much smaller number than the initial loss.
77+
####You could start triplet tranining using Caffe like this:
7778
```
7879
$ cd
7980
$ cd <caffe_source_directory>
8081
$ ./examples/triplet/create_3d_triplet.sh
8182
$ ./examples/triplet/train_3d_triplet.sh
8283
```
83-
###After doing this, you will get .caffemodel files as the trained parameter of net work. I have already provide the net definition .prototxt files and the pretrained .caffemodel in <opencv_contrib>/modules/cnn_3dobj/samples/build/data folder, you could just use them without training in caffe.
84-
==============
84+
####After doing this, you will get .caffemodel files as the trained parameter of net work. I have already provide the net definition .prototxt files and the pretrained .caffemodel in <opencv_contrib>/modules/cnn_3dobj/testdata/cv folder, you could just use them without training in caffe.
85+
===========================================================
8586
##Demo2: feature extraction and classification
8687
```
8788
$ cd
8889
$ cd <opencv_contrib>/modules/cnn_3dobj/samples/build
8990
```
90-
###Classifier, this will extracting the feature of a single image and compare it with features of gallery samples for prediction. This demo uses a set of images for feature extraction in a given path, these features will be a reference for prediction on target image. Just run:
91+
####Classifier, this will extracting the feature of a single image and compare it with features of gallery samples for prediction. This demo uses a set of images for feature extraction in a given path, these features will be a reference for prediction on target image. The caffe model and network prototxt file is attached in <opencv_contrib>/modules/cnn_3dobj/testdata/cv. Just run:
9192
```
9293
$ ./classify_test
9394
```
94-
###if the classification and pose estimation issue need to extract mean got from all training images, you can run this:
95+
####if the classification and pose estimation issue need to extract mean got from all training images, you can run this:
9596
```
9697
$ ./classify_test -mean_file=../data/images_mean/triplet_mean.binaryproto
9798
```
98-
==============================================
99+
===========================================================
100+
##Demo3: model performance test
101+
####This demo will have a test on the performance of trained CNN model on several images. If the the model fail on telling different samples from seperate classes or confused on samples with similar pose but from different classes, it will give some information on the model analysis.
102+
```
103+
$ ./model_test
104+
```
105+
===========================================================
106+
#Test
107+
####If you want to have a test on cnn_3dobj module, the path of test data must be set in advance:
108+
```
109+
$ export OPENCV_TEST_DATA_PATH=<opencv_contrib>/modules/cnn_3dobj/testdata
110+
```

modules/cnn_3dobj/doc/cnn_3dobj.bib

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@ @Article{hinterstoisser2008panter
44
booktitle = {BMVC British Machine Vision Conference 2008},
55
year = {2008}
66
}
7+
8+
@inproceedings{wohlhart15,
9+
author = {Paul Wohlhart and Vincent Lepetit},
10+
title = {Learning Descriptors for Object Recognition and 3D Pose Estimation},
11+
booktitle = {Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},
12+
year = {2015}
13+
}

0 commit comments

Comments
 (0)