Skip to content

Commit

Permalink
AM-75 Implement aquamarine as SOA software (#101)
Browse files Browse the repository at this point in the history
Design concept:

    Implement aquamarine as SOA software, as a component that has exclusive access to images and related calculations
    Use shared memory for messaging.
    Add the possibility of running multiple client(master) applications. Each client may have its own configuration.
    Define interface with Message types.
    Verify cross-platform build.

For developers:

    Add GA build for Windows, Linux, MacOS.
    Integrate into CMake file downloading actual version of the messaging lib.


Briefly tested with silber-1.0, and silber-1.1(actual version) messaging library.
  • Loading branch information
MaksymT17 authored Sep 23, 2024
1 parent f2011bf commit 1b496b7
Show file tree
Hide file tree
Showing 49 changed files with 2,132 additions and 310 deletions.
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

0 comments on commit 1b496b7

Please sign in to comment.