[問題] opencv讀每個點的RGB值有哪些方法

看板C_and_CPP (C/C++)作者 (微醺時光)時間15年前 (2011/05/10 22:28), 編輯推噓0(002)
留言2則, 2人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) DEVC++ 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) OpenCV 問題(Question): 讀取RGB值速度太慢 程式碼(Code):(請善用置底文網頁, 記得排版) int R,G,B; int r=0,c; while(r<img->height) // r: row { c=0; uchar *ptr=(uchar*)(img->imageData+r*img->widthStep); while (c<img->width) // c: col { B=ptr[3*c]; G=ptr[3*c+1]; R=ptr[3*c+2]; c++; } r++; } 補充說明(Supplement): 我用的是單板電腦,上面光取每一點的RGB值,什麼判斷式都沒作, 一張640*480,就花了我15毫秒,有其他的寫法能比較快嗎 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.116.200.75

05/11 01:45, , 1F
B=ptr[0]; G=ptr[1]; R=ptr[2] ptr += 3;
05/11 01:45, 1F

05/11 18:10, , 2F
你把RGB寫成struct或者是陣列就可以用memcpy了...
05/11 18:10, 2F
文章代碼(AID): #1DoKkaF_ (C_and_CPP)
文章代碼(AID): #1DoKkaF_ (C_and_CPP)