Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv_contrib
Commits
49399734
Commit
49399734
authored
Nov 23, 2016
by
Pavel Rojtberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cnn_3dobj: fix include and allow compilation of samples
caffe/vision_layers.hpp is gone. also fix some warnings.
parent
bd619c55
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
52 deletions
+29
-52
CMakeLists.txt
modules/cnn_3dobj/CMakeLists.txt
+10
-6
FindCaffe.cmake
modules/cnn_3dobj/FindCaffe.cmake
+1
-1
cnn_3dobj.hpp
modules/cnn_3dobj/include/opencv2/cnn_3dobj.hpp
+0
-1
CMakeLists.txt
modules/cnn_3dobj/samples/CMakeLists.txt
+0
-21
demo_classify.cpp
modules/cnn_3dobj/samples/demo_classify.cpp
+6
-8
demo_sphereview_data.cpp
modules/cnn_3dobj/samples/demo_sphereview_data.cpp
+3
-4
demo_video.cpp
modules/cnn_3dobj/samples/demo_video.cpp
+9
-11
No files found.
modules/cnn_3dobj/CMakeLists.txt
View file @
49399734
...
...
@@ -32,13 +32,17 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cnn_3dobj_config.hpp.in
include_directories
(
${
CMAKE_CURRENT_BINARY_DIR
}
)
if
(
${
Caffe_FOUND
}
)
include_directories
(
${
Caffe_INCLUDE_DIR
}
)
endif
()
include_directories
(
${
Caffe_INCLUDE_DIR
}
)
set
(
the_description
"CNN for 3D object recognition and pose estimation including a completed Sphere View on 3D objects"
)
ocv_define_module
(
cnn_3dobj opencv_core opencv_imgproc
opencv_viz opencv_highgui OPTIONAL
WRAP python
)
ocv_define_module
(
cnn_3dobj opencv_core opencv_imgproc
${
Caffe_LIBS
}
${
Glog_LIBS
}
${
Protobuf_LIBS
}
OPTIONAL opencv_features2d opencv_viz opencv_calib3d
WRAP python
)
if
(
${
Caffe_FOUND
}
)
target_link_libraries
(
opencv_
cnn_3dobj
${
Caffe_LIBS
}
${
Glog_LIBS
}
${
Protobuf_LIBS
}
)
if
(
TARGET opencv_test_cnn_3dobj
)
target_link_libraries
(
opencv_
test_cnn_3dobj boost_system
)
endif
()
foreach
(
exe_TGT demo_classify demo_video demo_sphereview_data demo_model_analysis
)
if
(
TARGET example_cnn_3dobj_
${
exe_TGT
}
)
target_link_libraries
(
example_cnn_3dobj_
${
exe_TGT
}
boost_system
)
endif
()
endforeach
()
endif
()
modules/cnn_3dobj/FindCaffe.cmake
View file @
49399734
# Caffe package for CNN Triplet training
unset
(
Caffe_FOUND
)
find_path
(
Caffe_INCLUDE_DIR NAMES caffe/caffe.hpp caffe/common.hpp caffe/net.hpp caffe/proto/caffe.pb.h caffe/util/io.hpp
caffe/vision_layers.hpp
find_path
(
Caffe_INCLUDE_DIR NAMES caffe/caffe.hpp caffe/common.hpp caffe/net.hpp caffe/proto/caffe.pb.h caffe/util/io.hpp
HINTS
/usr/local/include
)
...
...
modules/cnn_3dobj/include/opencv2/cnn_3dobj.hpp
View file @
49399734
...
...
@@ -65,7 +65,6 @@ the use of this software, even if advised of the possibility of such damage.
#include <caffe/net.hpp>
#include <caffe/proto/caffe.pb.h>
#include <caffe/util/io.hpp>
#include <caffe/vision_layers.hpp>
#endif
#include "opencv2/viz/vizcore.hpp"
...
...
modules/cnn_3dobj/samples/CMakeLists.txt
deleted
100755 → 0
View file @
bd619c55
cmake_minimum_required
(
VERSION 2.8
)
SET
(
CMAKE_CXX_FLAGS_DEBUG
"$ENV{CXXFLAGS} -O0 -Wall -g -ggdb "
)
SET
(
CMAKE_CXX_FLAGS_RELEASE
"$ENV{CXXFLAGS} -O3 -Wall"
)
project
(
cnn_3dobj
)
find_package
(
OpenCV REQUIRED
)
set
(
SOURCES_generator demo_sphereview_data.cpp
)
include_directories
(
${
OpenCV_INCLUDE_DIRS
}
)
add_executable
(
sphereview_test
${
SOURCES_generator
}
)
target_link_libraries
(
sphereview_test opencv_core opencv_imgproc opencv_highgui opencv_cnn_3dobj opencv_xfeatures2d
)
set
(
SOURCES_classifier demo_classify.cpp
)
add_executable
(
classify_test
${
SOURCES_classifier
}
)
target_link_libraries
(
classify_test opencv_core opencv_imgproc opencv_highgui opencv_cnn_3dobj opencv_xfeatures2d
)
set
(
SOURCES_modelanalysis demo_model_analysis.cpp
)
add_executable
(
model_test
${
SOURCES_modelanalysis
}
)
target_link_libraries
(
model_test opencv_core opencv_imgproc opencv_highgui opencv_cnn_3dobj opencv_xfeatures2d
)
set
(
SOURCES_video demo_video.cpp
)
add_executable
(
video_test
${
SOURCES_video
}
)
target_link_libraries
(
video_test opencv_core opencv_imgproc opencv_highgui opencv_cnn_3dobj opencv_xfeatures2d
)
modules/cnn_3dobj/samples/demo_classify.cpp
View file @
49399734
...
...
@@ -38,7 +38,7 @@
* @author Yida Wang
*/
#include <opencv2/cnn_3dobj.hpp>
#include <opencv2/features2d
/features2d
.hpp>
#include <opencv2/features2d.hpp>
#include <iomanip>
using
namespace
cv
;
using
namespace
std
;
...
...
@@ -48,7 +48,7 @@ using namespace cv::cnn_3dobj;
* @function listDir
* @brief Making all files names under a directory into a list
*/
void
listDir
(
const
char
*
path
,
std
::
vector
<
String
>&
files
,
bool
r
)
static
void
listDir
(
const
char
*
path
,
std
::
vector
<
String
>&
files
,
bool
r
)
{
DIR
*
pDir
;
struct
dirent
*
ent
;
...
...
@@ -82,7 +82,7 @@ void listDir(const char *path, std::vector<String>& files, bool r)
* @function featureWrite
* @brief Writing features of gallery images into binary files
*/
int
featureWrite
(
const
Mat
&
features
,
const
String
&
fname
)
static
int
featureWrite
(
const
Mat
&
features
,
const
String
&
fname
)
{
ofstream
ouF
;
ouF
.
open
(
fname
.
c_str
(),
std
::
ofstream
::
binary
);
...
...
@@ -131,7 +131,6 @@ int main(int argc, char** argv)
String
feature_blob
=
parser
.
get
<
String
>
(
"feature_blob"
);
int
num_candidate
=
parser
.
get
<
int
>
(
"num_candidate"
);
String
device
=
parser
.
get
<
String
>
(
"device"
);
int
dev_id
=
parser
.
get
<
int
>
(
"dev_id"
);
int
gallery_out
=
parser
.
get
<
int
>
(
"gallery_out"
);
/* Initialize a net work with Device */
cv
::
cnn_3dobj
::
descriptorExtractor
descriptor
(
device
);
...
...
@@ -167,7 +166,7 @@ int main(int argc, char** argv)
{
std
::
cout
<<
std
::
endl
<<
"---------- Features of gallery images ----------"
<<
std
::
endl
;
/* Print features of the reference images. */
for
(
unsigned
int
i
=
0
;
i
<
feature_reference
.
rows
;
i
++
)
for
(
int
i
=
0
;
i
<
feature_reference
.
rows
;
i
++
)
std
::
cout
<<
feature_reference
.
row
(
i
)
<<
endl
;
std
::
cout
<<
std
::
endl
<<
"---------- Saving features of gallery images into feature.bin ----------"
<<
std
::
endl
;
featureWrite
(
feature_reference
,
"feature.bin"
);
...
...
@@ -179,7 +178,7 @@ int main(int argc, char** argv)
std
::
cout
<<
std
::
endl
<<
"---------- Features of gallery images ----------"
<<
std
::
endl
;
std
::
vector
<
std
::
pair
<
String
,
float
>
>
prediction
;
/* Print features of the reference images. */
for
(
unsigned
int
i
=
0
;
i
<
feature_reference
.
rows
;
i
++
)
for
(
int
i
=
0
;
i
<
feature_reference
.
rows
;
i
++
)
std
::
cout
<<
feature_reference
.
row
(
i
)
<<
endl
;
cv
::
Mat
feature_test
;
descriptor
.
extract
(
img
,
feature_test
,
feature_blob
);
...
...
@@ -198,4 +197,4 @@ int main(int argc, char** argv)
}
}
return
0
;
}
\ No newline at end of file
}
modules/cnn_3dobj/samples/demo_sphereview_data.cpp
View file @
49399734
...
...
@@ -50,7 +50,7 @@ using namespace cv::cnn_3dobj;
* @function listDir
* @brief Making all files names under a directory into a list
*/
void
listDir
(
const
char
*
path
,
std
::
vector
<
String
>&
files
,
bool
r
)
static
void
listDir
(
const
char
*
path
,
std
::
vector
<
String
>&
files
,
bool
r
)
{
DIR
*
pDir
;
struct
dirent
*
ent
;
...
...
@@ -144,7 +144,7 @@ int main(int argc, char *argv[])
obj_dist
=
370
;
bg_dist
=
400
;
}
if
(
label_class
==
5
|
label_class
==
10
|
label_class
==
11
|
label_class
==
12
)
if
(
label_class
==
5
|
|
label_class
==
10
||
label_class
==
11
|
|
label_class
==
12
)
ite_depth
=
ite_depth
+
1
;
cv
::
cnn_3dobj
::
icoSphere
ViewSphere
(
10
,
ite_depth
);
std
::
vector
<
cv
::
Point3d
>
campos
;
...
...
@@ -250,7 +250,6 @@ int main(int argc, char *argv[])
cam_y_dir
.
y
=
cam_head_y
;
cam_y_dir
.
z
=
cam_head_z
;
char
*
temp
=
new
char
;
char
*
bgname
=
new
char
;
std
::
vector
<
String
>
name_bkg
;
if
(
bakgrdir
.
size
()
!=
0
)
{
...
...
@@ -262,7 +261,7 @@ int main(int argc, char *argv[])
}
}
/* Images will be saved as .png files. */
in
t
cnt_img
;
size_
t
cnt_img
;
srand
((
int
)
time
(
0
));
do
{
...
...
modules/cnn_3dobj/samples/demo_video.cpp
View file @
49399734
#include <opencv2/viz/vizcore.hpp>
#include <opencv2/calib3d
/calib3d
.hpp>
#include <opencv2/calib3d.hpp>
#include <iostream>
#include <fstream>
#include <opencv2/cnn_3dobj.hpp>
#include <opencv2/features2d
/features2d
.hpp>
#include <opencv2/features2d.hpp>
#include <iomanip>
using
namespace
cv
;
using
namespace
std
;
...
...
@@ -12,7 +12,7 @@ using namespace cv::cnn_3dobj;
* @function listDir
* @brief Making all files names under a directory into a list
*/
void
listDir
(
const
char
*
path
,
std
::
vector
<
String
>&
files
,
bool
r
)
static
void
listDir
(
const
char
*
path
,
std
::
vector
<
String
>&
files
,
bool
r
)
{
DIR
*
pDir
;
struct
dirent
*
ent
;
...
...
@@ -46,12 +46,12 @@ void listDir(const char *path, std::vector<String>& files, bool r)
* @function cvcloud_load
* @brief load bunny.ply
*/
Mat
cvcloud_load
(
Mat
feature_reference
)
static
Mat
cvcloud_load
(
Mat
feature_reference
)
{
Mat
cloud
(
1
,
feature_reference
.
rows
,
CV_32FC3
);
Point3f
*
data
=
cloud
.
ptr
<
cv
::
Point3f
>
();
float
dummy1
,
dummy2
;
for
(
size_
t
i
=
0
;
i
<
feature_reference
.
rows
;
++
i
)
for
(
in
t
i
=
0
;
i
<
feature_reference
.
rows
;
++
i
)
{
data
[
i
].
x
=
feature_reference
.
at
<
float
>
(
i
,
0
);
data
[
i
].
y
=
feature_reference
.
at
<
float
>
(
i
,
1
);
...
...
@@ -102,7 +102,7 @@ int main(int argc, char **argv)
String
feature_blob
=
parser
.
get
<
String
>
(
"feature_blob"
);
int
num_candidate
=
parser
.
get
<
int
>
(
"num_candidate"
);
String
device
=
parser
.
get
<
String
>
(
"device"
);
int
dev_id
=
parser
.
get
<
int
>
(
"dev_id"
);
ifstream
namelist_model
(
caffemodellist
.
c_str
(),
ios
::
in
);
vector
<
String
>
caffemodel
;
char
*
buf
=
new
char
[
512
];
...
...
@@ -198,7 +198,6 @@ int main(int argc, char **argv)
}
vector
<
Mat
>
img_merge
;
/* Part2: Start to have a show */
bool
camera_pov
=
true
;
viz
::
Viz3d
myWindow0
(
"Instruction"
);
viz
::
Viz3d
myWindow1
(
"Point Cloud"
);
viz
::
Viz3d
myWindow2
(
"Prediction sample"
);
...
...
@@ -246,7 +245,7 @@ int main(int argc, char **argv)
myWindowS
.
setWindowSize
(
Size
(
1300
,
700
));
myWindowS
.
setWindowPosition
(
Point
(
0
,
0
));
myWindowS
.
setBackgroundColor
(
viz
::
Color
::
white
());
for
(
in
t
i
=
0
;
i
<
slide
.
size
();
++
i
)
for
(
size_
t
i
=
0
;
i
<
slide
.
size
();
++
i
)
{
/// Create a triangle widget
viz
::
WImageOverlay
slide1
(
slide
[
i
],
Rect
(
0
,
0
,
1300
,
700
));
...
...
@@ -388,4 +387,4 @@ int main(int argc, char **argv)
myWindow2
.
removeAllWidgets
();
}
return
0
;
}
\ No newline at end of file
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment