vendor: OpenCV 5.0.0 snapshot at 755e50675d97db9b7d449d8bd6b09888646f6c6e
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
Training data generation using Icosphere {#tutorial_data_generation}
|
||||
=============
|
||||
|
||||
Goal
|
||||
----
|
||||
|
||||
In this tutorial you will learn how to
|
||||
|
||||
- Conduct a point cloud of camera view on sphere.
|
||||
- Generate training images using 3D model.
|
||||
|
||||
Code
|
||||
----
|
||||
|
||||
@include cnn_3dobj/samples/sphereview_data.cpp
|
||||
|
||||
Explanation
|
||||
-----------
|
||||
|
||||
Here is the general structure of the program:
|
||||
|
||||
- Create a window.
|
||||
@code{.cpp}
|
||||
viz::Viz3d myWindow("Coordinate Frame");
|
||||
@endcode
|
||||
|
||||
- Set window size as 64*64, we use this scale as default.
|
||||
@code{.cpp}
|
||||
myWindow.setWindowSize(Size(64,64));
|
||||
@endcode
|
||||
|
||||
- Add coordinate axes.
|
||||
@code{.cpp}
|
||||
myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem());
|
||||
myWindow.setBackgroundColor(viz::Color::gray());
|
||||
myWindow.spin();
|
||||
@endcode
|
||||
|
||||
- Create a Mesh widget, loading .ply models.
|
||||
@code{.cpp}
|
||||
viz::Mesh objmesh = viz::Mesh::load(plymodel);
|
||||
@endcode
|
||||
- Get the center of the generated mesh widget, cause some .ply files.
|
||||
@code{.cpp}
|
||||
Point3d cam_focal_point = ViewSphere.getCenter(objmesh.cloud);
|
||||
@endcode
|
||||
|
||||
- Get the pose of the camera using makeCameraPoses.
|
||||
@code{.cpp}
|
||||
Affine3f cam_pose = viz::makeCameraPose(campos.at(pose)*radius+cam_focal_point, cam_focal_point, cam_y_dir*radius+cam_focal_point);
|
||||
@endcode
|
||||
|
||||
- Get the transformation matrix from camera coordinate system to global.
|
||||
@code{.cpp}
|
||||
Affine3f transform = viz::makeTransformToGlobal(Vec3f(1.0f,0.0f,0.0f), Vec3f(0.0f,1.0f,0.0f), Vec3f(0.0f,0.0f,1.0f), campos.at(pose));
|
||||
viz::WMesh mesh_widget(objmesh);
|
||||
@endcode
|
||||
|
||||
- Save screen shot as images.
|
||||
@code{.cpp}
|
||||
myWindow.saveScreenshot(filename);
|
||||
@endcode
|
||||
|
||||
- Write images into binary files for further using in CNN training.
|
||||
@code{.cpp}
|
||||
ViewSphere.writeBinaryfile(filename, binaryPath, headerPath,(int)campos.size()*num_class, label_class, (int)(campos.at(pose).x*100), (int)(campos.at(pose).y*100), (int)(campos.at(pose).z*100), rgb_use);
|
||||
@endcode
|
||||
|
||||
Results
|
||||
-------
|
||||
|
||||
Here is collection images created by this demo using 4 model.
|
||||
|
||||

|
||||
@@ -0,0 +1,65 @@
|
||||
Classify {#tutorial_feature_classification}
|
||||
===============
|
||||
|
||||
Goal
|
||||
----
|
||||
|
||||
In this tutorial you will learn how to
|
||||
|
||||
- How to extract feature from an image
|
||||
- How to extract features from images under a given root path
|
||||
- How to make a prediction using reference images and target image
|
||||
|
||||
Code
|
||||
----
|
||||
|
||||
@include cnn_3dobj/samples/classify.cpp
|
||||
|
||||
Explanation
|
||||
-----------
|
||||
|
||||
Here is the general structure of the program:
|
||||
|
||||
- Initialize a net work with Device.
|
||||
@code{.cpp}
|
||||
cv::cnn_3dobj::descriptorExtractor descriptor(device);
|
||||
@endcode
|
||||
|
||||
- Load net with the caffe trained net work parameter and structure.
|
||||
@code{.cpp}
|
||||
if (strcmp(mean_file.c_str(), "no") == 0)
|
||||
descriptor.loadNet(network_forIMG, caffemodel);
|
||||
else
|
||||
descriptor.loadNet(network_forIMG, caffemodel, mean_file);
|
||||
@endcode
|
||||
|
||||
- List the file names under a given path.
|
||||
@code{.cpp}
|
||||
listDir(src_dir.c_str(), name_gallery, false);
|
||||
for (unsigned int i = 0; i < name_gallery.size(); i++)
|
||||
{
|
||||
name_gallery[i] = src_dir + name_gallery[i];
|
||||
}
|
||||
@endcode
|
||||
|
||||
- Extract feature from a set of images.
|
||||
@code{.cpp}
|
||||
descriptor.extract(img_gallery, feature_reference, feature_blob);
|
||||
@endcode
|
||||
|
||||
- Initialize a matcher which using L2 distance.
|
||||
@code{.cpp}
|
||||
cv::BFMatcher matcher(NORM_L2);
|
||||
std::vector<std::vector<cv::DMatch> > matches;
|
||||
@endcode
|
||||
|
||||
- Have a KNN match on the target and reference images.
|
||||
@code{.cpp}
|
||||
matcher.knnMatch(feature_test, feature_reference, matches, num_candidate);
|
||||
@endcode
|
||||
|
||||
- Print features of the reference images.
|
||||
@code{.cpp}std::cout << std::endl << "---------- Features of target image: " << target_img << "----------" << endl << feature_test << std::endl;
|
||||
@endcode
|
||||
Results
|
||||
-------
|
||||
@@ -0,0 +1,59 @@
|
||||
Training Model Analysis {#tutorial_model_analysis}
|
||||
=============
|
||||
|
||||
Goal
|
||||
----
|
||||
|
||||
In this tutorial you will learn how to
|
||||
|
||||
- Extract feature from particular image.
|
||||
- Have a meaningful comparation on the extracted feature.
|
||||
|
||||
Code
|
||||
----
|
||||
|
||||
@include cnn_3dobj/samples/model_analysis.cpp
|
||||
|
||||
Explanation
|
||||
-----------
|
||||
|
||||
Here is the general structure of the program:
|
||||
|
||||
- Sample which is most closest in pose to reference image and also the same class.
|
||||
@code{.cpp}
|
||||
ref_img.push_back(ref_img1);
|
||||
@endcode
|
||||
|
||||
- Sample which is less closest in pose to reference image and also the same class.
|
||||
@code{.cpp}
|
||||
ref_img.push_back(ref_img2);
|
||||
@endcode
|
||||
|
||||
- Sample which is very close in pose to reference image but not the same class.
|
||||
@code{.cpp}
|
||||
ref_img.push_back(ref_img3);
|
||||
@endcode
|
||||
|
||||
- Initialize a net work with Device.
|
||||
@code{.cpp}
|
||||
cv::cnn_3dobj::descriptorExtractor descriptor(device, dev_id);
|
||||
@endcode
|
||||
- Load net with the caffe trained net work parameter and structure.
|
||||
@code{.cpp}
|
||||
if (strcmp(mean_file.c_str(), "no") == 0)
|
||||
descriptor.loadNet(network_forIMG, caffemodel);
|
||||
else
|
||||
descriptor.loadNet(network_forIMG, caffemodel, mean_file);
|
||||
@endcode
|
||||
|
||||
- Have comparations on the distance between reference image and 3 other images
|
||||
distance between closest sample and reference image should be smallest and
|
||||
distance between sample in another class and reference image should be largest.
|
||||
@code{.cpp}
|
||||
if (matches[0] < matches[1] && matches[0] < matches[2])
|
||||
pose_pass = true;
|
||||
if (matches[1] < matches[2])
|
||||
class_pass = true;
|
||||
@endcode
|
||||
Results
|
||||
-------
|
||||
@@ -0,0 +1,26 @@
|
||||
CNN for 3D Object Classification and Pose Estimation {#tutorial_table_of_content_cnn_3dobj}
|
||||
==========
|
||||
|
||||
- @subpage tutorial_data_generation
|
||||
|
||||
*Compatibility:* \> OpenCV 3.0.0
|
||||
|
||||
*Author:* Yida Wang
|
||||
|
||||
You will learn how to generate training images from 3D models with proper poses for CNN training.
|
||||
|
||||
- @subpage tutorial_feature_classification
|
||||
|
||||
*Compatibility:* \> OpenCV 3.0.0
|
||||
|
||||
*Author:* Yida Wang
|
||||
|
||||
You will learn how to extract features from images and make a prediction using descriptor.
|
||||
|
||||
- @subpage tutorial_model_analysis
|
||||
|
||||
*Compatibility:* \> OpenCV 3.0.0
|
||||
|
||||
*Author:* Yida Wang
|
||||
|
||||
You will learn how to analyze performance of a trained Model.
|
||||
Reference in New Issue
Block a user