Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
generators
EMAM2Cpp
Commits
608aec4e
Commit
608aec4e
authored
Feb 15, 2020
by
Ahmed
Browse files
changes on temp-adi-dev
parent
429aebc8
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/monticar/generator/cpp/ArmadilloHelperSource.java
View file @
608aec4e
...
...
@@ -145,5 +145,44 @@ public class ArmadilloHelperSource {
"return A;\n"
+
"}\n"
+
"};\n"
+
"#endif\n"
;
"#endif\n"
+
"// convert an OpenCV matrix to Armadillo matrix. NOTE: a copy is made\n"
+
"template <typename T>\n"
+
"arma::Mat<T> to_arma(const cv::Mat_<T>& src) {\n"
+
" arma::Mat<T> dst(reinterpret_cast<double*>(src.data), src.cols, src.rows);\n"
+
" //src.copyTo({ src.rows, src.cols, dst.memptr() });\n"
+
" return dst;\n"
+
"}\n"
+
"\n"
+
"// convert an Armadillo matrix to OpenCV matrix. NOTE: no copy is made\n"
+
"template<typename T>\n"
+
"cv::Mat_<T> to_cvmat(const arma::Mat<T>& src) {\n"
+
" return cv::Mat_<T>{int(src.n_cols), int(src.n_rows), const_cast<T*>(src.memptr())};\n"
+
"}\n"
+
"\n"
+
"// convert an OpenCV multi-channel matrix to Armadillo cube. A copy is made\n"
+
"template <typename T, int NC>\n"
+
"Cube<T> to_armaCube(const cv::Mat_<cv::Vec<T, NC>>& src)\n"
+
"{\n"
+
" std::vector<cv::Mat_<T>> channels;\n"
+
" Cube<T> dst(src.cols, src.rows, NC);\n"
+
" for (int c = 0; c < NC; ++c)\n"
+
" channels.push_back({ src.rows, src.cols, dst.slice(c).memptr() });\n"
+
" cv::split(src, channels);\n"
+
" return dst;\n"
+
"}\n"
+
"\n"
+
"// convert an Armadillo cube to OpenCV matrix. NOTE: a copy is made\n"
+
"template <typename T>\n"
+
"cv::Mat to_cvmat(Cube<T>& src) {\n"
+
" std::vector<cv::Mat_<T>> channels;\n"
+
" for (size_t c = 0; c < src.n_slices; ++c) {\n"
+
" auto* data = const_cast<T*>(src.slice(c).memptr());\n"
+
" channels.push_back({ int(src.n_cols), int(src.n_rows), data });\n"
+
" }\n"
+
" cv::Mat dst;\n"
+
" cv::merge(channels, dst);\n"
+
" return dst;\n"
+
"}\n"
;
}
src/test/resources/results/armadillo/testMath/l0/test_math_erodeAndGaussianBlurCommandTest.h
View file @
608aec4e
...
...
@@ -67,3 +67,4 @@ findContours(dst3, contours, method, mode);
};
#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