Mat
함수에 a 를 전달 하려고 float
하는데 이미지 데이터 를 가져 오려고 할 때 오류가 발생 합니다. 누군가가 잘못된 점을 알려줄 수 있습니까?
int _tmain(int argc, _TCHAR* argv[])
{
cv::Mat img;//gradients from fingerprint image
cv::Mat dst;
bh2Rad(&img,&dst);
}
void bh2Rad(Mat* srcMat,cv::Mat* dstMat)
{
for (int i=0; i < srcMat->rows ;i++)
{
float* srcP = srcMat->data.fl + srcMat->width * i;// srcMat Error.
float* dstP = dstMat->data.fl + dstMat->width * i;//dstMat Error
for (int j = 0; j < srcMat->cols ;j++)
dstP[j] = srcP[j] * BH_DEG_TO_RAD;
}
}
이전 (c-api) CvMat과 cv :: Mat을 픽셀 연산과 혼동하는 것 같습니다.
또한 그레이 스케일 이미지는 float가 아닌 uchar이며, 이전에 convertTo () float를 사용하지 않는 한 임의의 형식으로 픽셀에 액세스 할 수 없습니다.
int main(int argc, char* argv[])
{
cv::Mat img = cv::imread("original.bmp", CV_LOAD_IMAGE_GRAYSCALE);
cv::Mat dst;
bh2Rad(img,dst);
}
//
// please use references with cv::Mat, not pointers.
// those things are refcounted, you're thrashing that with passing pointers.
//
void bh2Rad(const cv::Mat & srcMat, cv::Mat & dstMat)
{
dstMat.create(srcMat.size(),srcMat.type());
for (int i=0; i < srcMat.rows ;i++)
{
const uchar* srcP = srcMat.ptr<uchar>(i);
uchar* dstP = dstMat.ptr<uchar>(i);
for (int j = 0; j < srcMat.cols ;j++)
dstP[j] = srcP[j] * BH_DEG_TO_RAD;
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다