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
da989664
Commit
da989664
authored
Sep 14, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
parents
ac0b1d0d
9457fe6c
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
160 additions
and
115 deletions
+160
-115
test_cnn_3dobj_feature_extract.cpp
modules/cnn_3dobj/test/test_cnn_3dobj_feature_extract.cpp
+1
-1
pd_inria.cpp
modules/datasets/samples/pd_inria.cpp
+38
-65
CMakeLists.txt
modules/matlab/CMakeLists.txt
+7
-2
compile.cmake
modules/matlab/compile.cmake
+8
-1
filters.py
modules/matlab/generator/filters.py
+1
-3
gen_matlab.py
modules/matlab/generator/gen_matlab.py
+24
-8
parse_tree.py
modules/matlab/generator/parse_tree.py
+27
-6
functional.cpp
modules/matlab/generator/templates/functional.cpp
+5
-3
template_class_base.cpp
modules/matlab/generator/templates/template_class_base.cpp
+1
-2
template_function_base.cpp
...les/matlab/generator/templates/template_function_base.cpp
+1
-2
bridge.hpp
modules/matlab/include/opencv2/matlab/bridge.hpp
+33
-17
odometry.cpp
modules/rgbd/src/odometry.cpp
+13
-4
hash_murmur86.hpp
modules/surface_matching/src/hash_murmur86.hpp
+1
-1
No files found.
modules/cnn_3dobj/test/test_cnn_3dobj_feature_extract.cpp
View file @
da989664
...
...
@@ -53,7 +53,7 @@ void CV_CNN_Feature_Test::run(int)
// Reference feature is computed by Caffe extract_features tool.
// To generate values for different images, use extract_features with the resetted image list in prototxt.
Mat
feature_reference
=
(
Mat_
<
float
>
(
1
,
3
)
<<
-
312.4805
,
8.4768486
,
-
224.98953
);
float
dist
=
norm
(
feature_test
-
feature_reference
);
float
dist
=
cvtest
::
norm
(
feature_test
,
feature_reference
,
NORM_L1
);
if
(
dist
>
5
)
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Extracted featrue is not the same from the one extracted from Caffe."
);
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_MISSING_TEST_DATA
);
...
...
modules/datasets/samples/pd_inria.cpp
View file @
da989664
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2015, Itseez Inc, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Itseez Inc or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "opencv2/datasets/pd_inria.hpp"
#include <opencv2/
core
.hpp>
#include <opencv2/
highgui
.hpp>
#include <opencv2/imgproc.hpp>
#include <iostream>
#include <string>
#include <vector>
using
namespace
std
;
using
namespace
cv
;
...
...
@@ -55,6 +12,7 @@ int main(int argc, char *argv[])
const
char
*
keys
=
"{ help h usage ? | | show this message }"
"{ path p |true| path to dataset }"
;
CommandLineParser
parser
(
argc
,
argv
,
keys
);
string
path
(
parser
.
get
<
string
>
(
"path"
));
if
(
parser
.
has
(
"help"
)
||
path
==
"true"
)
...
...
@@ -66,28 +24,43 @@ int main(int argc, char *argv[])
Ptr
<
PD_inria
>
dataset
=
PD_inria
::
create
();
dataset
->
load
(
path
);
cout
<<
"train size: "
<<
(
unsigned
int
)
dataset
->
getTrain
().
size
()
<<
endl
;
size_t
train_size
=
dataset
->
getTrain
().
size
();
size_t
test_size
=
dataset
->
getTest
().
size
();
cout
<<
"train size: "
<<
train_size
<<
endl
;
cout
<<
"test size: "
<<
test_size
<<
endl
;
PD_inriaObj
*
example
=
static_cast
<
PD_inriaObj
*>
(
dataset
->
getTrain
()[
0
].
get
());
cout
<<
"first train object: "
<<
endl
;
cout
<<
"name: "
<<
example
->
filename
<<
endl
;
// image size
cout
<<
"image size: "
<<
endl
;
cout
<<
" - width: "
<<
example
->
width
<<
endl
;
cout
<<
" - height: "
<<
example
->
height
<<
endl
;
cout
<<
" - depth: "
<<
example
->
depth
<<
endl
;
// bounding boxes
for
(
unsigned
int
i
=
0
;
i
<
(
example
->
bndboxes
).
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
train_size
;
i
++
)
{
cout
<<
"object "
<<
i
<<
endl
;
int
x
=
(
example
->
bndboxes
)[
i
].
x
;
int
y
=
(
example
->
bndboxes
)[
i
].
y
;
cout
<<
" - xmin = "
<<
x
<<
endl
;
cout
<<
" - ymin = "
<<
y
<<
endl
;
cout
<<
" - xmax = "
<<
(
example
->
bndboxes
)[
i
].
width
+
x
<<
endl
;
cout
<<
" - ymax = "
<<
(
example
->
bndboxes
)[
i
].
height
+
y
<<
endl
;
PD_inriaObj
*
example
=
static_cast
<
PD_inriaObj
*>
(
dataset
->
getTrain
()[
i
].
get
());
cout
<<
"
\n
train object index: "
<<
i
<<
endl
;
cout
<<
"file name: "
<<
example
->
filename
<<
endl
;
// image size
cout
<<
"image size: "
<<
endl
;
cout
<<
" - width: "
<<
example
->
width
<<
endl
;
cout
<<
" - height: "
<<
example
->
height
<<
endl
;
cout
<<
" - depth: "
<<
example
->
depth
<<
endl
;
Mat
img
=
imread
(
example
->
filename
);
// bounding boxes
for
(
size_t
j
=
0
;
j
<
example
->
bndboxes
.
size
();
j
++
)
{
cout
<<
"object "
<<
j
<<
endl
;
int
x
=
example
->
bndboxes
[
j
].
x
;
int
y
=
example
->
bndboxes
[
j
].
y
;
cout
<<
" - xmin = "
<<
x
<<
endl
;
cout
<<
" - ymin = "
<<
y
<<
endl
;
cout
<<
" - xmax = "
<<
example
->
bndboxes
[
j
].
width
+
x
<<
endl
;
cout
<<
" - ymax = "
<<
example
->
bndboxes
[
j
].
height
+
y
<<
endl
;
rectangle
(
img
,
example
->
bndboxes
[
j
],
Scalar
(
0
,
0
,
255
),
2
);
}
imshow
(
"INRIAPerson Dataset Train Images"
,
img
);
cout
<<
"
\n
Press a key to continue or ESC to exit."
<<
endl
;
int
key
=
waitKey
();
if
(
key
==
27
)
break
;
}
return
0
;
...
...
modules/matlab/CMakeLists.txt
View file @
da989664
set
(
BUILD_opencv_matlab_INIT OFF
)
# Matlab module is broken
# ----------------------------------------------------------------------------
# CMake file for Matlab/Octave support
#
...
...
@@ -261,6 +259,13 @@ add_custom_command(
COMMAND
${
CMAKE_COMMAND
}
-E copy
${
CMAKE_CURRENT_SOURCE_DIR
}
/test/help.m
${
CMAKE_CURRENT_BINARY_DIR
}
/+cv
COMMAND
${
CMAKE_COMMAND
}
-E touch
${
GENERATE_PROXY
}
COMMENT
"Generating Matlab source files"
DEPENDS
"
${
CMAKE_CURRENT_LIST_DIR
}
/generator/build_info.py"
DEPENDS
"
${
CMAKE_CURRENT_LIST_DIR
}
/generator/cvmex.py"
DEPENDS
"
${
CMAKE_CURRENT_LIST_DIR
}
/generator/filters.py"
DEPENDS
"
${
CMAKE_CURRENT_LIST_DIR
}
/generator/gen_matlab.py"
DEPENDS
"
${
CMAKE_CURRENT_LIST_DIR
}
/generator/parse_tree.py"
DEPENDS
"
${
CMAKE_CURRENT_LIST_DIR
}
/generator/templates/functional.cpp"
DEPENDS
"
${
CMAKE_CURRENT_LIST_DIR
}
/generator/templates/template_function_base.cpp"
)
# compile
...
...
modules/matlab/compile.cmake
View file @
da989664
...
...
@@ -28,11 +28,18 @@ endif()
# 2. attempt compile if required
# 3. if the compile fails, throw an error and cancel compilation
file
(
GLOB SOURCE_FILES
"
${
CMAKE_CURRENT_BINARY_DIR
}
/src/*.cpp"
)
list
(
LENGTH SOURCE_FILES __size
)
message
(
"Matlab: compiling
${
__size
}
files"
)
set
(
__index 0
)
foreach
(
SOURCE_FILE
${
SOURCE_FILES
}
)
MATH
(
EXPR __index
"
${
__index
}
+1"
)
# strip out the filename
get_filename_component
(
FILENAME
${
SOURCE_FILE
}
NAME_WE
)
message
(
"[
${
__index
}
/
${
__size
}
] Compiling:
${
FILENAME
}
"
)
# compile the source file using mex
if
(
NOT EXISTS
${
CMAKE_CURRENT_BINARY_DIR
}
/+cv/
${
FILENAME
}
.
${
MATLAB_MEXEXT
}
)
if
(
NOT EXISTS
"
${
CMAKE_CURRENT_BINARY_DIR
}
/+cv/
${
FILENAME
}
.
${
MATLAB_MEXEXT
}
"
OR
"
${
SOURCE_FILE
}
"
IS_NEWER_THAN
"
${
CMAKE_CURRENT_BINARY_DIR
}
/+cv/
${
FILENAME
}
.
${
MATLAB_MEXEXT
}
"
)
execute_process
(
COMMAND
${
MATLAB_MEX_SCRIPT
}
${
MEX_OPTS
}
"CXXFLAGS=
\$
CXXFLAGS
${
MEX_CXXFLAGS
}
"
${
MEX_INCLUDE_DIRS_LIST
}
${
MEX_LIB_DIR
}
${
MEX_LIBS_LIST
}
${
SOURCE_FILE
}
...
...
modules/matlab/generator/filters.py
View file @
da989664
...
...
@@ -5,8 +5,6 @@ urlexpr = re.compile(r"((https?):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)", r
def
inputs
(
args
):
'''Keeps only the input arguments in a list of elements.
In OpenCV input arguments are all arguments with names
not beginning with 'dst'
'''
try
:
return
[
arg
for
arg
in
args
[
'only'
]
if
arg
.
I
and
not
arg
.
O
]
...
...
@@ -20,7 +18,7 @@ def ninputs(fun):
def
outputs
(
args
):
'''Determines whether any of the given arguments is an output
reference, and returns a list of only those elements.
In OpenCV, output references are preceeded by
'dst'
In OpenCV, output references are preceeded by
CV_OUT or has *OutputArray* type
'''
try
:
return
[
arg
for
arg
in
args
[
'only'
]
if
arg
.
O
and
not
arg
.
I
]
...
...
modules/matlab/generator/gen_matlab.py
View file @
da989664
...
...
@@ -4,6 +4,26 @@ from string import Template
from
parse_tree
import
ParseTree
,
todict
,
constants
from
filters
import
*
updated_files
=
[]
def
update_file
(
fname
,
content
):
if
fname
in
updated_files
:
print
(
'ERROR(gen_matlab.py): attemption to write file multiple times: {}'
.
format
(
fname
))
return
updated_files
.
append
(
fname
)
if
os
.
path
.
exists
(
fname
):
with
open
(
fname
,
'rb'
)
as
f
:
old_content
=
f
.
read
()
if
old_content
==
content
:
#print('Up-to-date: {}'.format(fname))
return
print
(
'Updating: {}'
.
format
(
fname
))
else
:
print
(
'Writing: {}'
.
format
(
fname
))
with
open
(
fname
,
'wb'
)
as
f
:
f
.
write
(
content
)
class
MatlabWrapperGenerator
(
object
):
"""
MatlabWrapperGenerator is a class for generating Matlab mex sources from
...
...
@@ -107,24 +127,20 @@ class MatlabWrapperGenerator(object):
# functions
for
method
in
namespace
.
methods
:
populated
=
tfunction
.
render
(
fun
=
method
,
time
=
time
,
includes
=
namespace
.
name
)
with
open
(
output_source_dir
+
'/'
+
method
.
name
+
'.cpp'
,
'wb'
)
as
f
:
f
.
write
(
populated
.
encode
(
'utf-8'
))
update_file
(
output_source_dir
+
'/'
+
method
.
name
+
'.cpp'
,
populated
.
encode
(
'utf-8'
))
# classes
for
clss
in
namespace
.
classes
:
# cpp converter
populated
=
tclassc
.
render
(
clss
=
clss
,
time
=
time
)
with
open
(
output_private_dir
+
'/'
+
clss
.
name
+
'Bridge.cpp'
,
'wb'
)
as
f
:
f
.
write
(
populated
.
encode
(
'utf-8'
))
update_file
(
output_private_dir
+
'/'
+
clss
.
name
+
'Bridge.cpp'
,
populated
.
encode
(
'utf-8'
))
# matlab classdef
populated
=
tclassm
.
render
(
clss
=
clss
,
time
=
time
)
with
open
(
output_class_dir
+
'/'
+
clss
.
name
+
'.m'
,
'wb'
)
as
f
:
f
.
write
(
populated
.
encode
(
'utf-8'
))
update_file
(
output_class_dir
+
'/'
+
clss
.
name
+
'.m'
,
populated
.
encode
(
'utf-8'
))
# create a global constants lookup table
const
=
dict
(
constants
(
todict
(
parse_tree
.
namespaces
)))
populated
=
tconst
.
render
(
constants
=
const
,
time
=
time
)
with
open
(
output_dir
+
'/cv.m'
,
'wb'
)
as
f
:
f
.
write
(
populated
.
encode
(
'utf-8'
))
update_file
(
output_dir
+
'/cv.m'
,
populated
.
encode
(
'utf-8'
))
if
__name__
==
"__main__"
:
...
...
modules/matlab/generator/parse_tree.py
View file @
da989664
...
...
@@ -8,6 +8,21 @@ except NameError:
# Python 3.3+
basestring
=
str
valid_types
=
(
'int'
,
'bool'
,
'float'
,
'double'
,
'size_t'
,
'char'
,
'Mat'
,
'Scalar'
,
'String'
,
'TermCriteria'
,
'Size'
,
'Point'
,
'Point2f'
,
'Point2d'
,
'Rect'
,
'RotatedRect'
,
'RNG'
,
'DMatch'
,
'Moments'
,
'vector_Mat'
,
'vector_Point'
,
'vector_int'
,
'vector_float'
,
'vector_double'
,
'vector_String'
,
'vector_uchar'
,
'vector_Rect'
,
'vector_DMatch'
,
'vector_KeyPoint'
,
'vector_Point2f'
,
'vector_vector_char'
,
'vector_vector_DMatch'
,
'vector_vector_KeyPoint'
,
'Ptr_StereoBM'
,
'Ptr_StereoSGBM'
,
'Ptr_FeatureDetector'
,
'Ptr_CLAHE'
,
'Ptr_LineSegmentDetector'
,
'Ptr_AlignMTB'
,
'Ptr_CalibrateDebevec'
,
'Ptr_CalibrateRobertson'
,
'Ptr_DenseOpticalFlow'
,
'Ptr_DualTVL1OpticalFlow'
,
'Ptr_MergeDebevec'
,
'Ptr_MergeMertens'
,
'Ptr_MergeRobertson'
,
'Ptr_Stitcher'
,
'Ptr_Tonemap'
,
'Ptr_TonemapDrago'
,
'Ptr_TonemapDurand'
,
'Ptr_TonemapMantiuk'
,
'Ptr_TonemapReinhard'
,
'Ptr_float'
,
# Not supported:
#vector_vector_KeyPoint
)
class
ParseTree
(
object
):
"""
The ParseTree class produces a semantic tree of C++ definitions given
...
...
@@ -89,7 +104,11 @@ class ParseTree(object):
methods
=
[]
constants
=
[]
for
defn
in
definitions
:
obj
=
babel
.
translate
(
defn
)
try
:
obj
=
babel
.
translate
(
defn
)
except
Exception
as
e
:
print
(
e
)
obj
=
None
if
obj
is
None
:
continue
if
type
(
obj
)
is
Class
or
obj
.
clss
:
...
...
@@ -176,15 +195,15 @@ class Translator(object):
return
Constant
(
name
,
clss
,
tp
,
const
,
''
,
val
)
def
translateArgument
(
self
,
defn
):
modifiers
=
defn
[
3
]
ref
=
'*'
if
'*'
in
defn
[
0
]
else
''
ref
=
'&'
if
'&'
in
defn
[
0
]
else
ref
const
=
'
const '
in
' '
+
defn
[
0
]
+
' '
ref
=
'&'
if
'&'
in
defn
[
0
]
or
'/Ref'
in
modifiers
else
ref
const
=
'
/C'
in
modifiers
tp
=
" "
.
join
([
word
for
word
in
defn
[
0
]
.
replace
(
ref
,
''
)
.
split
()
if
not
' const '
in
' '
+
word
+
' '
])
name
=
defn
[
1
]
default
=
defn
[
2
]
if
defn
[
2
]
else
''
modifiers
=
''
.
join
(
defn
[
3
])
I
=
True
if
not
modifiers
or
'I'
in
modifiers
else
False
O
=
True
if
'O'
in
modifiers
else
False
I
=
True
if
'/I'
in
modifiers
or
not
'/O'
in
modifiers
else
False
O
=
True
if
'/O'
in
modifiers
else
False
return
Argument
(
name
,
tp
,
const
,
I
,
O
,
ref
,
default
)
def
translateName
(
self
,
name
):
...
...
@@ -292,6 +311,8 @@ class Argument(object):
self
.
O
=
O
self
.
const
=
const
self
.
default
=
default
if
not
tp
in
valid_types
:
raise
Exception
(
"Non-supported argument type: {} (name: {})"
.
format
(
tp
,
name
))
def
__str__
(
self
):
return
(
'const '
if
self
.
const
else
''
)
+
self
.
tp
+
self
.
ref
+
\
...
...
modules/matlab/generator/templates/functional.cpp
View file @
da989664
...
...
@@ -104,21 +104,23 @@ addVariant("{{ fun.name }}", {{ fun.req|inputs|length }}, {{ fun.opt|inputs|leng
{
%-
macro
handleInputs
(
fun
)
%
}
{
%
if
fun
|
ninputs
or
(
fun
|
noutputs
and
not
fun
.
constructor
)
%
}
// unpack the arguments
{
#
-----------
Inputs
-------------
#
}
// - inputs
{
%
for
arg
in
fun
.
req
|
inputs
%
}
{{
arg
.
tp
}}
{{
arg
.
name
}}
=
inputs
[{{
loop
.
index0
}}].
to
{{
arg
.
tp
|
toUpperCamelCase
}}();
{
%
endfor
%
}
// - inputs (opt)
{
%
for
opt
in
fun
.
opt
|
inputs
%
}
{{
opt
.
tp
}}
{{
opt
.
name
}}
=
inputs
[{{
loop
.
index0
+
fun
.
req
|
inputs
|
length
}}].
empty
()
?
({{
opt
.
tp
}})
{
%
if
opt
.
ref
==
'*'
-%
}
{{
opt
.
tp
}}()
{
%-
else
-%
}
{{
opt
.
default
}}
{
%-
endif
%
}
:
inputs
[{{
loop
.
index0
+
fun
.
req
|
inputs
|
length
}}].
to
{{
opt
.
tp
|
toUpperCamelCase
}}();
{
%
endfor
%
}
{
#
-----------
Outputs
------------
#
}
// - outputs
{
%
for
arg
in
fun
.
req
|
only
|
outputs
%
}
{{
arg
.
tp
}}
{{
arg
.
name
}};
{
%
endfor
%
}
// - outputs (opt)
{
%
for
opt
in
fun
.
opt
|
only
|
outputs
%
}
{{
opt
.
tp
}}
{{
opt
.
name
}};
{
%
endfor
%
}
// - return
{
%
if
not
fun
.
rtp
|
void
and
not
fun
.
constructor
%
}
{{
fun
.
rtp
}}
retval
;
{
%
endif
%
}
...
...
modules/matlab/generator/templates/template_class_base.cpp
View file @
da989664
...
...
@@ -2,11 +2,10 @@
/*
* file: {{clss.name}}Bridge.cpp
* author: A trusty code generator
* date: {{time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())}}
*
* This file was autogenerated, do not modify.
* See LICENSE for full modification and redistribution details.
* Copyright
{{time.strftime("%Y", time.localtime())}}
The OpenCV Foundation
* Copyright
2018
The OpenCV Foundation
*/
#include <mex.h>
#include <vector>
...
...
modules/matlab/generator/templates/template_function_base.cpp
View file @
da989664
...
...
@@ -2,11 +2,10 @@
/*
* file: {{fun.name}}.cpp
* author: A trusty code generator
* date: {{time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())}}
*
* This file was autogenerated, do not modify.
* See LICENSE for full modification and redistribution details.
* Copyright
{{time.strftime("%Y", time.localtime())}}
The OpenCV Foundation
* Copyright
2018
The OpenCV Foundation
*/
#include <string>
#include <vector>
...
...
modules/matlab/include/opencv2/matlab/bridge.hpp
View file @
da989664
...
...
@@ -249,13 +249,13 @@ public:
case
mxUINT16_CLASS
:
deepCopyAndTranspose
<
uint16_t
,
Scalar
>
(
ptr_
,
mat
);
break
;
case
mxINT32_CLASS
:
deepCopyAndTranspose
<
int32_t
,
Scalar
>
(
ptr_
,
mat
);
break
;
case
mxUINT32_CLASS
:
deepCopyAndTranspose
<
uint32_t
,
Scalar
>
(
ptr_
,
mat
);
break
;
case
mxINT64_CLASS
:
deepCopyAndTranspose
<
int64_t
,
Scalar
>
(
ptr_
,
mat
);
break
;
case
mxUINT64_CLASS
:
deepCopyAndTranspose
<
uint64_t
,
Scalar
>
(
ptr_
,
mat
);
break
;
//
case mxINT64_CLASS: deepCopyAndTranspose<int64_t, Scalar>(ptr_, mat); break;
//
case mxUINT64_CLASS: deepCopyAndTranspose<uint64_t, Scalar>(ptr_, mat); break;
case
mxSINGLE_CLASS
:
deepCopyAndTranspose
<
float
,
Scalar
>
(
ptr_
,
mat
);
break
;
case
mxDOUBLE_CLASS
:
deepCopyAndTranspose
<
double
,
Scalar
>
(
ptr_
,
mat
);
break
;
case
mxCHAR_CLASS
:
deepCopyAndTranspose
<
char
,
Scalar
>
(
ptr_
,
mat
);
break
;
case
mxLOGICAL_CLASS
:
deepCopyAndTranspose
<
int8_t
,
Scalar
>
(
ptr_
,
mat
);
break
;
default
:
matlab
::
error
(
"Attempted to convert from unknown class"
);
default
:
matlab
::
error
(
"Attempted to convert from unknown
/unsupported
class"
);
}
return
mat
;
}
...
...
@@ -576,13 +576,13 @@ cv::Mat Bridge::toMat<matlab::InheritType>() const {
case
mxUINT16_CLASS
:
return
toMat
<
uint16_t
>
();
case
mxINT32_CLASS
:
return
toMat
<
int32_t
>
();
case
mxUINT32_CLASS
:
return
toMat
<
int32_t
>
();
case
mxINT64_CLASS
:
return
toMat
<
int64_t
>
();
case
mxUINT64_CLASS
:
return
toMat
<
int64_t
>
();
//
case mxINT64_CLASS: return toMat<int64_t>();
//
case mxUINT64_CLASS: return toMat<int64_t>();
case
mxSINGLE_CLASS
:
return
toMat
<
float
>
();
case
mxDOUBLE_CLASS
:
return
toMat
<
float
>
();
//NOTE: OpenCV uses float as native type!
case
mxCHAR_CLASS
:
return
toMat
<
int8_t
>
();
case
mxLOGICAL_CLASS
:
return
toMat
<
int8_t
>
();
default
:
matlab
::
error
(
"Attempted to convert from unknown class"
);
default
:
matlab
::
error
(
"Attempted to convert from unknown
/unsuported
class"
);
}
return
cv
::
Mat
();
}
...
...
@@ -598,18 +598,26 @@ cv::Mat Bridge::toMat() const { return toMat<matlab::InheritType>(); }
template
<
typename
InputScalar
,
typename
OutputScalar
>
void
deepCopyAndTranspose
(
const
cv
::
Mat
&
in
,
matlab
::
MxArray
&
out
)
{
const
int
cols
=
out
.
cols
();
const
int
rows
=
out
.
rows
();
matlab
::
conditionalError
(
static_cast
<
size_t
>
(
in
.
rows
)
==
out
.
rows
(),
"Matrices must have the same number of rows"
);
matlab
::
conditionalError
(
static_cast
<
size_t
>
(
in
.
cols
)
==
out
.
cols
(),
"Matrices must have the same number of cols"
);
matlab
::
conditionalError
(
static_cast
<
size_t
>
(
in
.
channels
())
==
out
.
channels
(),
"Matrices must have the same number of channels"
);
std
::
vector
<
cv
::
Mat
>
channels
;
cv
::
split
(
in
,
channels
);
for
(
size_t
c
=
0
;
c
<
out
.
channels
();
++
c
)
{
cv
::
transpose
(
channels
[
c
],
channels
[
c
]);
cv
::
Mat
outmat
(
out
.
cols
(),
out
.
rows
(),
cv
::
DataType
<
OutputScalar
>::
type
,
static_cast
<
void
*>
(
out
.
real
<
OutputScalar
>
()
+
out
.
cols
()
*
out
.
rows
()
*
c
));
channels
[
c
].
convertTo
(
outmat
,
cv
::
DataType
<
OutputScalar
>::
type
);
cv
::
Mat_
<
InputScalar
>
m
;
cv
::
transpose
(
channels
[
c
],
m
);
OutputScalar
*
dst_plane
=
(
OutputScalar
*
)
out
.
real
<
InputScalar
>
()
+
cols
*
rows
*
c
;
for
(
int
x
=
0
;
x
<
cols
;
x
++
)
{
OutputScalar
*
dst_col
=
dst_plane
+
x
*
rows
;
for
(
int
y
=
0
;
y
<
rows
;
y
++
)
{
dst_col
[
y
]
=
cv
::
saturate_cast
<
OutputScalar
>
(
m
(
y
,
x
));
}
}
}
//const InputScalar* inp = in.ptr<InputScalar>(0);
//OutputScalar* outp = out.real<OutputScalar>();
//gemt('R', out.rows(), out.cols(), inp, in.step1(), outp, out.rows());
...
...
@@ -617,17 +625,25 @@ void deepCopyAndTranspose(const cv::Mat& in, matlab::MxArray& out) {
template
<
typename
InputScalar
,
typename
OutputScalar
>
void
deepCopyAndTranspose
(
const
matlab
::
MxArray
&
in
,
cv
::
Mat
&
out
)
{
const
int
cols
=
in
.
cols
();
const
int
rows
=
in
.
rows
();
matlab
::
conditionalError
(
in
.
rows
()
==
static_cast
<
size_t
>
(
out
.
rows
),
"Matrices must have the same number of rows"
);
matlab
::
conditionalError
(
in
.
cols
()
==
static_cast
<
size_t
>
(
out
.
cols
),
"Matrices must have the same number of cols"
);
matlab
::
conditionalError
(
in
.
channels
()
==
static_cast
<
size_t
>
(
out
.
channels
()),
"Matrices must have the same number of channels"
);
std
::
vector
<
cv
::
Mat
>
channels
;
for
(
size_t
c
=
0
;
c
<
in
.
channels
();
++
c
)
{
cv
::
Mat
outmat
;
cv
::
Mat
inmat
(
in
.
cols
(),
in
.
rows
(),
cv
::
DataType
<
InputScalar
>::
type
,
static_cast
<
void
*>
(
const_cast
<
InputScalar
*>
(
in
.
real
<
InputScalar
>
()
+
in
.
cols
()
*
in
.
rows
()
*
c
)));
inmat
.
convertTo
(
outmat
,
cv
::
DataType
<
OutputScalar
>::
type
);
cv
::
transpose
(
outmat
,
outmat
);
channels
.
push_back
(
outmat
);
cv
::
Mat_
<
OutputScalar
>
m
(
cols
,
rows
);
const
InputScalar
*
src_plane
=
in
.
real
<
InputScalar
>
()
+
cols
*
rows
*
c
;
for
(
int
x
=
0
;
x
<
cols
;
x
++
)
{
const
InputScalar
*
src_col
=
src_plane
+
x
*
rows
;
for
(
int
y
=
0
;
y
<
rows
;
y
++
)
{
m
(
y
,
x
)
=
cv
::
saturate_cast
<
InputScalar
>
(
src_col
[
y
]);
}
}
cv
::
transpose
(
m
,
m
);
channels
.
push_back
(
m
);
}
cv
::
merge
(
channels
,
out
);
...
...
modules/rgbd/src/odometry.cpp
View file @
da989664
...
...
@@ -10,10 +10,19 @@
#include "fast_icp.hpp"
#if defined(HAVE_EIGEN) && EIGEN_WORLD_VERSION == 3
#define HAVE_EIGEN3_HERE
#include <Eigen/Core>
#include <unsupported/Eigen/MatrixFunctions>
#include <Eigen/Dense>
# define HAVE_EIGEN3_HERE
# if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable:4701) // potentially uninitialized local variable
# pragma warning(disable:4702) // unreachable code
# pragma warning(disable:4714) // const marked as __forceinline not inlined
# endif
# include <Eigen/Core>
# include <unsupported/Eigen/MatrixFunctions>
# include <Eigen/Dense>
# if defined(_MSC_VER)
# pragma warning(pop)
# endif
#endif
namespace
cv
...
...
modules/surface_matching/src/hash_murmur86.hpp
View file @
da989664
...
...
@@ -93,7 +93,7 @@ void hashMurmurx86 ( const void * key, const int len, const uint seed, void * ou
/* Now find best way we can to READ_UINT32 */
#ifndef WORDS_BIGENDIAN
# define READ_UINT32(ptr) (*((uint32_t*)(ptr)))
#elif defined(WORDS_BIGENDIAN)
#elif defined(WORDS_BIGENDIAN)
\
&& defined(__GNUC__) && (__GNUC__>4 || (__GNUC__==4 && __GNUC_MINOR__>=3))
# define READ_UINT32(ptr) (__builtin_bswap32(*((uint32_t*)(ptr))))
#endif
...
...
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