Hello guys I am doing a program that calculates the eigenvalues and the eigenvectors of an image. For this I am using the OpenCV and Armadillo libraries, with OpenCV I upload the image to my program and with Armadillo I calculate the eigenvalues and the eigenvectors.
I need to convert from cv::Mat to arma::mat to be able to calculate the eigenvalues and eigenvectors, for this I do the following based on a previous answer:
arma::mat arma_mat(reinterpret_cast<double*>(image.data), image.rows, image.cols);
The full code is here:
#include<armadillo>
#include<opencv2/opencv.hpp>
#include<iostream>
int main()
{
cv::Mat image = cv::imread("Imgs/face.jpg", CV_LOAD_IMAGE_GRAYSCALE);
if(!image.data){
std::cout << "No se pudo cargar la imágen\n";
return -1;
}
arma::mat arma_mat(reinterpret_cast<double*>(image.data), image.rows, image.cols);
return 0;
}
The code has no problem compiling, but when it is executed, when it reaches the line where it converts from cv::Mat to arma::mat the execution stops and the console appears (exit value: -1) Does anyone know why this is happening?