Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AM-75 Implement aquamarine as SOA software #101

Merged
merged 26 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d2e44c1
Add shared memory usage for requesting comparison
Jul 28, 2024
38b5a6b
Changed worklow with validation of requests
Aug 3, 2024
9ad9e06
Make named semaphore dependent on sh_mem name
Aug 4, 2024
ae94c16
Enable multiple Masters mode
Aug 4, 2024
f95a0ce
Apply formating, clientId in COMPARE response
Aug 10, 2024
31cfdbf
Fix compilation fixes Linux
Aug 11, 2024
e648ca6
Fix UT
Aug 11, 2024
d99a65c
Add cross-platform code for semaphore
Aug 11, 2024
8d23312
Respond with CompareFailed on any Am exception of compare
Aug 11, 2024
03eec44
Revert "Add cross-platform code for semaphore"
Aug 17, 2024
c6ac8f4
Add build of shared_mem lib, add UT
Aug 17, 2024
cc0ad58
Port Procummunicator to Windows
Aug 18, 2024
52153c0
Fix ProcCommunicator construction of semaphores
Aug 18, 2024
5fb3b8d
Update Messager UT where server starts first
Aug 18, 2024
82f8519
Fix sh_mem sync issues on Windows platform
Aug 24, 2024
8bc4e7d
Add ackNotify usage, to keep message flow consistent
Aug 25, 2024
77324e2
Replaced silberLib with sendRequestGetResponse usage
Sep 1, 2024
9402fd5
Fix UT and Win build
Sep 1, 2024
84ebf49
Make Configuration as a part of interface type
Sep 3, 2024
091c77e
Move ConnectionsInfo into header & source files
Sep 4, 2024
7cfff36
Add Service with typical message flow
Sep 4, 2024
7e28c17
Update silber-1.0 sources
Sep 8, 2024
927877e
Add upload build, no cloning applied
Sep 20, 2024
b50b285
Download silber lib as debug
Sep 21, 2024
8a9f89d
Remove unsued files
Sep 23, 2024
28403d8
Update master push build with no clone repo cmd
Sep 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

20 changes: 0 additions & 20 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

14 changes: 0 additions & 14 deletions .github/ISSUE_TEMPLATE/optimization-issue-template.md

This file was deleted.

16 changes: 14 additions & 2 deletions .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ jobs:
- uses: actions/checkout@v3
- name: Install packages
run: sudo apt -y install git g++ cmake libsqlite3-dev gcovr libjpeg-dev
- name: Clone aquamarine repo
run: git clone --branch ${{ github.head_ref }} https://github.com/MaksymT17/aquamarine.git

- name: Checkout silber repo
uses: actions/checkout@v3
with:
repository: MaksymT17/aquamarine
ref: ${{ github.head_ref }} # Use the head reference of the pull request
path: aquamarine

- name: Build artifacts with Cmake
run: |
cd aquamarine &&
Expand All @@ -38,3 +44,9 @@ jobs:
with:
check_name: Unit test results
files: "**/test_detail.xml"

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: aquamarine_build_Linux
path: aquamarine/build
16 changes: 13 additions & 3 deletions .github/workflows/build_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ jobs:
run: |
brew install git gcc cmake sqlite3 gcovr jpeg

- name: Clone aquamarine repo
run: git clone --branch ${{ github.head_ref }} https://github.com/MaksymT17/aquamarine.git
- name: Checkout aquamarine repo
uses: actions/checkout@v3
with:
repository: MaksymT17/aquamarine
ref: ${{ github.head_ref }}
path: aquamarine

- name: Build artifacts with Cmake
run: |
Expand All @@ -36,4 +40,10 @@ jobs:
./prepare_build.sh &&
cd build &&
make -j8 &&
./aquamarine_ut
./aquamarine_ut

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: aquamarine_build_MacOS
path: aquamarine/build
27 changes: 20 additions & 7 deletions .github/workflows/build_master_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ jobs:
- uses: actions/checkout@v3
- name: Install packages
run: sudo apt -y install git g++ cmake libsqlite3-dev gcovr libjpeg-dev valgrind lynx
- name: Clone aquamarine repo
run: git clone https://github.com/MaksymT17/aquamarine.git

- name: Checkout aquamarine repo
uses: actions/checkout@v3
with:
repository: MaksymT17/aquamarine
ref: ${{ github.head_ref }}
path: aquamarine

- name: Build artifacts with Cmake
run: |
cd aquamarine &&
Expand Down Expand Up @@ -47,9 +53,12 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Clone aquamarine repo
run: git clone https://github.com/MaksymT17/aquamarine.git
shell: bash
- name: Checkout aquamarine repo
uses: actions/checkout@v3
with:
repository: MaksymT17/aquamarine
ref: ${{ github.head_ref }}
path: aquamarine

- name: Build artifacts with Cmake
run: |
Expand All @@ -75,8 +84,12 @@ jobs:
run: |
brew install git gcc cmake sqlite3 gcovr jpeg

- name: Clone aquamarine repo
run: git clone https://github.com/MaksymT17/aquamarine.git
- name: Checkout aquamarine repo
uses: actions/checkout@v3
with:
repository: MaksymT17/aquamarine
ref: ${{ github.head_ref }}
path: aquamarine

- name: Build artifacts with Cmake
run: |
Expand Down
17 changes: 13 additions & 4 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Clone aquamarine repo
run: git clone --branch ${{ github.head_ref }} https://github.com/MaksymT17/aquamarine.git
shell: bash
- name: Checkout aquamarine repo
uses: actions/checkout@v3
with:
repository: MaksymT17/aquamarine
ref: ${{ github.head_ref }}
path: aquamarine

- name: Build artifacts with Cmake
run: |
Expand All @@ -23,7 +26,13 @@ jobs:
mkdir build &&
echo "preparing new build with cmake..." &&
cd build/ &&
cmake .. &&
cmake -DCMAKE_BUILD_TYPE=Release .. &&
cmake --build . &&
echo "Build complete!"
shell: bash

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: aquamarine_build_Windows
path: aquamarine/build/
42 changes: 19 additions & 23 deletions AmApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,71 +4,67 @@
#include "analyze/algorithm/ImagePair.h"
#include <sstream>

#if defined __unix__ || defined __APPLE__
#ifndef WIN32
#include <jpeglib.h>
#endif
namespace am
{
using namespace common::types;
using namespace analyze;


AmApi::AmApi(const char *conf_path):
loggerPtr(std::make_shared<am::common::Logger>("log.log")),
extractor(loggerPtr)
AmApi::AmApi(const Configuration &conf) : loggerPtr(std::make_shared<am::common::Logger>("log.log")),
extractor(loggerPtr)
{
am::configuration::ConfigurationReader reader;
configuration = reader.getConfigurationFromFile(conf_path);
const size_t opt_threads = am::common::getOptimalThreadsCount(configuration->ThreadsMultiplier);
detector = std::make_unique<algorithm::ObjectDetector>(opt_threads, configuration, loggerPtr) ;
configuration::ConfigurationReader reader;
setConfiguration(conf);
}

algorithm::DescObjects AmApi::compare(const std::string &base_img, const std::string &cmp_img)
{
std::vector<Matrix<Color24b>> data = extractor.readFiles({base_img, cmp_img});

algorithm::ImagePair pair(data[0], data[1]);
return detector->getObjectsRects(pair);
auto res = detector->getObjectsRects(pair);
return res;
}

void AmApi::compare_and_save_diff_img(const std::string &base_img, const std::string &cmp_img, std::string && out_diff_img)
void AmApi::compare_and_save_diff_img(const std::string &base_img, const std::string &cmp_img, std::string &&out_diff_img)
{
const algorithm::DescObjects objects = compare(base_img, cmp_img);
am::extraction::BmpDrawer drawer(base_img);
for (auto& obj : objects)
for (auto &obj : objects)
{
drawer.drawRectangle(obj.getLeft(), obj.getMinHeight(), obj.getRight(),
obj.getMaxHeight());
obj.getMaxHeight());
}

#if defined __unix__ || defined __APPLE__
if(dbcPtr)
#ifndef WIN32
if (dbcPtr)
{
std::stringstream ss;
ss << "'" << am::common::get_datetime() << "', '" << base_img << "', '" << cmp_img << "', " << objects.size();
ss << "'" << am::common::get_datetime() << "', '" << base_img << "', '" << cmp_img << "', " << objects.size();
dbcPtr->add_results_table(); // if already exists - it produces a warning
dbcPtr->insert_records2results({ss.str()});
dbcPtr->insert_records2results({ss.str()});
}
#endif
drawer.save(out_diff_img);
}

void AmApi::enable_database_reports(const char *db_name)
{
#if defined __unix__ || defined __APPLE__
#ifndef WIN32
dbcPtr.reset(new database::DataBaseCommunicator(db_name));
#endif
}

std::shared_ptr<configuration::Configuration> AmApi::getConfiguration()
const Configuration &AmApi::getConfiguration()
{
return configuration;
}

void AmApi::setConfiguration(std::shared_ptr<configuration::Configuration> newConf)
void AmApi::setConfiguration(const Configuration &newConf)
{
configuration = newConf;
const size_t opt_threads = am::common::getOptimalThreadsCount(configuration->ThreadsMultiplier);
detector = std::make_unique<algorithm::ObjectDetector>(opt_threads, configuration, loggerPtr) ;
const size_t opt_threads = am::common::getOptimalThreadsCount(configuration.ThreadsMultiplier);
detector = std::make_unique<algorithm::ObjectDetector>(opt_threads, configuration, loggerPtr);
}
}
13 changes: 7 additions & 6 deletions AmApi.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#pragma once
#include <string>
#include <memory>

#include "extraction/BmpExtractor.h"
#include "configuration/ConfigurationReader.hpp"
#include "common/Logger.hpp"
#include "extraction/MultipleExtractor.h"
#if defined __unix__ || defined __APPLE__
#ifndef WIN32
#include "database/DataBaseCommunicator.h"
#endif

Expand All @@ -14,12 +15,12 @@ namespace am
class AmApi
{
public:
AmApi(const char *conf_path);
AmApi(const Configuration& conf);
analyze::algorithm::DescObjects compare(const std::string &base_img, const std::string &cmp_img);
void compare_and_save_diff_img(const std::string &base_img, const std::string &cmp_img, std::string &&out_diff_img);
void enable_database_reports(const char *db_name);
std::shared_ptr<configuration::Configuration> getConfiguration();
void setConfiguration(std::shared_ptr<configuration::Configuration> newConf);
const Configuration& getConfiguration();
void setConfiguration(const Configuration& newConf);

private:
std::shared_ptr<am::common::Logger> loggerPtr;
Expand All @@ -28,9 +29,9 @@ namespace am

std::string base_img_path;
std::string cmp_img_path;
#if defined __unix__ || defined __APPLE__
#ifndef WIN32
std::unique_ptr<database::DataBaseCommunicator> dbcPtr;
#endif
std::shared_ptr<configuration::Configuration> configuration;
Configuration configuration;
};
}
Loading
Loading