Re: [問題] opencv Mat取直的問題

看板C_and_CPP (C/C++)作者 (大David為)時間13年前 (2012/08/27 14:19), 編輯推噓3(3014)
留言17則, 3人參與, 最新討論串2/2 (看更多)
想請問 我試過了d大的兩個方式 但使用mat.at<uchar>(i,j)執行都會有閃退 有在大陸網站查到好像是opencv2.2本身的錯誤? 錯誤訊息如下 http://ppt.cc/LdFZ 主要是希望擷取下圖深度影像的某個區塊作處理 http://ppt.cc/6hjw 但使用 : Mat b; : Mat a; : for(k=0;k<20;k++) : { : for(j=0;j<20;j++) : { : b.data[k*b.cols+j] = a.data[k*a.cols+j]; : } : } 結出來的圖繪變成下圖這樣= = http://ppt.cc/9wxD 請問還有甚麼方法可以取得mat裡的值呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.136.146.60

08/27 14:58, , 1F
閃退是什麼啊...
08/27 14:58, 1F

08/27 14:59, , 2F
深度影像的型態是?
08/27 14:59, 2F

08/27 15:10, , 3F
閃退就是當機啦= =程式開起來會當掉的那種
08/27 15:10, 3F

08/27 15:12, , 4F
深度影像是CV_8U
08/27 15:12, 4F

08/27 15:40, , 5F
如果你是灰階圖用這個.at<Vec3b>
08/27 15:40, 5F

08/27 15:44, , 6F
重點在於at的型態,你用uchar一定不行的...
08/27 15:44, 6F

08/27 15:59, , 7F
一樣步行耶,請問要怎麼樣知道自己要用甚麼型態呢?
08/27 15:59, 7F

08/27 16:04, , 8F
這個問題我也很想知道...我都是慢慢try
08/27 16:04, 8F

08/27 16:05, , 9F
給個code看看,這樣比較好知道問題
08/27 16:05, 9F

08/27 16:05, , 10F
你的程式有轉成灰階嗎?gray
08/27 16:05, 10F

08/27 16:09, , 11F
我是用openni去接kinect回傳的值 本生就是灰階影像
08/27 16:09, 11F

08/27 16:33, , 12F
channel是1?
08/27 16:33, 12F

08/27 17:34, , 13F
恩恩~C1的
08/27 17:34, 13F

08/27 19:55, , 14F
可以看type號碼吧
08/27 19:55, 14F

08/28 09:26, , 15F
請問d大用的是opencv哪個版本呢?
08/28 09:26, 15F

08/28 12:00, , 16F
2.3
08/28 12:00, 16F

08/28 13:57, , 17F
我現在是2.2等等來換換看2.3試試好了
08/28 13:57, 17F
後來我看了core.hpp 裡面有一段寫到 The next important thing to learn about the matrix class is element access. Here is how the matrix is stored. The elements are stored in row-major order (row by row). The cv::Mat::data member points to the first element of the first row, cv::Mat::rows contains the number of matrix rows and cv::Mat::cols - the number of matrix columns. There is yet another member, cv::Mat::step that is used to actually compute address of a matrix element. cv::Mat::step is needed because the matrix can be a part of another matrix or because there can some padding space in the end of each row for a proper alignment. 也有提到範例 *(b.data + (b.step*k + j*b.elemSize())) = 0; 用這樣的方式給值是可行的 要控制通道的話從b.step*k + j*b.elemSize() -1或-2去修改 ※ 編輯: ddv70 來自: 140.136.146.60 (08/28 15:45) ※ 編輯: ddv70 來自: 140.136.146.60 (08/28 16:34)
文章代碼(AID): #1GEn5OQy (C_and_CPP)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
文章代碼(AID): #1GEn5OQy (C_and_CPP)