您好,我有一個關於opencv的基本問題。如果我嘗試與CV分配內存::墊類,我可以做到以下幾點:opencv cv :: mat allocation
cv::Mat sumimg(rows,cols,CV_32F,0);
float* sumimgrowptr = sumimg.ptr<float>(0);
但後來我得到一個壞的指針(NULL)回來。在互聯網有人使用這個:
cv::Mat* ptrsumimg = new cv::Mat(rows,cols,CV_32F,0);
float* sumimgrowptr = ptrsumimg->ptr<float>(0);
而且在這裏我得到一個空指針回來!但如果我終於這樣做:
cv::Mat sumimg;
sumimg.create(rows,cols,CV_32F);
sumimg.setTo(0);
float* sumimgrowptr = sumimg.ptr<float>(0);
然後一切都很好!所以我想知道我在做什麼錯了?
鏈接對我無效,但我找到了這個:http://docs.opencv.org/modules/core/doc/basic_structures.html#Mat – Pascal 2015-10-12 07:06:20