auto &inputBuffer = callbackNode->getInputBuffer();
auto newBaseData = inputBuffer->getInputs()[0]->clone();
auto newImage = dynamic_pointer_cast<ImageDataType>(newBaseData);
- const int answer[][4] = { { 553, 87, 583, 129 }, { 397, 110, 427, 149 } };
+ const vector<Rect> answer { { 553, 87, 583, 129 }, { 397, 110, 427, 149 } };
cv::Mat cv_image(cv::Size(newImage->width, newImage->height), CV_MAKETYPE(CV_8U, 3), newImage->ptr);
- auto &results = callbackNode->results();
- for (auto r : results) {
- ASSERT_EQ(r->_type, ResultType::FACE_DETECTION);
+ for (auto &result : callbackNode->results()) {
+ ASSERT_EQ(result->_type, ResultType::FACE_DETECTION);
- auto f_r = dynamic_pointer_cast<FdResultType>(r);
- unsigned int idx = 0;
+ auto f_r = dynamic_pointer_cast<FdResultType>(result);
- for (auto rect : f_r->_rects) {
- ASSERT_EQ(rect.left, answer[idx][0]);
- ASSERT_EQ(rect.top, answer[idx][1]);
- ASSERT_EQ(rect.right, answer[idx][2]);
- ASSERT_EQ(rect.bottom, answer[idx++][3]);
- }
+ ASSERT_EQ(f_r->_rects.size(), answer.size());
+
+ unsigned int idx = 0;
+ for (auto &rect : f_r->_rects)
+ ASSERT_EQ(rect, answer[idx++]);
}
auto outputBuffer = make_shared<SharedBuffer>();
{
cv::Mat cv_image = cv::imread(IMG_FACE, cv::IMREAD_COLOR);
cv::cvtColor(cv_image, cv_image, cv::COLOR_BGR2RGB);
- const int answer[][2] = { { 243, 133 }, { 404, 135 }, { 347, 197 }, { 250, 266 }, { 385, 266 } };
+ const vector<Point> answer { { 243, 133 }, { 404, 135 }, { 347, 197 }, { 250, 266 }, { 385, 266 } };
ASSERT_FALSE(cv_image.empty());
taskManager->run();
- auto results = taskManager->output();
- for (auto &result : results) {
+ for (auto &result : taskManager->output()) {
auto fld_result = dynamic_pointer_cast<FldResultType>(result);
- unsigned int idx = 0;
- for (auto &point : fld_result->_points) {
- ASSERT_EQ(point.x, answer[idx][0]);
- ASSERT_EQ(point.y, answer[idx++][1]);
- }
+ ASSERT_EQ(fld_result->_points.size(), answer.size());
+
+ unsigned int idx = 0;
+ for (auto &point : fld_result->_points)
+ ASSERT_EQ(point, answer[idx++]);
}
taskManager->clear();
{
cv::Mat cv_image = cv::imread(IMG_FACE, cv::IMREAD_COLOR);
cv::cvtColor(cv_image, cv_image, cv::COLOR_BGR2RGB);
- const int answer[][2] = { { 243, 133 }, { 404, 135 }, { 347, 197 }, { 250, 266 }, { 385, 266 } };
+ const vector<Point> answer { { 243, 133 }, { 404, 135 }, { 347, 197 }, { 250, 266 }, { 385, 266 } };
ASSERT_FALSE(cv_image.empty());
taskManager->run();
- auto results = taskManager->output();
- for (auto &result : results) {
+ for (auto &result : taskManager->output()) {
auto fld_result = dynamic_pointer_cast<FldResultType>(result);
- unsigned int idx = 0;
- for (auto &point : fld_result->_points) {
- ASSERT_EQ(point.x, answer[idx][0]);
- ASSERT_EQ(point.y, answer[idx++][1]);
- }
+ ASSERT_EQ(fld_result->_points.size(), answer.size());
+
+ unsigned int idx = 0;
+ for (auto &point : fld_result->_points)
+ ASSERT_EQ(point, answer[idx++]);
}
taskManager->clear();
{
cv::Mat cv_image = cv::imread(IMG_FACE, cv::IMREAD_COLOR);
cv::cvtColor(cv_image, cv_image, cv::COLOR_BGR2RGB);
- const int fd_answer[][4] = { { 553, 87, 583, 129 }, { 397, 110, 427, 149 } };
- const int fld_answer[][2] = { { 243, 133 }, { 404, 135 }, { 347, 197 }, { 250, 266 }, { 385, 266 } };
+ const vector<Rect> fd_answer { { 553, 87, 583, 129 }, { 397, 110, 427, 149 } };
+ const vector<Point> fld_answer { { 243, 133 }, { 404, 135 }, { 347, 197 }, { 250, 266 }, { 385, 266 } };
ASSERT_FALSE(cv_image.empty());
taskManager->run();
- auto results = taskManager->output();
- for (auto &result : results) {
+ for (auto &result : taskManager->output()) {
if (result->_type == ResultType::FACE_DETECTION) {
auto fd_result = dynamic_pointer_cast<FdResultType>(result);
- unsigned int idx = 0;
- for (auto rect : fd_result->_rects) {
- ASSERT_EQ(rect.left, fd_answer[idx][0]);
- ASSERT_EQ(rect.top, fd_answer[idx][1]);
- ASSERT_EQ(rect.right, fd_answer[idx][2]);
- ASSERT_EQ(rect.bottom, fd_answer[idx++][3]);
- }
+ ASSERT_EQ(fd_result->_rects.size(), fd_answer.size());
+
+ unsigned int idx = 0;
+ for (auto &rect : fd_result->_rects)
+ ASSERT_EQ(rect, fd_answer[idx++]);
} else {
auto fld_result = dynamic_pointer_cast<FldResultType>(result);
- unsigned int idx = 0;
- for (auto &point : fld_result->_points) {
- ASSERT_EQ(point.x, fld_answer[idx][0]);
- ASSERT_EQ(point.y, fld_answer[idx++][1]);
- }
+ ASSERT_EQ(fld_result->_points.size(), fld_answer.size());
+
+ unsigned int idx = 0;
+ for (auto &point : fld_result->_points)
+ ASSERT_EQ(point, fld_answer[idx++]);
}
}
{
cv::Mat cv_image = cv::imread(IMG_FACE, cv::IMREAD_COLOR);
cv::cvtColor(cv_image, cv_image, cv::COLOR_BGR2RGB);
- const int fd_answer[][4] = { { 553, 87, 583, 129 }, { 397, 110, 427, 149 } };
- const int fld_answer[][2] = { { 243, 133 }, { 404, 135 }, { 347, 197 }, { 250, 266 }, { 385, 266 } };
+ const vector<Rect> fd_answer { { 553, 87, 583, 129 }, { 397, 110, 427, 149 } };
+ const vector<Point> fld_answer { { 243, 133 }, { 404, 135 }, { 347, 197 }, { 250, 266 }, { 385, 266 } };
ASSERT_FALSE(cv_image.empty());
taskManager->run();
- auto results = taskManager->output();
- for (auto &result : results) {
+ for (auto &result : taskManager->output()) {
if (result->_type == ResultType::FACE_DETECTION) {
auto fd_result = dynamic_pointer_cast<FdResultType>(result);
- unsigned int idx = 0;
- for (auto rect : fd_result->_rects) {
- ASSERT_EQ(rect.left, fd_answer[idx][0]);
- ASSERT_EQ(rect.top, fd_answer[idx][1]);
- ASSERT_EQ(rect.right, fd_answer[idx][2]);
- ASSERT_EQ(rect.bottom, fd_answer[idx++][3]);
- }
+ ASSERT_EQ(fd_result->_rects.size(), fd_answer.size());
+
+ unsigned int idx = 0;
+ for (auto &rect : fd_result->_rects)
+ ASSERT_EQ(rect, fd_answer[idx++]);
} else {
auto fld_result = dynamic_pointer_cast<FldResultType>(result);
- unsigned int idx = 0;
- for (auto &point : fld_result->_points) {
- ASSERT_EQ(point.x, fld_answer[idx][0]);
- ASSERT_EQ(point.y, fld_answer[idx++][1]);
- }
+ ASSERT_EQ(fld_result->_points.size(), fld_answer.size());
+
+ unsigned int idx = 0;
+ for (auto &point : fld_result->_points)
+ ASSERT_EQ(point, fld_answer[idx++]);
}
}
auto outputBuffer = make_shared<SharedBuffer>();
- auto &results = callbackNode->results();
- for (auto r : results) {
+ for (auto &r : callbackNode->results()) {
ASSERT_EQ(r->_type, ResultType::OBJECT_DETECTION);
auto obj_r = dynamic_pointer_cast<OdResultType>(r);
- for (auto rect : obj_r->_rects) {
+ for (auto &rect : obj_r->_rects) {
rect.left = max(rect.left, 0);
rect.top = max(rect.top, 0);
rect.right = min(rect.right, static_cast<int>(inputImage->width));
}
}
// Object detection failed so do not go forward.
- if (outputBuffer->getInputs().size() == 0)
+ if (outputBuffer->getInputs().empty())
return;
+
callbackNode->setOutputBuffer(outputBuffer);
}
// -----> object_detection --- -----> image_classification ---------
TEST(SingloTaskManager, MultipleNodesBasedGraphFShouldWork)
{
- const int fld_answer[][2] = { { 243, 133 }, { 404, 135 }, { 347, 197 }, { 250, 266 }, { 385, 266 } };
+ const vector<Point> fld_answer = { { 243, 133 }, { 404, 135 }, { 347, 197 }, { 250, 266 }, { 385, 266 } };
const std::string ic_answer = "Banana";
cv::Mat cv_image[2];
auto fld_result = dynamic_pointer_cast<FldResultType>(result);
unsigned int idx = 0;
- for (auto &point : fld_result->_points) {
- ASSERT_EQ(point.x, fld_answer[idx][0]);
- ASSERT_EQ(point.y, fld_answer[idx++][1]);
- }
+ for (auto &point : fld_result->_points)
+ ASSERT_EQ(point, fld_answer[idx++]);
} else if (result->_type == ResultType::IMAGE_CLASSIFICATION) {
SINGLEO_LOGD("IC result received at endpoint");
auto ic_result = dynamic_pointer_cast<IcResultType>(result);