AI Watch A1
Multi-person 3D skeleton detection using Intel RealSense and OpenPose with Kafka support.
ImageManager.cpp
Go to the documentation of this file.
1//
2// ImageManager.cpp
3// AI Watch A1
4//
5// Created by Denny Caruso on 30/07/22.
6//
7
8// License: Apache 2.0. See LICENSE file in root directory.
9// Copyright(c) 2022. All Rights Reserved.
10
11#include "ImageManager.hpp"
12
13
14
15void ImageManager::saveImage (std::string imageSavePath, const cv::Mat & imageToSave) {
16 if (!(cv::imwrite(imageSavePath, imageToSave))) CV_Error(SAVE_IMAGE_ERROR, SAVE_IMAGE_SCOPE);
17}
18
19
20
21void ImageManager::loadImage(std::string imagePath, int loadType, cv::Mat & inputImage) {
22 inputImage = cv::imread(imagePath, loadType);
23 if (inputImage.empty()) {
24 std::cout << "IMAGE NOT FOUND: " << imagePath << "\n";
26 }
27}
28
29void ImageManager::saveImages (const std::initializer_list <cv::Mat> & images, const std::initializer_list <std::string> & imagePaths) {
30 auto imagesIterator = images.begin();
31 auto imagePathsIterator = imagePaths.begin();
32 for (unsigned char i = 0; i < images.size(); i++) {
33 saveImage(* imagePathsIterator, * imagesIterator);
34 imagePathsIterator++;
35 imagesIterator++;
36 }
37}
38
39void ImageManager::showImages (const std::initializer_list <cv::Mat> & images, const std::initializer_list <std::string> & windowNames) {
40 auto imagesIterator = images.begin();
41 auto windowNamesIterator = windowNames.begin();
42 for (unsigned char i = 0; i < images.size(); i++) {
43 cv::imshow(* windowNamesIterator, * imagesIterator);
44 windowNamesIterator++;
45 imagesIterator++;
46 }
47 cv::waitKey(1);
48}
49
50void ImageManager::releaseImages (const std::initializer_list <cv::Mat> & images) {
51 for (auto singleImage : images) singleImage.release();
52}
void showImages(const std::initializer_list< cv::Mat > &images, const std::initializer_list< std::string > &windowNames)
Shows multiple images.
void releaseImages(const std::initializer_list< cv::Mat > &images)
Releases multiple images.
void saveImage(std::string imageSavePath, const cv::Mat &imageToSave)
Saves a single image.
void saveImages(const std::initializer_list< cv::Mat > &images, const std::initializer_list< std::string > &imagePaths)
Saves multiple images.
void loadImage(std::string imagePath, int loadType, cv::Mat &inputImage)
Loads a single image.
static const char * LOAD_IMAGE_SCOPE
Definition: constants.hpp:21
static const short int SAVE_IMAGE_ERROR
Definition: constants.hpp:23
static const short int LOAD_IMAGE_ERROR
Definition: constants.hpp:20
static const char * SAVE_IMAGE_SCOPE
Definition: constants.hpp:24