Skip to content

Commit

Permalink
Astyle cpp/h files
Browse files Browse the repository at this point in the history
  • Loading branch information
willdurand committed Mar 15, 2018
1 parent cb0b7f3 commit e0a309f
Show file tree
Hide file tree
Showing 25 changed files with 378 additions and 278 deletions.
14 changes: 9 additions & 5 deletions contrib/face.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#include "face.h"

LBPHFaceRecognizer CreateLBPHFaceRecognizer() {
return new cv::Ptr<cv::face::LBPHFaceRecognizer>(cv::face::LBPHFaceRecognizer::create());
return new cv::Ptr<cv::face::LBPHFaceRecognizer>(cv::face::LBPHFaceRecognizer::create());
}

void LBPHFaceRecognizer_Train(LBPHFaceRecognizer fr, Mats mats, IntVector labels_in) {
std::vector<int> labels;
for(int i = 0, *v = labels_in.val; i < labels_in.length; ++v, ++i) {

for (int i = 0, *v = labels_in.val; i < labels_in.length; ++v, ++i) {
labels.push_back(*v);
}

std::vector<cv::Mat> images;

for (int i = 0; i < mats.length; ++i) {
images.push_back(*mats.mats[i]);
}
Expand All @@ -22,11 +24,13 @@ void LBPHFaceRecognizer_Train(LBPHFaceRecognizer fr, Mats mats, IntVector labels

void LBPHFaceRecognizer_Update(LBPHFaceRecognizer fr, Mats mats, IntVector labels_in) {
std::vector<int> labels;
for(int i = 0, *v = labels_in.val; i < labels_in.length; ++v, ++i) {

for (int i = 0, *v = labels_in.val; i < labels_in.length; ++v, ++i) {
labels.push_back(*v);
}

std::vector<cv::Mat> images;

for (int i = 0; i < mats.length; ++i) {
images.push_back(*mats.mats[i]);
}
Expand All @@ -49,8 +53,8 @@ struct PredictResponse LBPHFaceRecognizer_PredictExtended(LBPHFaceRecognizer fr,
double confidence;

(*fr)->predict(*sample, label, confidence);
response.label = label;
response.confidence = confidence;
response.label = label;
response.confidence = confidence;


return response;
Expand Down
20 changes: 10 additions & 10 deletions contrib/tracking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bool Tracker_Init(Tracker self, Mat image, Rect boundingBox) {
return ret;
}

bool Tracker_Update(Tracker self, Mat image, Rect *boundingBox) {
bool Tracker_Update(Tracker self, Mat image, Rect* boundingBox) {
cv::Rect2d bb;
bool ret = (*self)->update(*image, bb);
boundingBox->x = int(bb.x);
Expand All @@ -23,54 +23,54 @@ TrackerMIL TrackerMIL_Create() {
return new cv::Ptr<cv::TrackerMIL>(cv::TrackerMIL::create());
}

void TrackerMIL_Close(TrackerMIL self){
void TrackerMIL_Close(TrackerMIL self) {
delete self;
}

TrackerBoosting TrackerBoosting_Create() {
return new cv::Ptr<cv::TrackerBoosting>(cv::TrackerBoosting::create());
}

void TrackerBoosting_Close(TrackerBoosting self){
delete self;
void TrackerBoosting_Close(TrackerBoosting self) {
delete self;
}

TrackerMedianFlow TrackerMedianFlow_Create() {
return new cv::Ptr<cv::TrackerMedianFlow>(cv::TrackerMedianFlow::create());
}

void TrackerMedianFlow_Close(TrackerMedianFlow self){
delete self;
void TrackerMedianFlow_Close(TrackerMedianFlow self) {
delete self;
}

TrackerTLD TrackerTLD_Create() {
return new cv::Ptr<cv::TrackerTLD>(cv::TrackerTLD::create());
}

void TrackerTLD_Close(TrackerTLD self){
void TrackerTLD_Close(TrackerTLD self) {
delete self;
}

TrackerKCF TrackerKCF_Create() {
return new cv::Ptr<cv::TrackerKCF>(cv::TrackerKCF::create());
}

void TrackerKCF_Close(TrackerKCF self){
void TrackerKCF_Close(TrackerKCF self) {
delete self;
}

TrackerMOSSE TrackerMOSSE_Create() {
return new cv::Ptr<cv::TrackerMOSSE>(cv::TrackerMOSSE::create());
}

void TrackerMOSSE_Close(TrackerMOSSE self){
void TrackerMOSSE_Close(TrackerMOSSE self) {
delete self;
}

TrackerCSRT TrackerCSRT_Create() {
return new cv::Ptr<cv::TrackerCSRT>(cv::TrackerCSRT::create());
}

void TrackerCSRT_Close(TrackerCSRT self){
void TrackerCSRT_Close(TrackerCSRT self) {
delete self;
}
2 changes: 1 addition & 1 deletion contrib/tracking.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ typedef void* TrackerCSRT;
#endif

bool Tracker_Init(Tracker self, Mat image, Rect boundingBox);
bool Tracker_Update(Tracker self, Mat image, Rect *boundingBox);
bool Tracker_Update(Tracker self, Mat image, Rect* boundingBox);

TrackerMIL TrackerMIL_Create();
void TrackerMIL_Close(TrackerMIL self);
Expand Down
36 changes: 24 additions & 12 deletions contrib/xfeatures2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ struct KeyPoints SIFT_Detect(SIFT d, Mat src) {
(*d)->detect(*src, detected);

KeyPoint* kps = new KeyPoint[detected.size()];

for (size_t i = 0; i < detected.size(); ++i) {
KeyPoint k = {detected[i].pt.x, detected[i].pt.y, detected[i].size, detected[i].angle,
detected[i].response, detected[i].octave, detected[i].class_id};
kps[i] = k;
KeyPoint k = {detected[i].pt.x, detected[i].pt.y, detected[i].size, detected[i].angle,
detected[i].response, detected[i].octave, detected[i].class_id
};
kps[i] = k;
}

KeyPoints ret = {kps, (int)detected.size()};
return ret;
}
Expand All @@ -28,11 +31,14 @@ struct KeyPoints SIFT_DetectAndCompute(SIFT d, Mat src, Mat mask, Mat desc) {
(*d)->detectAndCompute(*src, *mask, detected, *desc);

KeyPoint* kps = new KeyPoint[detected.size()];

for (size_t i = 0; i < detected.size(); ++i) {
KeyPoint k = {detected[i].pt.x, detected[i].pt.y, detected[i].size, detected[i].angle,
detected[i].response, detected[i].octave, detected[i].class_id};
kps[i] = k;
KeyPoint k = {detected[i].pt.x, detected[i].pt.y, detected[i].size, detected[i].angle,
detected[i].response, detected[i].octave, detected[i].class_id
};
kps[i] = k;
}

KeyPoints ret = {kps, (int)detected.size()};
return ret;
}
Expand All @@ -51,11 +57,14 @@ struct KeyPoints SURF_Detect(SURF d, Mat src) {
(*d)->detect(*src, detected);

KeyPoint* kps = new KeyPoint[detected.size()];

for (size_t i = 0; i < detected.size(); ++i) {
KeyPoint k = {detected[i].pt.x, detected[i].pt.y, detected[i].size, detected[i].angle,
detected[i].response, detected[i].octave, detected[i].class_id};
kps[i] = k;
KeyPoint k = {detected[i].pt.x, detected[i].pt.y, detected[i].size, detected[i].angle,
detected[i].response, detected[i].octave, detected[i].class_id
};
kps[i] = k;
}

KeyPoints ret = {kps, (int)detected.size()};
return ret;
}
Expand All @@ -65,11 +74,14 @@ struct KeyPoints SURF_DetectAndCompute(SURF d, Mat src, Mat mask, Mat desc) {
(*d)->detectAndCompute(*src, *mask, detected, *desc);

KeyPoint* kps = new KeyPoint[detected.size()];

for (size_t i = 0; i < detected.size(); ++i) {
KeyPoint k = {detected[i].pt.x, detected[i].pt.y, detected[i].size, detected[i].angle,
detected[i].response, detected[i].octave, detected[i].class_id};
kps[i] = k;
KeyPoint k = {detected[i].pt.x, detected[i].pt.y, detected[i].size, detected[i].angle,
detected[i].response, detected[i].octave, detected[i].class_id
};
kps[i] = k;
}

KeyPoints ret = {kps, (int)detected.size()};
return ret;
}
24 changes: 16 additions & 8 deletions core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void Mat_ConvertTo(Mat m, Mat dst, int type) {

// Mat_ToBytes returns the bytes representation of the underlying data.
struct ByteArray Mat_ToBytes(Mat m) {
return toByteArray(reinterpret_cast<const char*>(m->data), m->total() * m->elemSize());
return toByteArray(reinterpret_cast<const char*>(m->data), m->total() * m->elemSize());
}

// Mat_Region returns a Mat of a region of another Mat
Expand Down Expand Up @@ -84,7 +84,7 @@ Scalar Mat_Mean(Mat m) {
}

void LUT(Mat src, Mat lut, Mat dst) {
cv::LUT(*src, *lut, *dst);
cv::LUT(*src, *lut, *dst);
}

// Mat_Rows returns how many rows in this Mat.
Expand Down Expand Up @@ -119,7 +119,7 @@ uint8_t Mat_GetUChar(Mat m, int row, int col) {
}

uint8_t Mat_GetUChar3(Mat m, int x, int y, int z) {
return m->at<uchar>(x, y , z);
return m->at<uchar>(x, y, z);
}

// Mat_GetSChar returns a specific row/col value from this Mat expecting
Expand Down Expand Up @@ -185,11 +185,11 @@ void Mat_SetUChar3(Mat m, int x, int y, int z, uint8_t val) {
// Mat_SetSChar set a specific row/col value from this Mat expecting
// each element to contain a schar aka CV_8S.
void Mat_SetSChar(Mat m, int row, int col, int8_t val) {
m->at<schar>(row, col) = val;
m->at<schar>(row, col) = val;
}

void Mat_SetSChar3(Mat m, int x, int y, int z, int8_t val) {
m->at<schar>(x, y, z) = val;
m->at<schar>(x, y, z) = val;
}

// Mat_SetShort set a specific row/col value from this Mat expecting
Expand Down Expand Up @@ -260,7 +260,8 @@ void Mat_BitwiseXor(Mat src1, Mat src2, Mat dst) {
cv::bitwise_xor(*src1, *src2, *dst);
}

void Mat_BatchDistance(Mat src1, Mat src2, Mat dist, int dtype, Mat nidx, int normType, int K, Mat mask, int update, bool crosscheck) {
void Mat_BatchDistance(Mat src1, Mat src2, Mat dist, int dtype, Mat nidx, int normType, int K,
Mat mask, int update, bool crosscheck) {
cv::batchDistance(*src1, *src2, *dist, dtype, *nidx, normType, K, *mask, update, crosscheck);
}

Expand Down Expand Up @@ -293,7 +294,8 @@ void Mat_ConvertScaleAbs(Mat src, Mat dst, double alpha, double beta) {
cv::convertScaleAbs(*src, *dst, alpha, beta);
}

void Mat_CopyMakeBorder(Mat src, Mat dst, int top, int bottom, int left, int right, int borderType, Scalar value) {
void Mat_CopyMakeBorder(Mat src, Mat dst, int top, int bottom, int left, int right, int borderType,
Scalar value) {
cv::Scalar c_value(value.val1, value.val2, value.val3, value.val4);
cv::copyMakeBorder(*src, *dst, top, bottom, left, right, borderType, c_value);
}
Expand Down Expand Up @@ -381,9 +383,11 @@ void Mat_MeanStdDev(Mat src, Mat dstMean, Mat dstStdDev) {

void Mat_Merge(struct Mats mats, Mat dst) {
std::vector<cv::Mat> images;

for (int i = 0; i < mats.length; ++i) {
images.push_back(*mats.mats[i]);
}

cv::merge(images, *dst);
}

Expand All @@ -410,13 +414,15 @@ double Norm(Mat src1, int normType) {
return cv::norm(*src1, normType);
}

void Mat_Split(Mat src, struct Mats *mats) {
void Mat_Split(Mat src, struct Mats* mats) {
std::vector<cv::Mat> channels;
cv::split(*src, channels);
mats->mats = new Mat[channels.size()];

for (size_t i = 0; i < channels.size(); ++i) {
mats->mats[i] = new cv::Mat(channels[i]);
}

mats->length = (int)channels.size();
}

Expand Down Expand Up @@ -448,6 +454,7 @@ void Contours_Close(struct Contours cs) {
for (int i = 0; i < cs.length; i++) {
Points_Close(cs.contours[i]);
}

delete[] cs.contours;
}

Expand All @@ -459,6 +466,7 @@ void Points_Close(Points ps) {
for (size_t i = 0; i < ps.length; i++) {
Point_Close(ps.points[i]);
}

delete[] ps.points;
}

Expand Down
Loading

0 comments on commit e0a309f

Please sign in to comment.