-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
60 lines (47 loc) · 1.8 KB
/
main.cpp
File metadata and controls
60 lines (47 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <opencv2/imgproc.hpp>
#include <string>
#include <filesystem>
#include <iostream>
#include "BrisqueAlgorithm.hpp"
#define DEFAULT_MODEL_PATH "./models/brisque_model_live.yml"
#define DEFAULT_RANGE_PATH "./models/brisque_range_live.yml"
int main(int ac, char **av) {
if (ac < 2) {
std::cerr << "Usage: " << av[0] << " <image_path> [model_path] [range_path]" << std::endl;
return 1;
}
// Load the input image
std::string imagePath = av[1];
cv::Mat img = cv::imread(imagePath, cv::IMREAD_COLOR);
if (img.empty()) {
std::cerr << "Error: Unable to load image at " << imagePath << std::endl;
return -1;
}
// Determine paths to model and range files
const char* modelPath = (ac > 2) ? av[2] : DEFAULT_MODEL_PATH;
const char* rangePath = (ac > 3) ? av[3] : DEFAULT_RANGE_PATH;
// Check if model and range files exist
if (!std::filesystem::exists(modelPath)) {
std::cerr << "Error: Model file not found at " << modelPath << std::endl;
return -1;
}
if (!std::filesystem::exists(rangePath)) {
std::cerr << "Error: Range file not found at " << rangePath << std::endl;
return -1;
}
// Convert image to grayscale
cv::Mat grayImg;
cv::cvtColor(img, grayImg, cv::COLOR_BGR2GRAY);
// Create a BRISQUE algorithm instance
luxoria::filter::algorithms::BrisqueAlgorithm brisque(modelPath, rangePath);
try {
// Compute BRISQUE score
std::cout << "Computing BRISQUE score..." << std::endl;
double scoreInstance = brisque.compute(grayImg);
std::cout << "BRISQUE Score: " << scoreInstance << std::endl;
} catch (const cv::Exception& e) {
std::cerr << "Error during BRISQUE computation: " << e.what() << std::endl;
return -1;
}
return 0;
}