ubuntu下opencv 安裝比較簡單,直接使用命令
sudo apt-get install libopencv-dev
安裝後用簡單**進行測試
makefile/****opencv_test.cpp***/
#include #include using namespace std;
using namespace cv;
int main()
ubuntu 一般通過v4l2拿取影象,然後把影象交給opencv即可顯示處理。 另外opencv 也提供了開啟攝像頭介面,對v4l2的實現進行了封裝,可以滿足基本的使用。下面就分別介紹下兩種方式include = $(shell pkg-config --cflag opencv)
libs = $(shell pkg-config --libs opencv)
bin = opencv
objects = opencv_test.o
sources = opencv_test.cpp
$(bin):$(objects)
g++ -o $(bin) $(objects) -i $(include) $(libs)
$(objects):$(sources)
g++ -c $(sources)
clean:
rm $(object) $(bin)
直接上**
完整**:#include #include #include #include int main(int argc, char *argv)
cv::mat frame; //定義乙個矩陣接受幀
cv::namedwindow("camera",1); //定義顯示幀
int i=0;
for(;;)
}3. 啟動攝像頭採集資料
if (-1 == xioctl(fd, vidioc_streamon, &type))
4. 讀取一幀
if (-1 == xioctl(fd, vidioc_dqbuf, &buf))
5. v4l2 資料轉mat
cv::mat yuvimg;
cv::mat rgbimg(rows, cols,cv_8uc3);
yuvimg.create(rows , cols, cv_8uc2);
memcpy(yuvimg.data, p, cols*rows*2);
cv::cvtcolor(yuvimg, rgbimg, cv_yuv2bgr_yuyv); //p 為v4l2資料
Ubuntu下編譯安裝OpenCV
國外乙個部落格是在ubuntu 11.04下安裝opencv2.2 由於我的系統是11.10的,在opencv2.2下make時,總是出錯。如果系統是ubuntu 11.04的建議採用這篇英文部落格的方法,應該沒有問題。後面看到另乙個部落格,可以安裝opencv2.3 對於測試,可以參考上面提到的一...
ubuntu下opencv在python中的配置
因為之前在安裝caffe的時候裝過opencv,那次是用cmake編譯安裝的,當時應該是沒設定makelist中python選項,最近在想在python中呼叫cv2,結果發現opencv的編譯包中沒有cv2.pyd,python中import cv2找不到相應庫。然後我又去已安裝的python第三方...
Ubuntu下編寫OpenCV程式
ubuntu下編譯 openccv 程式有兩種方法 command line 和 cmake。建立test.cpp檔案,內容如下 include int main int argc,char ar g test.cpp o test pkg config cflags libs opencv 以上是...