本文整理汇总了C++中Mat1b::clone方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat1b::clone方法的具体用法?C++ Mat1b::clone怎么用?C++ Mat1b::clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat1b
的用法示例。
在下文中一共展示了Mat1b::clone方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nietoLaneMarkingsDetector
void Nieto::nietoLaneMarkingsDetector(Mat1b &srcGRAY, Mat1b &dstGRAY, int tauInicio, int tauFim) {
Mat1b tempDst = Mat1b(srcGRAY.size(), 0);
int aux = 0;
double alturaInicioVariacao = (double)srcGRAY.rows / 2;
double tauTaxaVariacao = double(tauFim - tauInicio) / alturaInicioVariacao;
int tau = tauInicio;
for (int j = 0; j < srcGRAY.rows; ++j) {
unsigned char *ptRowSrc = srcGRAY.ptr<uchar>(j);
unsigned char *ptRowDst = tempDst.ptr<uchar>(j);
if (j > alturaInicioVariacao) tau = int(tauInicio + tauTaxaVariacao * (j - alturaInicioVariacao));
for (int i = tau; i < srcGRAY.cols - tau; ++i) {
unsigned char aux2 = ptRowSrc[i];
if (ptRowSrc[i] != 0) {
aux = 2 * ptRowSrc[i];
aux += -ptRowSrc[i - tau];
aux += -ptRowSrc[i + tau];
aux += -abs((int)(ptRowSrc[i - tau] - ptRowSrc[i + tau]));
aux = (aux < 0) ? 0 : aux;
aux = (aux > 255) ? 255 : aux;
ptRowDst[i] = (unsigned char)aux;
}
}
}
dstGRAY = tempDst.clone();
}
示例2: displayBoolean
void displayBoolean(Mat1b& mat) {
if (!img_widget) {
img_widget = new ImageWidget(0);
img_widget->show();
}
Mat1b dup = mat.clone();
dup *= 255;
img_widget->setImage(dup);
}
示例3: imadjust
void imadjust(const Mat1b& src, Mat1b& dst, int tol = 1, Vec2i in = Vec2i(0, 255), Vec2i out = Vec2i(0, 255))
{
// src : input CV_8UC1 image
// dst : output CV_8UC1 imge
// tol : tolerance, from 0 to 100.
// in : src image bounds
// out : dst image buonds
dst = src.clone();
tol = max(0, min(100, tol));
if (tol > 0)
{
// Compute in and out limits
// Histogram
vector<int> hist(256, 0);
for (int r = 0; r < src.rows; ++r) {
for (int c = 0; c < src.cols; ++c) {
hist[src(r,c)]++;
}
}
// Cumulative histogram
vector<int> cum = hist;
for (int i = 1; i < hist.size(); ++i) {
cum[i] = cum[i - 1] + hist[i];
}
// Compute bounds
int total = src.rows * src.cols;
int low_bound = total * tol / 100;
int upp_bound = total * (100-tol) / 100;
in[0] = distance(cum.begin(), lower_bound(cum.begin(), cum.end(), low_bound));
in[1] = distance(cum.begin(), lower_bound(cum.begin(), cum.end(), upp_bound));
}
// Stretching
float scale = float(out[1] - out[0]) / float(in[1] - in[0]);
for (int r = 0; r < dst.rows; ++r)
{
for (int c = 0; c < dst.cols; ++c)
{
int vs = max(src(r, c) - in[0], 0);
int vd = min(int(vs * scale + 0.5f) + out[0], out[1]);
dst(r, c) = saturate_cast<uchar>(vd);
}
}
}
示例4: skeleton
Mat1b Helper::skeleton(const Mat1b &binaryImage, const int size) {
Mat1b img = binaryImage.clone();
Mat skel(img.size(), CV_8UC1, Scalar(0));
Mat temp;
Mat eroded;
Mat element = getStructuringElement(MORPH_CROSS, cv::Size(size, size));
bool done;
do {
erode(img, eroded, element);
dilate(eroded, temp, element); // temp = open(img)
subtract(img, temp, temp);
bitwise_or(skel, temp, skel);
eroded.copyTo(img);
done = (countNonZero(img) == 0);
} while (!done);
return skel;
}
示例5: max
void xyVision::GetTarget::imadjust(const Mat1b& src, Mat1b& dst, int tol, Vec2i in, Vec2i out)
{
dst = src.clone();
tol = max(0, min(100, tol));
if (tol > 0)
{
// Compute in and out limits
// Histogram
vector<int> hist(256, 0);
for (int r = 0; r < src.rows; ++r) {
for (int c = 0; c < src.cols; ++c) {
hist[src(r,c)]++;
}
}
// Cumulative histogram
vector<int> cum = hist;
for (int i = 1; i < (int)hist.size(); ++i) {
cum[i] = cum[i - 1] + hist[i];
}
// Compute bounds
int total = src.rows * src.cols;
int low_bound = total * tol / 100;
int upp_bound = total * (100-tol) / 100;
in[0] = distance(cum.begin(), lower_bound(cum.begin(), cum.end(), low_bound));
in[1] = distance(cum.begin(), lower_bound(cum.begin(), cum.end(), upp_bound));
}
// Stretching
float scale = float(out[1] - out[0]) / float(in[1] - in[0]);
for (int r = 0; r < dst.rows; ++r)
{
for (int c = 0; c < dst.cols; ++c)
{
int vs = max(src(r, c) - in[0], 0);
int vd = min(int(vs * scale + 0.5f) + out[0], out[1]);
dst(r, c) = saturate_cast<uchar>(vd);
}
}
}
示例6: I_armaSamples
void Nieto::ExpectationMaximizationArmadillo2Features(const Mat1b &imageI, const Mat1b &imageL,
map<string, double> &i_means0, map<string, double> &i_covs0, map<string, double> &i_weights0,
map<string, double> &l_means0, map<string, double> &l_covs0, map<string, double> &l_weights0, int maxIters) {
double tempoInicio = static_cast<double>(getTickCount());
const int nClusters = 4; // 4 classes => {pavement, markings, objects, unknown}
bool aplicaResize = true;
// samples feature I
Mat1b I_imageClone = imageI.clone();
Mat1b I_trainImageClone = imageI.clone();
if (aplicaResize) resize(I_imageClone, I_trainImageClone, Size(160, 35), 0, 0, INTER_NEAREST);
Mat1d I_samples = I_trainImageClone.reshape(1, I_trainImageClone.rows * I_trainImageClone.cols);
arma::mat I_armaSamples(reinterpret_cast<double*>(I_samples.data), I_samples.rows, I_samples.cols);
// samples feature L
Mat1b L_imageClone = imageL.clone();
Mat1b L_trainImageClone = imageL.clone();
if (aplicaResize) resize(L_imageClone, L_trainImageClone, Size(160, 35), 0, 0, INTER_NEAREST);
Mat1d L_samples = L_trainImageClone.reshape(1, L_trainImageClone.rows * L_trainImageClone.cols);
arma::mat L_armaSamples(reinterpret_cast<double*>(L_samples.data), L_samples.rows, L_samples.cols);
// junta as amostras (uma em cada linha)
arma::mat armaSamples = arma::join_rows(I_armaSamples, L_armaSamples);
// cout << "size armaSamples: " << arma::size(armaSamples.t()) << endl;
// formata o _means0
arma::mat means0(2, nClusters);
means0.at(0, 0) = i_means0["pavement"];
means0.at(0, 1) = i_means0["markings"];
means0.at(0, 2) = i_means0["objects"];
means0.at(0, 3) = 255.0 / 2.0;
means0.at(1, 0) = l_means0["pavement"];
means0.at(1, 1) = l_means0["markings"];
means0.at(1, 2) = l_means0["objects"];
means0.at(1, 3) = 255.0 / 2.0;
// cout << "size means0: " << arma::size(means0) << endl;
// formata o _covs0
arma::mat covs0(2, nClusters);
covs0.at(0, 0) = i_covs0["pavement"];
covs0.at(0, 1) = i_covs0["markings"];
covs0.at(0, 2) = i_covs0["objects"];
covs0.at(0, 3) = ((255.0 / 2.0) / sqrt(3)) * ((255.0 / 2.0) / sqrt(3));
covs0.at(1, 0) = l_covs0["pavement"];
covs0.at(1, 1) = l_covs0["markings"];
covs0.at(1, 2) = l_covs0["objects"];
covs0.at(1, 3) = ((255.0 / 2.0) / sqrt(3)) * ((255.0 / 2.0) / sqrt(3));
// cout << "size covs0: " << arma::size(covs0) << endl;
// formata o _weights0
arma::mat weights0(1, nClusters);/*
double total_i = i_weights0["pavement"] + i_weights0["markings"] + i_weights0["objects"] + i_weights0["unknown"];
double total_l = l_weights0["pavement"] + l_weights0["markings"] + l_weights0["objects"] + l_weights0["unknown"];
double total_weights = total_i + total_l;
weights0.at(0, 0) = (i_weights0["pavement"] + l_weights0["pavement"]) / total_weights;
weights0.at(0, 1) = (i_weights0["markings"] + l_weights0["markings"]) / total_weights;
weights0.at(0, 2) = (i_weights0["objects"] + l_weights0["objects"]) / total_weights;
weights0.at(0, 3) = (i_weights0["unknown"] + l_weights0["unknown"]) / total_weights;
*/
double total_i = i_weights0["pavement"] + i_weights0["objects"] + i_weights0["unknown"] + l_weights0["markings"];
weights0.at(0, 0) = i_weights0["pavement"] / total_i;
weights0.at(0, 1) = l_weights0["markings"] / total_i;
weights0.at(0, 2) = i_weights0["objects"] / total_i;
weights0.at(0, 3) = i_weights0["unknown"] / total_i;
// cout << "size weights0: " << arma::size(weights0) << endl;
weights0.at(0, 0) = trunc(weights0.at(0, 0) * 1000) / 1000;
weights0.at(0, 1) = trunc(weights0.at(0, 1) * 1000) / 1000;
weights0.at(0, 2) = trunc(weights0.at(0, 2) * 1000) / 1000;
weights0.at(0, 3) = trunc(weights0.at(0, 3) * 1000) / 1000;
double diff = 1 - (weights0.at(0, 0) + weights0.at(0, 1) + weights0.at(0, 2) + weights0.at(0, 3));
weights0.at(0, 3) += diff;
// if (!(size(means0) != size(covs0))) cout << "1 - ok!" << endl;
// if (!(weights0.n_cols != means0.n_cols)) cout << "2 - ok!" << endl;
// if (!(weights0.n_rows != 1)) cout << "3 - ok!" << endl;
arma::gmm_diag em;
em.set_params(means0, covs0, weights0);
em.means.print("means a: ");
em.dcovs.print("dcovs a: ");
em.hefts.print("hefts a: ");
em.learn(armaSamples.t(), nClusters, arma::eucl_dist, arma::keep_existing, 0, 1000, 1e-10, false);
em.means.print("means b: ");
em.dcovs.print("dcovs b: ");
em.hefts.print("hefts b: ");
// calcula o tempo de execu��o
double tempoFim = static_cast<double>(getTickCount());
double tempoExecutando = ((tempoFim - tempoInicio) / getTickFrequency()) * 1000;
// exibe as sa�das definidas (texto e/ou imagem)
if (verbose) cout << "- em armadillo (2 features): " << tempoExecutando << " ms" << endl;
if (display) {
// predict
Mat1b predictedImage = Mat1b(imageI.size(), uchar(0));
for (int j = 0; j < predictedImage.rows; ++j) {
unsigned char *ptRowI = I_imageClone.ptr<uchar>(j);
//.........这里部分代码省略.........
示例7: ExpectationMaximizationArmadillo
void Nieto::ExpectationMaximizationArmadillo(const Mat1b &inGrayFrameRoi, int maxIters, map<string, double> &_means0, map<string, double> &_covs0, map<string, double> &_weights0) {
double tempoInicio = static_cast<double>(getTickCount());
const int nClusters = 4; // 4 classes => {pavement, markings, objects, unknown}
Mat1b grayFrameRoiClone = inGrayFrameRoi.clone();
Mat1b trainGrayFrameRoiClone = inGrayFrameRoi.clone();
resize(grayFrameRoiClone, trainGrayFrameRoiClone, Size(160, 35), 0, 0, INTER_NEAREST);
Mat1d samples = trainGrayFrameRoiClone.reshape(1, trainGrayFrameRoiClone.rows * trainGrayFrameRoiClone.cols);
arma::mat armaSamples(reinterpret_cast<double*>(samples.data), samples.rows, samples.cols);
// cout << "size armaSamples: " << arma::size(armaSamples) << endl;
// formata o _means0
arma::mat means0(1, nClusters);
means0.at(0, 0) = _means0["pavement"];
means0.at(0, 1) = _means0["markings"];
means0.at(0, 2) = _means0["objects"];
means0.at(0, 3) = 255.0 / 2.0;
// cout << "size means0: " << arma::size(means0) << endl;
// formata o _covs0
arma::mat covs0(1, nClusters);
covs0.at(0, 0) = _covs0["pavement"];
covs0.at(0, 1) = _covs0["markings"];
covs0.at(0, 2) = _covs0["objects"];
covs0.at(0, 3) = ((255.0 / 2.0) / sqrt(3)) * ((255.0 / 2.0) / sqrt(3));
// cout << "size covs0: " << arma::size(covs0) << endl;
// formata o _weights0
arma::mat weights0(1, nClusters);
weights0.at(0, 0) = _weights0["pavement"];
weights0.at(0, 1) = _weights0["markings"];
weights0.at(0, 2) = _weights0["objects"];
weights0.at(0, 3) = _weights0["unknown"];
// cout << "size weights0: " << arma::size(weights0) << endl;
// if (!(size(means0) != size(covs0))) cout << "1 - ok!" << endl;
// if (!(weights0.n_cols != means0.n_cols)) cout << "2 - ok!" << endl;
// if (!(weights0.n_rows != 1)) cout << "3 - ok!" << endl;
arma::gmm_diag em;
em.set_params(means0, covs0, weights0);
em.learn(armaSamples.t(), nClusters, arma::eucl_dist, arma::keep_existing, 0, maxIters, 1e-10, false);
// calcula o tempo de execu��o
double tempoFim = static_cast<double>(getTickCount());
double tempoExecutando = ((tempoFim - tempoInicio) / getTickFrequency()) * 1000;
// exibe as sa�das definidas (texto e/ou imagem)
if (verbose) cout << "- em armadillo (1 feature): " << tempoExecutando << " ms" << endl;
if (display) {
// predict
Mat1b predictedImage = Mat1b(grayFrameRoiClone.size(), uchar(0));
for (int j = 0; j < predictedImage.rows; ++j) {
unsigned char *ptRowSrc = grayFrameRoiClone.ptr<uchar>(j);
unsigned char *ptRowDst = predictedImage.ptr<uchar>(j);
for (int i = 0; i < predictedImage.cols; ++i) {
arma::vec v;
v << ptRowSrc[i];
int emPredicted = em.assign(v, arma::eucl_dist);
switch (emPredicted) {
case 0: ptRowDst[i] = 160; break;
case 1: ptRowDst[i] = 255; break;
case 2: ptRowDst[i] = 80; break;
case 3: ptRowDst[i] = 0; break;
}
}
}
imshow("EM Armadillo - 1 Feature", predictedImage);
}
}
示例8: double
void Nieto::ExpectationMaximizationOpenCV2Features(const Mat1b &imageI, const Mat1b &imageL,
map<string, double> &i_means0, map<string, double> &i_covs0, map<string, double> &i_weights0,
map<string, double> &l_means0, map<string, double> &l_covs0, map<string, double> &l_weights0, int maxIters) {
double tempoInicio = static_cast<double>(getTickCount());
const int nFeatures = 2; // 2 features => {I, L}
const int nClusters = 4; // 4 classes => {pavement, markings, objects, unknown}
const bool aplicaResize = true;
// samples feature I
Mat1b I_imageClone = imageI.clone();
Mat1b I_trainImageClone = imageI.clone();
if (aplicaResize) resize(I_imageClone, I_trainImageClone, Size(160, 35), 0, 0, INTER_NEAREST);
Mat1d I_samples = I_trainImageClone.reshape(1, I_trainImageClone.rows * I_trainImageClone.cols);
// samples feature L
Mat1b L_imageClone = imageL.clone();
Mat1b L_trainImageClone = imageL.clone();
if (aplicaResize) resize(L_imageClone, L_trainImageClone, Size(160, 35), 0, 0, INTER_NEAREST);
Mat1d L_samples = L_trainImageClone.reshape(1, L_trainImageClone.rows * L_trainImageClone.cols);
// junta as amostras (uma em cada linha)
Mat1d samplesArray[] = { I_samples, L_samples };
Mat1d samples;
cv::hconcat(samplesArray, 2, samples);
// formata o _means0
Mat1d means0 = Mat1d(nClusters, nFeatures, CV_64FC1);
means0.at<double>(0, 0) = i_means0["pavement"];
means0.at<double>(1, 0) = i_means0["markings"];
means0.at<double>(2, 0) = i_means0["objects"];
means0.at<double>(3, 0) = 255.0 / 2.0;
means0.at<double>(0, 1) = l_means0["pavement"];
means0.at<double>(1, 1) = l_means0["markings"];
means0.at<double>(2, 1) = l_means0["objects"];
means0.at<double>(3, 1) = 255.0 / 2.0;
// formata o _covs0
Mat1d covs0_pavement = Mat1d(Size(nFeatures, nFeatures), double(0));
covs0_pavement.at<double>(0, 0) = i_covs0["pavement"];
covs0_pavement.at<double>(1, 1) = l_covs0["pavement"];
Mat1d covs0_markings = Mat1d(Size(nFeatures, nFeatures), double(0));;
covs0_markings.at<double>(0, 0) = i_covs0["markings"];
covs0_markings.at<double>(1, 1) = l_covs0["markings"];
Mat1d covs0_objects = Mat1d(Size(nFeatures, nFeatures), double(0));;
covs0_objects.at<double>(0, 0) = i_covs0["objects"];
covs0_objects.at<double>(1, 1) = l_covs0["objects"];
Mat1d covs0_unknown = Mat1d(Size(nFeatures, nFeatures), double(0));;
covs0_unknown.at<double>(0, 0) = ((255.0 / 2.0) / sqrt(3)) * ((255.0 / 2.0) / sqrt(3));
covs0_unknown.at<double>(1, 1) = ((255.0 / 2.0) / sqrt(3)) * ((255.0 / 2.0) / sqrt(3));
vector<Mat> covs0 = {
covs0_pavement,
covs0_markings,
covs0_objects,
covs0_unknown
};
// formata o _weights0
Mat1d weights0 = Mat1d(nClusters, 1, CV_64FC1);
double total_i = i_weights0["pavement"] + i_weights0["markings"] + i_weights0["objects"] + i_weights0["unknown"];
double total_l = l_weights0["pavement"] + l_weights0["markings"] + l_weights0["objects"] + l_weights0["unknown"];
double total_weights = total_i + total_l;
weights0.at<double>(0, 0) = (i_weights0["pavement"] + l_weights0["pavement"]) / total_weights;
weights0.at<double>(1, 0) = (i_weights0["markings"] + l_weights0["markings"]) / total_weights;
weights0.at<double>(2, 0) = (i_weights0["objects"] + l_weights0["objects"]) / total_weights;
weights0.at<double>(3, 0) = (i_weights0["unknown"] + l_weights0["unknown"]) / total_weights;
// cout << means0 << endl;
// condi��es do EM
// dims => samples.cols
// if (!(&means0) || (!means0.empty() && means0.rows == nClusters && means0.cols == samples.cols && means0.channels() == 1)) cout << "means - ok!" << endl;
EM em = EM(nClusters, EM::COV_MAT_DIAGONAL);
em.set("maxIters", maxIters);
em.trainE(samples, means0, covs0, weights0);
// calcula o tempo de execu��o
double tempoFim = static_cast<double>(getTickCount());
double tempoExecutando = ((tempoFim - tempoInicio) / getTickFrequency()) * 1000;
// exibe as sa�das definidas (texto e/ou imagem)
if (verbose) cout << "- em opencv (2 features): " << tempoExecutando << " ms" << endl;
if (display) {
// predict
Mat1b predictedImage = Mat1b(I_imageClone.size(), uchar(0));
for (int j = 0; j < predictedImage.rows; ++j) {
unsigned char *ptRowI = I_imageClone.ptr<uchar>(j);
unsigned char *ptRowL = L_imageClone.ptr<uchar>(j);
unsigned char *ptRowDst = predictedImage.ptr<uchar>(j);
for (int i = 0; i < predictedImage.cols; ++i) {
Mat1d elementPredict = Mat1d(Size(2, 1), CV_64FC1);
elementPredict.at<double>(0) = ptRowL[i];
elementPredict.at<double>(1) = ptRowI[i];
Vec2d emPredicted = em.predict(elementPredict);
switch ((int)emPredicted[1]) {
case 0: ptRowDst[i] = 160; break;
case 1: ptRowDst[i] = 255; break;
//.........这里部分代码省略.........
示例9: ExpectationMaximizationOpenCV
void Nieto::ExpectationMaximizationOpenCV(const Mat1b &inGrayFrameRoi, int maxIters, map<string, double> &_means0, map<string, double> &_covs0, map<string, double> &_weights0) {
double tempoInicio = static_cast<double>(getTickCount());
const int nClusters = 4; // 4 classes => {pavement, markings, objects, unknown}
const bool aplicaResize = true;
EM em = EM(nClusters, EM::COV_MAT_DIAGONAL);
Mat1b grayFrameRoiClone = inGrayFrameRoi.clone();
Mat1b trainGrayFrameRoiClone = inGrayFrameRoi.clone();
if (aplicaResize) resize(grayFrameRoiClone, trainGrayFrameRoiClone, Size(160, 35), 0, 0, INTER_NEAREST);
Mat1d samples = trainGrayFrameRoiClone.reshape(1, trainGrayFrameRoiClone.rows * trainGrayFrameRoiClone.cols);
// formata o _means0
Mat1d means0 = Mat1d(nClusters, 1, CV_64FC1);
means0.at<double>(0) = _means0["pavement"];
means0.at<double>(1) = _means0["markings"];
means0.at<double>(2) = _means0["objects"];
means0.at<double>(3) = 255.0 / 2.0;
// formata o _covs0
vector<Mat> covs0 = {
Mat1d(1, 1, _covs0["pavement"]),
Mat1d(1, 1, _covs0["markings"]),
Mat1d(1, 1, _covs0["objects"]),
Mat1d(1, 1, ((255.0 / 2.0) / sqrt(3)) * ((255.0 / 2.0) / sqrt(3)))
};
// formata o _weights0
// Mat1d weights0 = *(Mat1f(nClusters, 1, CV_64FC1) << 0.75, 0.10, 0.10, 0.05);
Mat1d weights0 = *(Mat1f(nClusters, 1, CV_64FC1) <<
_weights0["pavement"],
_weights0["markings"],
_weights0["objects"],
_weights0["unknown"]
);
// cout << means0 << endl;
em.set("maxIters", maxIters);
em.trainE(samples, means0, covs0, weights0);
// calcula o tempo de execu��o
double tempoFim = static_cast<double>(getTickCount());
double tempoExecutando = ((tempoFim - tempoInicio) / getTickFrequency()) * 1000;
// exibe as sa�das definidas (texto e/ou imagem)
if (verbose) cout << "- em opencv (1 feature): " << tempoExecutando << " ms" << endl;
if (display) {
// predict
Mat1b predictedImage = Mat1b(grayFrameRoiClone.size(), uchar(0));
for (int j = 0; j < predictedImage.rows; ++j) {
unsigned char *ptRowSrc = grayFrameRoiClone.ptr<uchar>(j);
unsigned char *ptRowDst = predictedImage.ptr<uchar>(j);
for (int i = 0; i < predictedImage.cols; ++i) {
Vec2d emPredicted = em.predict(ptRowSrc[i]);
switch ((int)emPredicted[1]) {
case 0: ptRowDst[i] = 160; break;
case 1: ptRowDst[i] = 255; break;
case 2: ptRowDst[i] = 80; break;
case 3: ptRowDst[i] = 0; break;
}
}
}
imshow("EM OpenCV - 1 Feature", predictedImage);
}
}
示例10: featureL_IPM
void Nieto::featureL_IPM(const Mat1b &inGrayFrameFiltradoRoi, IPM * _ipm, map<string, double> &outMeans0, map<string, double> &outCovs0, map<string, double> &outWeights0) {
double tempoInicio = static_cast<double>(getTickCount());
Size imgSize = inGrayFrameFiltradoRoi.size();
// Imagens que ser�o constru�das
Mat1b _binaryMarkings = Mat1b(imgSize, uchar(0));
Mat1b _binaryPavement = Mat1b(imgSize, uchar(0));
Mat1b binaryMarkings = Mat1b(imgSize, uchar(0)); // NA IPM
Mat1b binaryPavement = Mat1b(imgSize, uchar(0)); // NA IPM
// pega o threshold inicial que separa as duas gaussianas (Pavement < thres < LaneMarkings)
// Nieto: A reasonable threshold that separates these two components is the standard deviation
Scalar meanFiltro, stddevFiltro;
cv::meanStdDev(inGrayFrameFiltradoRoi, meanFiltro, stddevFiltro);
// seta as m�scaras dos elementos que pertecem a mabas as classes
_binaryMarkings = inGrayFrameFiltradoRoi > stddevFiltro[0];
_binaryPavement = inGrayFrameFiltradoRoi <= stddevFiltro[0];
_ipm->applyHomography(_binaryMarkings, binaryMarkings, INTER_NEAREST);
_ipm->applyHomography(_binaryPavement, binaryPavement, INTER_NEAREST);
map<string, Scalar> meansScalar, stddevScalar;
// ************************************** PAVEMENT
cv::meanStdDev(inGrayFrameFiltradoRoi, meansScalar["pavement"], stddevScalar["pavement"], _binaryPavement);
outMeans0["pavement"] = getMean(inGrayFrameFiltradoRoi, _binaryPavement);
outCovs0["pavement"] = getVariance(inGrayFrameFiltradoRoi.clone(), outMeans0["pavement"], _binaryPavement);
// ************************************** LANE MARKINGS
cv::meanStdDev(inGrayFrameFiltradoRoi, meansScalar["markings"], stddevScalar["markings"], _binaryMarkings);
outMeans0["markings"] = getMean(inGrayFrameFiltradoRoi, _binaryMarkings);
outCovs0["markings"] = getVariance(inGrayFrameFiltradoRoi.clone(), outMeans0["markings"], _binaryMarkings);
// ************************************** OBJECTS
outMeans0["objects"] = outMeans0["pavement"];
outCovs0["objects"] = outCovs0["pavement"];
// ************************************** UNKNOWN
outMeans0["unknown"] = 255.0 / 2.0;
outCovs0["unknown"] = ((255.0 / 2.0) / sqrt(3)) * ((255.0 / 2.0) / sqrt(3));
// calcula os pesos => propor��o de cada classe
double nPavements = countNonZero(binaryPavement);
double nMarkings = countNonZero(binaryMarkings);
double nTotal = nPavements + nMarkings;
double nUnknown = nTotal * 0.05;
nTotal += nUnknown;
outWeights0["pavement"] = (nPavements / 2) / nTotal;
outWeights0["objects"] = outWeights0["pavement"];
outWeights0["markings"] = nMarkings / nTotal;
outWeights0["unknown"] = nUnknown / nTotal;
// calcula o tempo de execu��o
double tempoFim = static_cast<double>(getTickCount());
double tempoExecutando = ((tempoFim - tempoInicio) / getTickFrequency()) * 1000;
// exibe as sa�das definidas (texto e/ou imagem)
if (verbose) cout << "- nieto.featureL: " << tempoExecutando << " ms" << endl;
// if (config.display)
// imshow("L - binaryMarkings", binaryMarkings);
// imshow("L - binaryPavement", binaryPavement);
/*
if (display) {
Mat1b imgResultNietoMasks = Mat1b(Size(grayFrameRoiIPM.cols, grayFrameRoiIPM.rows * 4), uchar(0));
grayPavement.copyTo(imgResultNietoMasks(Rect(0, 0, grayFrameRoiIPM.cols, grayFrameRoiIPM.rows)));
grayMarkings.copyTo(imgResultNietoMasks(Rect(0, grayFrameRoiIPM.rows, grayFrameRoiIPM.cols, grayFrameRoiIPM.rows)));
grayObjects.copyTo(imgResultNietoMasks(Rect(0, 2 * grayFrameRoiIPM.rows, grayFrameRoiIPM.cols, grayFrameRoiIPM.rows)));
imgResultNietoMasks(Rect(0, 3 * grayFrameRoiIPM.rows, grayFrameRoiIPM.cols, grayFrameRoiIPM.rows)).setTo(85, binaryPavement);
imgResultNietoMasks(Rect(0, 3 * grayFrameRoiIPM.rows, grayFrameRoiIPM.cols, grayFrameRoiIPM.rows)).setTo(170, binaryObjects);
imgResultNietoMasks(Rect(0, 3 * grayFrameRoiIPM.rows, grayFrameRoiIPM.cols, grayFrameRoiIPM.rows)).setTo(255, binaryMarkings);
imgResultNietoMasks(Rect(0, 3 * grayFrameRoiIPM.rows, grayFrameRoiIPM.cols, grayFrameRoiIPM.rows)).setTo(0, binaryUnknown);
imshow("Nieto - Mascaras", imgResultNietoMasks);
// imshow("binaryIpmInvMask", binaryIpmInvMask);
// descomente para visualizar o que foi calculado para o Pavement
// imshow("grayPavement", grayPavement);
// imshow("binaryPavement", binaryPavement);
// cout << "p.mean: " << means0["pavement"] << ", p.covs: " << covs0["pavement"] << endl;
// descomente para visualizar o que foi calculado para os Lane Markings
// imshow("grayMarkings", grayMarkings);
// imshow("binaryMarkings", binaryMarkings);
// cout << "lm.mean: " << means0["markings"] << ", lm.covs: " << covs0["markings"] << endl;
// descomente para visualizar o que foi calculado para os Objects
// imshow("grayObjects", grayObjects);
// imshow("binaryObjects", binaryObjects);
// cout << "obj.mean: " << means0["objects"] << ", obj.covs: " << covs0["objects"] << endl;
// descomente para visualizar o que foi calculado para o Unknown
//.........这里部分代码省略.........