레이블이 OpenCV인 게시물을 표시합니다. 모든 게시물 표시
레이블이 OpenCV인 게시물을 표시합니다. 모든 게시물 표시

2017년 5월 18일 목요일

OpenCV 3.2 in Ubuntu 16.10


OpenCV 3.2 in Ubuntu 16.10 설치기
$ sudo apt-get install build-essential checkinstall cmake git pkg-config yasm libtiff5-dev libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine2-dev libv4l-dev python-dev python-numpy libtbb-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils libopenexr-dev python-tk  libeigen3-dev libx264-dev
$ sudo add-apt-repository ppa:mc3man/gstffmpeg-keep
$ sudo apt-get update
$ sudo apt-get install ffmpeg
$ git clone https://github.com/opencv/opencv.git
$ git clone https://github.com/opencv/opencv_contrib.git
$ cd opencv
$ mkdir build
$ cd build
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_TBB=ON -D WITH_IPP=OFF -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules  ../
$ make -j8
$ sudo make install

2013년 7월 14일 일요일

getGaussianKernel

getGaussianKernel : Returns Gaussian filter coefficients.
getGaussianKernel(int ksize, double sigma, int ktype=CV_64F )

ksize – Aperture size. It should be odd ( \texttt{ksize} \mod 2 = 1 ) and positive.
sigma – Gaussian standard deviation. If it is non-positive, it is computed from ksize as sigma = 0.3*((ksize-1)*0.5 - 1) + 0.8 .
ktype – Type of filter coefficients. It can be CV_32f or CV_64F .



int M = 101;
double sigma = 10;
Mat_ g = getGaussianKernel(M, sigma, CV_64F);

for(int i=0; i
{
double g1 = g(i,0);
Dbg("%f", g1);
}

Mat_ 접근
// more convenient forms of row and element access operators 
    _Tp* operator [](int y);
    const _Tp* operator [](int y) const;

    _Tp& operator ()(int row, int col);
    const _Tp& operator ()(int row, int col) const;
    _Tp& operator ()(Point pt);
    const _Tp& operator ()(Point pt) const;


아래는 http://bytefish.de/blog/opencv/code_snippets/ 에서 가져옴

template
void printMat(const cv::Mat_<_tp>& mat) {
    typedef typename DataType<_tp>::work_type _wTp;
    for(int i = 0; i < mat.rows; i++)
        for(int j=0; j < mat.cols; j++)
            cout << (_wTp) mat(i,j) << " ";
    cout << endl;
}



2013년 6월 15일 토요일

iOS에서 OpenCV 2.4.5 linking


iOS에서 OpenCV 2.4.5 linking 할때 생기는 에러.

std::__1::__vector_base_common::__throw_length_error() const", referenced from:

libc++ .dylib 넣으면 됨.

---------------------------------------------------------------
from http://libcxx.llvm.org/

libc++ is a new implementation of the C++ standard library, targeting C++11.
All of the code in libc++ is dual licensed under the MIT license and the UIUC License (a BSD-like license).

Features and Goals
  • Correctness as defined by the C++11 standard.
  • Fast execution.
  • Minimal memory use.
  • Fast compile times.
  • ABI compatibility with gcc's libstdc++ for some low-level features such as exception objects, rtti and memory allocation.
  • Extensive unit tests.





2012년 7월 15일 일요일

Direct Access to CvMat



If CV_32FC1 (1 channel float)

CvMat* M = cvCreateMat( 4, 4, CV_32FC1 );
M->data.fl[ row * M->cols + col ] = (float)3.0;

or...

cvmGet( mat, row, col );

...


inline void cvDoubleMatPrint( const CvMat* mat )
{
    int i, j;
    for( i = 0; i < mat->rows; i++ )
    {
        for( j = 0; j < mat->cols; j++ )
        {
            printf( "%f ",cvmGet( mat, i, j ) );
        }
        printf( "\n" );
    }
}

from http://note.sonots.com/OpenCV/MatrixOperations.html


2012년 6월 24일 일요일

OpenCV in iOS

XCODE 4.2로 업그레이드를 하기전에, 좀 더 심사숙고했어야 하는데..
어쨋든 기존 프로젝트 섿업을 다시 한번 손봐줘야했다.

마지막으로 남은 OpenCV 문제.




Statement-expressions are allowed only inside functions
../externalLibs/opencv/include/opencv2/core/core.hpp:437: confused by earlier errors, bailing out


core.hpp 에서 MIN 함수에서 문제가 생기네..
해결법이 다음 링크에 나와있긴 한데, 나의 경우는 잘 안되었음.
http://computer-vision-talks.com/2011/01/using-opencv-in-objective-c-code/



이럴때는 간단히 아래처럼 MIN 을 정의를 undef하면 됨.
뭐 나중에 opencv내에서 정의하겠지..


#undef MIN
#include

굳이 나중에 문제가 생긴다면, 재정의하면 되고.
#define MIN(a, b)  (((a) < (b)) ? (a) : (b))