voglio testare una funzione che è alla ricerca di specifiche profondità mat & & numero di canaliImpostazione di profondità per un cv :: Mat
E 'un test ...
if (image.channels() == 1 && image.depth() == 8) ...
else if (image.channels() == 1 && image.depth() == 16) ...
else if (image.channels() == 1 && image.depth() == 32) ...
else
{
if ((image.channels() != 3) || (image.depth() != 8))
{printf("Expecting rgb24 input image"); return false;}
...
}
preferisco per testare con un tappetino truccata, per evitare l'uso di risorse locali:
cv::Mat M(255, 255, CV_8UC3, cv::Scalar(0,0,255));
printf("M: %d %d \n", M.channels(), M.depth());
cv::Mat M1(255, 255, CV_32F, cv::Scalar(0,0,255));
cv::Mat M2(255, 255, CV_32FC3, cv::Scalar(0,0,255));
cv::Mat M2(255, 255, CV_8SC3, cv::Scalar(0,0,255));
ho sperimentato con tutti i tipi di combinazioni, ma se stampo, ottengo 0 profondità.
Ho anche cercato di caricare un png o un file jpg - con lo stesso risultato (preferisco non usare i file al di fuori ... ma non vedo alcun motivo per cui questo non funziona)
cv::Mat M3 = cv::imread("c:/my_image.png", CV_LOAD_IMAGE_COLOR);
cv::Mat M3 = cv::imread("c:/my_image.jpg", CV_LOAD_IMAGE_COLOR);
Sembrano tutti avere profondità = 0?
C'è qualcos'altro che devo fare? Non riesco a vedere nulla nella documentazione ...
Grazie
Quindi ... il test nella funzione è sbagliato allora. .. L'ho cambiato dalla versione c in cui era se (image-> nChannels == 1 && image-> depth == 8) e così via – Thalia
sì, l'interfaccia C++ è diversa, ecco l'ultima documentazione sulla profondità (): http://docs.opencv.org/modules/core/doc/basic_structures.html#mat-depth – cxyzs7