Commit 429aebc8 authored by Ahmed's avatar Ahmed

some changes

parent 24c85af3
......@@ -72,6 +72,11 @@ public class BluePrint {
Collections.replaceAll(variables,varOld, varNew);
}
public void addMethod(Method method) {
for(Method meth: methods){
if(meth.getName().equals(method.getName())){
return;
}
}
methods.add(method);
}
......
......@@ -51,7 +51,7 @@ public class BluePrintCPP extends BluePrint {
}
public boolean hasCVIncludeString(String includeString) {
return additionalIncludeStrings.contains(includeString);
return cvIncludeStrings.contains(includeString);
}
......
// convert an OpenCV matrix to Armadillo matrix. NOTE: a copy is made
template <typename T>
arma::Mat<T> to_arma(const cv::Mat_<T>& src) {
arma::Mat<T> dst(reinterpret_cast<double*>(src.data), src.cols, src.rows);
//src.copyTo({ src.rows, src.cols, dst.memptr() });
return dst;
}
// convert an Armadillo matrix to OpenCV matrix. NOTE: no copy is made
template<typename T>
cv::Mat_<T> to_cvmat(const arma::Mat<T>& src) {
return cv::Mat_<T>{int(src.n_cols), int(src.n_rows), const_cast<T*>(src.memptr())};
}
// convert an OpenCV multi-channel matrix to Armadillo cube. A copy is made
template <typename T, int NC>
Cube<T> to_armaCube(const cv::Mat_<cv::Vec<T, NC>>& src)
{
std::vector<cv::Mat_<T>> channels;
Cube<T> dst(src.cols, src.rows, NC);
for (int c = 0; c < NC; ++c)
channels.push_back({ src.rows, src.cols, dst.slice(c).memptr() });
cv::split(src, channels);
return dst;
}
// convert an Armadillo cube to OpenCV matrix. NOTE: a copy is made
template <typename T>
cv::Mat to_cvmat(Cube<T>& src) {
std::vector<cv::Mat_<T>> channels;
for (size_t c = 0; c < src.n_slices; ++c) {
auto* data = const_cast<T*>(src.slice(c).memptr());
channels.push_back({ int(src.n_cols), int(src.n_rows), data });
}
cv::Mat dst;
cv::merge(channels, dst);
return dst;
}
\ No newline at end of file
......@@ -4,9 +4,9 @@
#define M_PI 3.14159265358979323846
#endif
#include "armadillo"
#include "ConvHelper.h"
#include "opencv2/imgproc.hpp"
#include <vector>
#include "opencv2/imgproc.hpp"
using namespace arma;
using namespace cv;
class test_math_erodeAndGaussianBlurCommandTest{
......@@ -15,13 +15,15 @@ cube src;
int erosion_elemIn;
colvec sizeY;
colvec two;
cube dst;
cube outMatrix;
mat out2Matrix;
void init()
{
src = cube(3, n, m);
src = cube(n, m, 3);
sizeY=colvec(3);
two=colvec(2);
dst = cube(n, m, 3);
outMatrix = cube(3, n, m);
out2Matrix=mat(2,m);
}
......@@ -37,10 +39,30 @@ void erodeHelper(cube src, cube dst, int erosion_elem, int iterations)
Point( -1, -1 ) );
erode( src, dst, element, Point(-1,-1), iterations );
}
void dilateHelper(cube src, cube dst, int dilation_elem, int iterations)
{
int dilation_type = 0;
if( dilation_elem == 0 ){ dilation_type = MORPH_RECT; }
else if( dilation_elem == 1 ){ dilation_type = MORPH_CROSS; }
else if( dilation_elem == 2) { dilation_type = MORPH_ELLIPSE; }
dilation_size = dilation_elem;
mat element = getStructuringElement( dilation_type,
Size( 2*dilation_size + 1, 2*dilation_size+1 ),
Point( -1, -1 ) );
dilate( src, dst, element, Point(-1,-1), iterations );
}
void execute()
{
findContours(image, contours, mode, method);
erodeHelper(src, dst, erosion_elem, iterations);
cube dst2=cube(270,340,3);
erodeHelper(src, dst, erosion_elem, iterations);
erodeHelper(src, dst, erosion_elem, iterations);
dilateHelper(dst, dst3, dilation_elem, iterations);
cube src4 = (det(src));
erodeHelper(src4, dst, erosion_elem, iterations);
erodeHelper(src, dst, erosion_elem, iterations);
dilateHelper(dst, dst3, dilation_elem, iterations);
findContours(dst3, contours, method, mode);
}
};
......
#ifndef TEST_MATH_ERODECOMMANDTEST
#define TEST_MATH_ERODECOMMANDTEST
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#include "armadillo"
#include "ConvHelper.h"
#include "opencv2/imgproc.hpp"
using namespace arma;
using namespace cv;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment