Commit d0780166 authored by Matteo's avatar Matteo
Browse files

add formatting config and style guide

parent e075f46c
......@@ -2,11 +2,13 @@
#define GETTIMELABEL_H
#include <stdlib.h>
#include <string>
/**
* @fn std::string getTimeLabel(int ms, std::string delim = ":")
* @brief Convert an int representing milliseconds to the corresponding Time Label string.
* @brief Convert an int representing milliseconds to the corresponding Time
* Label string.
*
* @param ms the number of milliseconds.
* @param delim the time separator
......
This diff is collapsed.
#include "utility.h"
#include <filesystem>
#include <fstream>
#include <nlohmann/json.hpp>
#include "utility.h"
using namespace cv;
using namespace std;
......@@ -14,135 +15,137 @@ utility::Frame::Frame(const Mat& m) : Mat(m) {}
utility::Frame::Frame(const Frame& f) : Mat(f) {}
// Operators
utility::Frame& utility::Frame::operator=(const Mat& m) {
Mat::operator=(m);
return *this;
Mat::operator=(m);
return *this;
}
utility::Frame& utility::Frame::operator=(const Frame& f) {
Mat::operator=(f);
return *this;
Mat::operator=(f);
return *this;
}
// Methods
utility::Frame utility::Frame::clone() const {
return utility::Frame(Mat::clone());
}
utility::Frame utility::Frame::clone() const { return utility::Frame(Mat::clone()); }
utility::Frame& utility::Frame::downsample(int factor) {
pyrDown(*this, *this, Size(size().width / factor, size().height / factor));
return *this;
pyrDown(*this, *this, Size(size().width / factor, size().height / factor));
return *this;
}
utility::Frame& utility::Frame::convertColor(int code) {
cvtColor(*this, *this, code);
return *this;
}
utility::Frame utility::Frame::difference(Frame& f) {
return Frame(utility::difference(*this, f));
cvtColor(*this, *this, code);
return *this;
}
utility::Frame utility::Frame::difference(Frame& f) { return Frame(utility::difference(*this, f)); }
utility::Frame& utility::Frame::crop(Size rect_size, Point2f center) {
cv::getRectSubPix(*this, rect_size, center, *this);
return *this;
cv::getRectSubPix(*this, rect_size, center, *this);
return *this;
}
utility::Frame& utility::Frame::warp(cv::Mat rotationMatrix) {
cv::warpAffine(*this, *this, rotationMatrix, this->size(), INTER_CUBIC);
return *this;
cv::warpAffine(*this, *this, rotationMatrix, this->size(), INTER_CUBIC);
return *this;
}
pair<utility::Frame, utility::Frame> utility::Frame::deinterlace() const {
Frame odd_frame(cv::Mat(this->rows/2, this->cols, CV_8UC3));
Frame even_frame(cv::Mat(this->rows/2, this->cols, CV_8UC3));
Frame odd_frame(cv::Mat(this->rows / 2, this->cols, CV_8UC3));
Frame even_frame(cv::Mat(this->rows / 2, this->cols, CV_8UC3));
utility::separateFrame(*this, odd_frame, even_frame);
utility::separateFrame(*this, odd_frame, even_frame);
return make_pair(odd_frame, even_frame);
return make_pair(odd_frame, even_frame);
}
void utility::detectShape(Ptr<GeneralizedHoughGuil> alg, Mat templateShape, int posThresh, vector<Vec4f> &positivePositions, Mat &positiveVotes, vector<Vec4f> &negativePositions, Mat &negativeVotes, Mat processingArea) {
alg -> setPosThresh(posThresh);
alg -> setTemplate(templateShape);
int oldSizePositive = 0;
int i = 0;
int maxVote = 0;
// Process shapes with positive angles
alg -> setMinAngle(0);
alg -> setMaxAngle(3);
while (true) {
alg -> detect(processingArea, positivePositions, positiveVotes);
int currentSize = positivePositions.size();
if (currentSize == 1) {
// We detected the most interesting shape
break;
} else if (currentSize == 0 && oldSizePositive > 0) {
// It is not possible to detect only one shape with the current parameters
alg -> setPosThresh(posThresh+i-1); // Decrease position value
alg -> detect(processingArea, positivePositions, positiveVotes); // Detect all available shapes
break;
} else if (currentSize == 0 && oldSizePositive == 0) {
// Impossible to find with these parameters
break;
}
oldSizePositive = currentSize;
// Find maximum vote
for (int j = 0; j < positiveVotes.cols / 3; j++) {
if (positiveVotes.at<int>(3*j) > maxVote)
maxVote = positiveVotes.at<int>(3*j);
}
if (currentSize > 10) {
i += 5; // To speed up computation when there are too many matches
} else if (maxVote - (posThresh + i) > 100) {
i += 100; // To speed up computation when there are few super high matches
} else {
i++;
}
alg -> setPosThresh(posThresh+i);
}
int oldSizeNegative = 0;
// Reset incremental position value
i = 0;
maxVote = 0;
// Process shapes with negative angles
alg -> setMinAngle(357);
alg -> setMaxAngle(360);
while (true) {
alg -> detect(processingArea, negativePositions, negativeVotes);
int currentSize = negativePositions.size();
if (currentSize == 1) {
// We detected the most interesting shape
break;
} else if (currentSize == 0 && oldSizeNegative > 0) {
// It is not possible to detect only one shape with the current parameters
alg -> setPosThresh(posThresh+i-1); // Decrease position value
alg -> detect(processingArea, negativePositions, negativeVotes); // Detect all available shapes
break;
} else if (currentSize == 0 && oldSizeNegative == 0) {
// Impossible to found with these parameters
break;
}
oldSizeNegative = currentSize;
// Find maximum vote
for (int j = 0; j < positiveVotes.cols / 3; j++) {
if (positiveVotes.at<int>(3*j) > maxVote)
maxVote = positiveVotes.at<int>(3*j);
}
if (currentSize > 10) {
i += 5; // To speed up computation when there are too many matches
} else if (maxVote - (posThresh + i) > 100) {
i += 100; // To speed up computation when there are few super high matches
} else {
i++;
}
alg -> setPosThresh(posThresh+i);
}
void utility::detectShape(Ptr<GeneralizedHoughGuil> alg, Mat templateShape, int posThresh,
vector<Vec4f>& positivePositions, Mat& positiveVotes, vector<Vec4f>& negativePositions,
Mat& negativeVotes, Mat processingArea) {
alg->setPosThresh(posThresh);
alg->setTemplate(templateShape);
int oldSizePositive = 0;
int i = 0;
int maxVote = 0;
// Process shapes with positive angles
alg->setMinAngle(0);
alg->setMaxAngle(3);
while (true) {
alg->detect(processingArea, positivePositions, positiveVotes);
int currentSize = positivePositions.size();
if (currentSize == 1) {
// We detected the most interesting shape
break;
} else if (currentSize == 0 && oldSizePositive > 0) {
// It is not possible to detect only one shape with the current
// parameters
alg->setPosThresh(posThresh + i - 1); // Decrease position value
alg->detect(processingArea, positivePositions,
positiveVotes); // Detect all available shapes
break;
} else if (currentSize == 0 && oldSizePositive == 0) {
// Impossible to find with these parameters
break;
}
oldSizePositive = currentSize;
// Find maximum vote
for (int j = 0; j < positiveVotes.cols / 3; j++) {
if (positiveVotes.at<int>(3 * j) > maxVote) maxVote = positiveVotes.at<int>(3 * j);
}
if (currentSize > 10) {
i += 5; // To speed up computation when there are too many matches
} else if (maxVote - (posThresh + i) > 100) {
i += 100; // To speed up computation when there are few super high
// matches
} else {
i++;
}
alg->setPosThresh(posThresh + i);
}
int oldSizeNegative = 0;
// Reset incremental position value
i = 0;
maxVote = 0;
// Process shapes with negative angles
alg->setMinAngle(357);
alg->setMaxAngle(360);
while (true) {
alg->detect(processingArea, negativePositions, negativeVotes);
int currentSize = negativePositions.size();
if (currentSize == 1) {
// We detected the most interesting shape
break;
} else if (currentSize == 0 && oldSizeNegative > 0) {
// It is not possible to detect only one shape with the current
// parameters
alg->setPosThresh(posThresh + i - 1); // Decrease position value
alg->detect(processingArea, negativePositions,
negativeVotes); // Detect all available shapes
break;
} else if (currentSize == 0 && oldSizeNegative == 0) {
// Impossible to found with these parameters
break;
}
oldSizeNegative = currentSize;
// Find maximum vote
for (int j = 0; j < positiveVotes.cols / 3; j++) {
if (positiveVotes.at<int>(3 * j) > maxVote) maxVote = positiveVotes.at<int>(3 * j);
}
if (currentSize > 10) {
i += 5; // To speed up computation when there are too many matches
} else if (maxVote - (posThresh + i) > 100) {
i += 100; // To speed up computation when there are few super high
// matches
} else {
i++;
}
alg->setPosThresh(posThresh + i);
}
}
RotatedRect utility::drawShapes(Mat frame, Vec4f &positions, Scalar color, int width, int height, int offsetX, int offsetY, float processingScale) {
RotatedRect utility::drawShapes(Mat frame, Vec4f& positions, Scalar color, int width, int height, int offsetX,
int offsetY, float processingScale) {
RotatedRect rr;
Point2f rrpts[4];
Point2f pos(positions[0]+offsetX, positions[1]+offsetY);
Point2f pos(positions[0] + offsetX, positions[1] + offsetY);
float scale = positions[2];
float angle = positions[3];
......@@ -160,21 +163,20 @@ RotatedRect utility::drawShapes(Mat frame, Vec4f &positions, Scalar color, int w
return rr;
}
void utility::separateFrame(const cv::Mat frame, cv::Mat &odd_frame, cv::Mat &even_frame) {
void utility::separateFrame(const cv::Mat frame, cv::Mat& odd_frame, cv::Mat& even_frame) {
int i_odd_frame = 0;
int i_even_frame = 0;
for (int i = 0; i < frame.rows; i++) {
for (int j = 0; j < frame.cols; j++) {
if (i % 2 == 0) {
even_frame.at<cv::Vec3b>( i_even_frame, j )[0] = frame.at<cv::Vec3b>(i, j)[0];
even_frame.at<cv::Vec3b>( i_even_frame, j )[1] = frame.at<cv::Vec3b>(i, j)[1];
even_frame.at<cv::Vec3b>( i_even_frame, j )[2] = frame.at<cv::Vec3b>(i, j)[2];
even_frame.at<cv::Vec3b>(i_even_frame, j)[0] = frame.at<cv::Vec3b>(i, j)[0];
even_frame.at<cv::Vec3b>(i_even_frame, j)[1] = frame.at<cv::Vec3b>(i, j)[1];
even_frame.at<cv::Vec3b>(i_even_frame, j)[2] = frame.at<cv::Vec3b>(i, j)[2];
} else {
odd_frame.at<cv::Vec3b>( i_odd_frame, j )[0] = frame.at<cv::Vec3b>(i, j)[0];
odd_frame.at<cv::Vec3b>( i_odd_frame, j )[1] = frame.at<cv::Vec3b>(i, j)[1];
odd_frame.at<cv::Vec3b>( i_odd_frame, j )[2] = frame.at<cv::Vec3b>(i, j)[2];
odd_frame.at<cv::Vec3b>(i_odd_frame, j)[0] = frame.at<cv::Vec3b>(i, j)[0];
odd_frame.at<cv::Vec3b>(i_odd_frame, j)[1] = frame.at<cv::Vec3b>(i, j)[1];
odd_frame.at<cv::Vec3b>(i_odd_frame, j)[2] = frame.at<cv::Vec3b>(i, j)[2];
}
}
......@@ -186,14 +188,15 @@ void utility::separateFrame(const cv::Mat frame, cv::Mat &odd_frame, cv::Mat &ev
}
return;
}
cv::Mat utility::difference(cv::Mat &prevFrame, cv::Mat &currentFrame) {
cv::Mat utility::difference(cv::Mat& prevFrame, cv::Mat& currentFrame) {
cv::Mat diff = currentFrame.clone();
for (int i = 0; i < currentFrame.rows; i++) {
for (int j = 0; j < currentFrame.cols; j++) {
if (prevFrame.at<cv::Vec3b>(i, j)[0] != currentFrame.at<cv::Vec3b>(i, j)[0] || prevFrame.at<cv::Vec3b>(i, j)[1] != currentFrame.at<cv::Vec3b>(i, j)[1] || prevFrame.at<cv::Vec3b>(i, j)[2] != currentFrame.at<cv::Vec3b>(i, j)[2]) {
if (prevFrame.at<cv::Vec3b>(i, j)[0] != currentFrame.at<cv::Vec3b>(i, j)[0] ||
prevFrame.at<cv::Vec3b>(i, j)[1] != currentFrame.at<cv::Vec3b>(i, j)[1] ||
prevFrame.at<cv::Vec3b>(i, j)[2] != currentFrame.at<cv::Vec3b>(i, j)[2]) {
// Different pixels
diff.at<cv::Vec3b>(i, j)[0] = 0;
} else {
......@@ -206,34 +209,20 @@ cv::Mat utility::difference(cv::Mat &prevFrame, cv::Mat &currentFrame) {
}
SceneObject::SceneObject(int minDist, Threshold threshold) {
this->minDist = minDist;
this->threshold = threshold;
this->minDist = minDist;
this->threshold = threshold;
}
SceneObject SceneObject::from_file(fs::path path, Object obj) {
ifstream iConfig(path);
json j;
iConfig >> j;
if (obj == Object::TAPE) {
return SceneObject(
j["MinDist"],
Threshold {
j["TapeThresholdPercentual"],
j["AngleThresh"],
j["ScaleThresh"],
j["PosThresh"]
}
);
} else {
return SceneObject(
j["MinDistCapstan"],
Threshold {
j["CapstanThresholdPercentual"],
j["AngleThreshCapstan"],
j["ScaleThreshCapstan"],
j["PosThreshCapstan"]
}
);
}
ifstream iConfig(path);
json j;
iConfig >> j;
if (obj == Object::TAPE) {
return SceneObject(j["MinDist"],
Threshold{j["TapeThresholdPercentual"], j["AngleThresh"], j["ScaleThresh"], j["PosThresh"]});
} else {
return SceneObject(j["MinDistCapstan"], Threshold{j["CapstanThresholdPercentual"], j["AngleThreshCapstan"],
j["ScaleThreshCapstan"], j["PosThreshCapstan"]});
}
}
\ No newline at end of file
......@@ -10,159 +10,173 @@ namespace fs = std::filesystem;
/**
* @brief Namespace containing a set of utility functions used in the project.
* The functions are mainly used to perform operations on images.
*
*
*/
namespace utility {
/**
* @class Frame
* @brief Class that extends the OpenCV Mat class, adding some useful methods frequently used in the project.
*
*/
class Frame : public Mat {
public:
Frame();
Frame(const Mat& m);
Frame(const Frame& f);
Frame& operator=(const Mat& m);
Frame& operator=(const Frame& f);
Frame clone() const;
/**
* @brief Downsample the image by a given factor.
*
* @param factor The factor by which the image will be downsampled.
* @return Frame& The downsampled image.
*/
Frame& downsample(int factor);
/**
* @brief Convert the image to a given color space.
*
* @param code The code of the color space to which the image will be converted.
* @return Frame& The converted image.
*/
Frame& convertColor(int code);
Frame difference(Frame& f);
/**
* @brief Crop the image to a given size, centered in a given point.
*
* @param rect_size The size of the cropped image.
* @param center The center of the cropped image.
* @return Frame& The cropped image.
*/
Frame& crop(Size rect_size, Point2f center);
/**
* @brief Warp the image using a given rotation matrix.
*
* @param rotationMatrix The rotation matrix used to warp the image.
* @return Frame& The warped image.
*/
Frame& warp(cv::Mat rotationMatrix);
/**
* @brief Deinterlace the image, returning two images, one containing the odd lines and the other containing the even lines.
*
* @return std::pair<Frame, Frame> The two images containing the odd and even lines.
*/
std::pair<Frame, Frame> deinterlace() const;
};
/**
* @fn void detectShape(Ptr<GeneralizedHoughGuil> alg, Mat templateShape, int posThresh, vector<Vec4f> &positivePositions, Mat &positiveVotes, vector<Vec4f> &negativePositions, Mat &negativeVotes, Mat processingArea)
* @brief Detects a given shape in an image, using a the OpenCV algorithm GeneralizedHoughGuil.
*
* @param[in] alg the algorithm instance;
* @param[in] templateShape the shape to detect;
* @param[in] posThresh the position votes threshold;
* @param[out] positivePositions vector representing the position assigned to each found rectangle for positive angles;
* @param[out] positiveVotes vector representing the vote assigned to each found rectangle for positive angles;
* @param[out] negativePositions vector representing the position assigned to each found rectangle for negative angles;
* @param[out] negativeVotes vector representing the vote assigned to each found rectangle for negative angles;
* @param[in] processingArea the image to be processed.
*/
void detectShape(Ptr<GeneralizedHoughGuil> alg, Mat templateShape, int posThresh, vector<Vec4f> &positivePositions, Mat &positiveVotes, vector<Vec4f> &negativePositions, Mat &negativeVotes, Mat processingArea);
/**
* @fn RotatedRect drawShapes(Mat frame, Vec4f &positions, Scalar color, int width, int height, int offsetX, int offsetY, float processingScale)
* @brief Draw rectangles on an image.
*
* @param frame Frame on which the rectangles will be drawn;
* @param positions The position of the rectangle;
* @param color The color of the rectangle;
* @param width The width of the rectangle;
* @param height The height of the rectangle;
* @param offsetX X offset on the position of the rectangle;
* @param offsetY Y offset on the position of the rectangle;
* @param processingScale Scaling factor, useful for downsizing.
* @return RotatedRect Object representing the drawn rectangle.
*/
RotatedRect drawShapes(Mat frame, Vec4f &positions, Scalar color, int width, int height, int offsetX, int offsetY, float processingScale);
/**
* @class Frame
* @brief Class that extends the OpenCV Mat class, adding some useful methods
* frequently used in the project.
*
*/
class Frame : public Mat {
public:
Frame();
Frame(const Mat& m);
Frame(const Frame& f);
Frame& operator=(const Mat& m);
Frame& operator=(const Frame& f);
Frame clone() const;
/**
* @brief Downsample the image by a given factor.
*
* @param factor The factor by which the image will be downsampled.
* @return Frame& The downsampled image.
*/
Frame& downsample(int factor);
/**
* @brief Convert the image to a given color space.
*
* @param code The code of the color space to which the image will be
* converted.
* @return Frame& The converted image.
*/
Frame& convertColor(int code);
Frame difference(Frame& f);
/**
* @brief Crop the image to a given size, centered in a given point.
*
* @param rect_size The size of the cropped image.
* @param center The center of the cropped image.
* @return Frame& The cropped image.
*/
Frame& crop(Size rect_size, Point2f center);
/**
* @brief Warp the image using a given rotation matrix.
*
* @param rotationMatrix The rotation matrix used to warp the image.
* @return Frame& The warped image.
*/
Frame& warp(cv::Mat rotationMatrix);
/**
* @brief Deinterlace the image, returning two images, one containing the
* odd lines and the other containing the even lines.
*
* @return std::pair<Frame, Frame> The two images containing the odd and
* even lines.
*/
std::pair<Frame, Frame> deinterlace() const;
};
/**
* @fn void detectShape(Ptr<GeneralizedHoughGuil> alg, Mat templateShape, int
* posThresh, vector<Vec4f> &positivePositions, Mat &positiveVotes,
* vector<Vec4f> &negativePositions, Mat &negativeVotes, Mat processingArea)
* @brief Detects a given shape in an image, using a the OpenCV algorithm
* GeneralizedHoughGuil.
*
* @param[in] alg the algorithm instance;
* @param[in] templateShape the shape to detect;
* @param[in] posThresh the position votes threshold;
* @param[out] positivePositions vector representing the position assigned to
* each found rectangle for positive angles;
* @param[out] positiveVotes vector representing the vote assigned to each found
* rectangle for positive angles;
* @param[out] negativePositions vector representing the position assigned to
* each found rectangle for negative angles;
* @param[out] negativeVotes vector representing the vote assigned to each found
* rectangle for negative angles;
* @param[in] processingArea the image to be processed.
*/
void detectShape(Ptr<GeneralizedHoughGuil> alg, Mat templateShape, int posThresh, vector<Vec4f>& positivePositions,
Mat& positiveVotes, vector<Vec4f>& negativePositions, Mat& negativeVotes, Mat processingArea);
/**
* @fn void separateFrame(cv::Mat frame, cv::Mat &odd_frame, cv::Mat &even_frame)
* @brief Function to deinterlace the current image.
*
* @param[in] frame image to be processed;
* @param[out] odd_frame odd plane;
* @param[out] even_frame even plane.
*/
void separateFrame(const cv::Mat frame, cv::Mat &odd_frame, cv::Mat &even_frame);
/**
* @fn RotatedRect drawShapes(Mat frame, Vec4f &positions, Scalar color, int
* width, int height, int offsetX, int offsetY, float processingScale)
* @brief Draw rectangles on an image.
*
* @param frame Frame on which the rectangles will be drawn;
* @param positions The position of the rectangle;
* @param color The color of the rectangle;
* @param width The width of the rectangle;
* @param height The height of the rectangle;
* @param offsetX X offset on the position of the rectangle;
* @param offsetY Y offset on the position of the rectangle;
* @param processingScale Scaling factor, useful for downsizing.
* @return RotatedRect Object representing the drawn rectangle.
*/
RotatedRect drawShapes(Mat frame, Vec4f& positions, Scalar color, int width, int height, int offsetX, int offsetY,
float processingScale);
/**
* @fn void separateFrame(cv::Mat frame, cv::Mat &odd_frame, cv::Mat
* &even_frame)
* @brief Function to deinterlace the current image.
*
* @param[in] frame image to be processed;
* @param[out] odd_frame odd plane;
* @param[out] even_frame even plane.
*/
void separateFrame(const cv::Mat frame, cv::Mat& odd_frame, cv::Mat& even_frame);
/**
* @fn void separateFrame(cv::Mat frame, cv::Mat &odd_frame, cv::Mat &even_frame)
* @brief Compute the number of different pixels between two frames.
*
* @param prevFrame the first frame;
* @param currentFrame the second frame.
* @return cv::Mat A black and white frame, where black pixels represent a difference, while white pixels represent an equality.
*/
cv::Mat difference(cv::Mat &prevFrame, cv::Mat &currentFrame);
}
/**
* @fn void separateFrame(cv::Mat frame, cv::Mat &odd_frame, cv::Mat
* &even_frame)
* @brief Compute the number of different pixels between two frames.
*
* @param prevFrame the first frame;
* @param currentFrame the second frame.
* @return cv::Mat A black and white frame, where black pixels represent a
* difference, while white pixels represent an equality.
*/
cv::Mat difference(cv::Mat& prevFrame, cv::Mat& currentFrame);
} // namespace utility
/**
* @struct Threshold
* @brief Struct containing the threshold values used to detect a shape.
*
*
*/
struct Threshold {
/**
*
*/
float percentual; /**< The minimum percentage of different pixels for considering the current frame under the ROI as a potential Irregularity */
int angle; /**< The angle votes threshold for the detection of the object */
int scale; /**< The scale votes threshold for the detection of the object */
int pos; /**< The position votes threshold for the detection of the object */
float percentual; /**< The minimum percentage of different pixels for
considering the current frame under the ROI as a
potential Irregularity */
int angle; /**< The angle votes threshold for the detection of the object */
int scale; /**< The scale votes threshold for the detection of the object */
int pos; /**< The position votes threshold for the detection of the object
*/
};
/**
* @enum Object
* @brief Enum containing the possible objects to detect.
*
*
*/
enum Object {
TAPE,
CAPSTAN
};
enum Object { TAPE, CAPSTAN };
/**
* @struct SceneObject
* @brief A scene object is an object that can be detected in a scene, such as a tape or a capstan.
* @brief A scene object is an object that can be detected in a scene, such as a
* tape or a capstan.
*
*/
struct SceneObject {
int minDist; /**< The minimum distance between the centers of the detected objects for the detection of the reading head */
Threshold threshold; /**< the threshold values used to detect the object */
int minDist; /**< The minimum distance between the centers of the detected
objects for the detection of the reading head */
Threshold threshold; /**< the threshold values used to detect the object */
SceneObject(int minDist, Threshold threshold);
~SceneObject() = default;
/**
* @fn static SceneObject from_file(fs::path path, Object obj)
* @brief Create a SceneObject from a given file.
*
* @param path The path of the file containing the object.
* @note The file must be a JSON file.
* @param obj The object to detect.
* @return SceneObject The SceneObject created from the file.
*/
static SceneObject from_file(fs::path path, Object obj);
SceneObject(int minDist, Threshold threshold);
~SceneObject() = default;
/**
* @fn static SceneObject from_file(fs::path path, Object obj)
* @brief Create a SceneObject from a given file.
*
* @param path The path of the file containing the object.
* @note The file must be a JSON file.
* @param obj The object to detect.
* @return SceneObject The SceneObject created from the file.
*/
static SceneObject from_file(fs::path path, Object obj);
};
#include "../src/lib/enums.h"
#include <gtest/gtest.h>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include "../src/lib/enums.h"
TEST(IrregularityType, toString) {
EXPECT_EQ(irregularityTypeToString(IrregularityType::WOW_AND_FLUTTER), "wf");
}
TEST(IrregularityType, toString) { EXPECT_EQ(irregularityTypeToString(IrregularityType::WOW_AND_FLUTTER), "wf"); }
TEST(IrregularityType, fromString) {
EXPECT_EQ(irregularityTypeFromString("wf"), IrregularityType::WOW_AND_FLUTTER);
......
#include "../src/lib/Irregularity.h"
#include <gtest/gtest.h>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include "../src/lib/Irregularity.h"
TEST(Irregularity, Init) {
Irregularity irreg = Irregularity(
Source::Video,
"00:00:00.000",
IrregularityType::WOW_AND_FLUTTER,
"https://example.com/image.png"
);
Irregularity irreg =
Irregularity(Source::Video, "00:00:00.000", IrregularityType::WOW_AND_FLUTTER, "https://example.com/image.png");
Irregularity irreg2 = Irregularity(
Source::Video,
"00:00:00.000",
IrregularityType::WOW_AND_FLUTTER,
"https://example.com/image.png"
);
Irregularity irreg2 =
Irregularity(Source::Video, "00:00:00.000", IrregularityType::WOW_AND_FLUTTER, "https://example.com/image.png");
EXPECT_NE(irreg.id, irreg2.id);
EXPECT_EQ(irreg.source, irreg2.source);
......
Supports Markdown
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