22#include "jkqtplotter/jkqtpdatastorage.h"
23#include <opencv2/core.hpp>
25#ifndef JKQTPINTERFACEOPENCV_H
26#define JKQTPINTERFACEOPENCV_H
51 template <
typename TPixel>
54 const int channels=mat.channels();
55 for (
int iy=0; iy<mat.rows; iy++ ) {
56 const TPixel* row=mat.ptr<TPixel>(iy);
57 for (
int ix=0; ix<mat.cols; ix++ ) {
58 data[r]=
jkqtp_todouble(*
static_cast<const TPixel*
>(&(row[ix*channels+channel])));
67 const size_t N=
static_cast<size_t>(mat.cols*mat.rows);
68 double* d=
static_cast<double*
>(malloc(
static_cast<size_t>(N)*
sizeof(
double)));
70 if (CV_MAT_DEPTH(mat.type())==CV_64F) JKQTPDatastore_Helper::copyDataFromMat<double>(d, mat, channel);
71 else if (CV_MAT_DEPTH(mat.type())==CV_32F) JKQTPDatastore_Helper::copyDataFromMat<float>(d, mat, channel);
72 else if (CV_MAT_DEPTH(mat.type())==CV_32S) JKQTPDatastore_Helper::copyDataFromMat<uint32_t>(d, mat, channel);
73 else if (CV_MAT_DEPTH(mat.type())==CV_16S) JKQTPDatastore_Helper::copyDataFromMat<int16_t>(d, mat, channel);
74 else if (CV_MAT_DEPTH(mat.type())==CV_16U) JKQTPDatastore_Helper::copyDataFromMat<uint16_t>(d, mat, channel);
75 else if (CV_MAT_DEPTH(mat.type())==CV_8S) JKQTPDatastore_Helper::copyDataFromMat<int8_t>(d, mat, channel);
76 else if (CV_MAT_DEPTH(mat.type())==CV_8U) JKQTPDatastore_Helper::copyDataFromMat<uint8_t>(d, mat, channel);
77 else throw std::runtime_error(
"datatype of cv::Mat not supported by JKQTPDatastore::copyImageToColumn()");
This class manages data columns (with entries of type double ), used by JKQTPlotter/JKQTBasePlotter t...
Definition jkqtpdatastorage.h:282
size_t addInternalImageColumn(double *data, size_t width, size_t height, const QString &name)
add a column with width * height entries from the array data, ownership of the memory behind data is ...
void copyDataFromMat(double *data, const cv::Mat &mat, int channel)
internal helper function for JKQTPCopyCvMatToColumn()
Definition jkqtpinterfaceopencv.h:52
size_t JKQTPCopyCvMatToColumn(JKQTPDatastore *datastore, const cv::Mat &mat, const QString &name=QString(""), int channel=0)
add one external column to the datastore. It will be filled with the contents of CImg matrix cv::Mat
Definition jkqtpinterfaceopencv.h:65
Definition jkqtpinterfaceopencv.h:47