Commit e58e0a20 authored by Ahmed's avatar Ahmed

some fixes

parent 344c734b
......@@ -10,18 +10,26 @@ using namespace arma;
using namespace std;
class test_math_cvtColorCommandTest{
public:
mat src;
arma::mat src;
int colorConversion;
mat dst;
arma::mat dst;
void init()
{
src=mat(n,m);
dst=mat(n,m);
}
void cvtColorHelper(arma::mat src, arma::mat dst, int colorConversion)
{
cv::Mat srcCV;
cv::Mat dstCV;
srcCV = ConvHelper::to_cvmat(src);
cv::cvtColor(srcCV, dstCV, colorConversion);
dst = ConvHelper::to_arma(dstCV);
}
void execute()
{
cv::cvtColor(src, dst, colorConversion);
cvtColorHelper(src, dst, colorConversion);
}
};
#endif
\ No newline at end of file
#endif
......@@ -10,26 +10,30 @@ using namespace arma;
using namespace std;
class test_math_dilateCommandTest{
public:
mat src;
arma::mat src;
int dilation_elem;
int iterations;
mat dst;
arma::mat dst;
void init()
{
src=mat(n,m);
dst=mat(n,m);
}
void dilateHelper(mat src, mat dst, int dilation_elem, int iterations)
void dilateHelper(arma::mat src, arma::mat 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 = cv::getStructuringElement( dilation_type,
cv::mat element = cv::getStructuringElement( dilation_type,
Size( 2*dilation_size + 1, 2*dilation_size+1 ),
Point( -1, -1 ) );
cv::dilate( src, dst, element, Point(-1,-1), iterations );
cv::Mat srcCV;
cv::Mat dstCV;
srcCV = ConvHelper::to_cvmat(src);
cv::dilate( srcCV, dstCV, element, Point(-1,-1), iterations );
dst = ConvHelper::to_arma(dstCV);
}
void execute()
{
......
......@@ -17,7 +17,7 @@ colvec sizeY;
colvec two;
cube dst;
cube outMatrix;
mat out2Matrix;
arma::mat out2Matrix;
void init()
{
src = cube(n, m, 3);
......@@ -27,30 +27,36 @@ dst = cube(n, m, 3);
outMatrix = cube(3, n, m);
out2Matrix=mat(2,m);
}
void erodeHelper(cube src, cube dst, int erosion_elem, int iterations)
void erodeHelper(cube src, cv::Mat dst, int erosion_elem, int iterations)
{
int erosion_type = 0;
if( erosion_elem == 0 ){ erosion_type = MORPH_RECT; }
else if( erosion_elem == 1 ){ erosion_type = MORPH_CROSS; }
else if( erosion_elem == 2) { erosion_type = MORPH_ELLIPSE; }
erosion_size = erosion_elem;
mat element = cv::getStructuringElement( erosion_type,
cv::Mat element = cv::getStructuringElement( erosion_type,
Size( 2*erosion_size + 1, 2*erosion_size+1 ),
Point( -1, -1 ) );
cv::erode( src, dst, element, Point(-1,-1), iterations );
cv::Mat srcCV;
srcCV = ConvHelper::to_cvmat(src);
cv::erode( srcCV, dst, element, Point(-1,-1), iterations );
}
void dilateHelper(cube src, cube dst, int dilation_elem, int iterations)
void dilateHelper(cv::Mat src, cv::Mat 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 = cv::getStructuringElement( dilation_type,
cv::mat element = cv::getStructuringElement( dilation_type,
Size( 2*dilation_size + 1, 2*dilation_size+1 ),
Point( -1, -1 ) );
cv::dilate( src, dst, element, Point(-1,-1), iterations );
}
void findContoursHelper(cv::Mat image, vector<vector<cv::Point>> contours, int mode, int method)
{
cv::findContours( image, contours, mode, method );
}
void execute()
{
erodeHelper(src, dst, erosion_elem, iterations);
......
......@@ -11,7 +11,7 @@ using namespace arma;
using namespace std;
class test_math_findContoursCommandTest{
public:
mat image;
arma::mat image;
int mode;
int method;
vector<vector<cv::Point>> contours;
......@@ -19,10 +19,16 @@ void init()
{
image=mat(n,m);
}
void findContoursHelper(arma::mat image, vector<vector<cv::Point>> contours, int mode, int method)
{
cv::Mat srcCV;
srcCV = ConvHelper::to_cvmat(src);
cv::findContours( image, contours, mode, method );
}
void execute()
{
cv::findContours(image, contours, mode, method);
}
};
#endif
#endif
\ No newline at end of file
......@@ -23,7 +23,11 @@ dst = cube(3, n, m);
}
void gaussianBlurHelper(cube src, cube dst, int sizeX, int sizeY, double sigmaX, double sigmaY)
{
cv::gaussianBlur(src, dst, Size(sizeX, sizeY), sigmaX, sigmaY);
cv::Mat srcCV;
cv::Mat dstCV;
srcCV = ConvHelper::to_cvmat(src);
cv::gaussianBlur(srcCV, dstCV, Size(sizeX, sizeY), sigmaX, sigmaY);
dst = ConvHelper::to_armaCube(dstCV);
}
void execute()
{
......
......@@ -10,10 +10,10 @@ using namespace arma;
using namespace std;
class test_math_inRangeCommandTest{
public:
mat src;
arma::mat src;
colvec lowerBoundary;
colvec upperBoundary;
mat dst;
arma::mat dst;
void init()
{
src=mat(n,m);
......@@ -21,10 +21,14 @@ lowerBoundary=colvec(3);
upperBoundary=colvec(3);
dst=mat(n,m);
}
void inRangeHelper(cube src, mat dst, colvec lowerB, colvec upperB)
void inRangeHelper(cube src, arma::mat dst, colvec lowerB, colvec upperB)
{
cv::inRange(src, Scalar(lowerB(0), lowerB(1), lowerB(2)),
Scalar(upperB(0), upperB(1), upperB(2)), dst);
cv::Mat srcCV;
cv::Mat dstCV;
srcCV = ConvHelper::to_cvmat(src);
cv::inRange(srcCV, cv::Scalar(lowerB(0), lowerB(1), lowerB(2)),
cv::Scalar(upperB(0), upperB(1), upperB(2)), dstCV);
dst = ConvHelper::to_arma(dstCV);
}
void execute()
{
......
......@@ -22,10 +22,14 @@ src = cube(3, n, m);
color=colvec(3);
outputImg = cube(3, n, m);
}
Mat rectangleHelper(Mat src, Rect rect, colvec color, int thickness, int lineType)
cube rectangleHelper(cube src, cv::Rect rect, colvec color, int thickness, int lineType)
{
cv::rectangle(src, rect.tl(), rect.br(), Scalar(color(0), color(1), color(2)), thickness, lineType);
return src;
cv::Mat srcCV;
srcCV = ConvHelper::to_cvmat(src);
cv::rectangle(srcCV, rect.tl(), rect.br(), Scalar(color(0), color(1), color(2)), thickness, lineType);
arma::cube srcCube;
srcCube = to_armaCube(srcCV);
return srcCube;
}
void execute()
{
......@@ -34,3 +38,4 @@ outputImg = (rectangleHelper(src, rect, color, thickness, lineType));
};
#endif
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