'STUDY > Python' 카테고리의 다른 글

[Python] Reserved Words  (0) 2016.08.16
[Python] create name in Python  (0) 2016.08.16



#include <opencv2/opencv.hpp>

using namespace cv;


#include <iostream>

using namespace std;


#define STR_WINDOW "Window"


void mouseEvent(int evt, int x, int y, int flags, void *param){

Mat *img = (Mat *)param;

if ( evt == CV_EVENT_LBUTTONDOWN ){

printf("(%04d, %04d) : %03d, %03d, %03d\n", x, y,

(int)(*img).at<Vec3b>(y,x)[0],

(int)(*img).at<Vec3b>(y,x)[1],

(int)(*img).at<Vec3b>(y,x)[2]);

}

}


int main(){

Mat image = imread( your image path );

if ( image.empty() ){

cout << "Error loading the image" <<endl;

return -1;

}


namedWindow(STR_WINDOW, 1);

setMouseCallback(STR_WINDOW, mouseEvent, &image);

imshow(STR_WINDOW, image);


waitKey(0);

return 0;

}


<< result >>

    • and
    • as
    • assert
    • break
    • class
    • continue
    • def
    • del
    • elif
    • else
    • except
    • exec
    • finally
    • for
    • from
    • global
    • if
    • import
    • in
    • is
    • lambda
    • Not
    • or
    • pass
    • print
    • raise
    • return
    • try
    • while
    • with
    • yield


'STUDY > Python' 카테고리의 다른 글

파이썬 디버깅(Debugging python)  (0) 2016.09.28
[Python] create name in Python  (0) 2016.08.16
  • Class names start with an uppercase letter. All other identifiers start with a lowercase letter.
  • Starting an identifier with a single leading underscore indicates that the identifier is private.
  • Starting an identifier with two leading underscores indicates a strongly private identifier.
  • If the identifier also ends with two trailing underscores, the identifier is a language-defined special name.


'STUDY > Python' 카테고리의 다른 글

파이썬 디버깅(Debugging python)  (0) 2016.09.28
[Python] Reserved Words  (0) 2016.08.16


#include <stdio.h>

#include <direct.h>    // chdir


#ifndef _MAX_PATH

#define _MAX_PATH    260

#endif // _MAX_PATH


int main(){

char strBuffer[_MAX_PATH]={0,};

char strChangeDir[_MAX_PATH]={"..\\"};


char *pStrBuffer = NULL;

pStrBuffer = _getcwd(strBuffer, _MAX_PATH);

printf("Beginning path : %s\n", strBuffer);


int nResult = _chdir(strChangeDir);

if ( nResult == 0 ){

printf( "Successed\n" );

pStrBuffer = _getcwd(strBuffer, _MAX_PATH);

printf( "Ending path : %s\n", strBuffer);

} else {

perror( "Failed" );

}


return 0;

}







< 테스트 결과 (Result of test) >


#include <stdio.h>


#pragma warning(disable: 4996)


int main(){

FILE *pFile;

pFile = fopen("MakeAFile.txt", "w");

if ( pFile != NULL ){

fputs("fopen example", pFile);

fclose(pFile);

}


return 0;

}

#include <opencv\cv.h>

#include <opencv\highgui.h>


using namespace cv;

using namespace std;


int main(){


// 이미지 불러오기 (read image).

Mat image = imread("image.jpg");


// 에러 처리 (error).

if ( !image.data ) {

return -1;

}


// 관심영역 설정 (set ROI (X, Y, W, H)).

Rect rect(100, 30, 150, 300);


// 관심영역 자르기 (Crop ROI).

Mat subImage = image(rect);


// show

imshow("image", subImage);


waitKey(0);


return 0;

}



#include <opencv2/opencv.hpp>

using namespace cv;


int main(int argc, char **argv){

char *imageName = argv[1];


Mat image;

image = imread(imageName, 1);    // 이미지 불러오기.


// 에러 처리.

if ( argc!= 2 || !image.data ){

printf(" No image data \n ");

return -1;

}


// 불러온 이미지와 구분하기 위하여 흑백 이미지로 변환.

Mat grayImage;

cvtColor( image, grayImage, COLOR_BGR2GRAY );


// 파일명 "GrayImage.jpg"로 저장.

imwrite( "GrayImage.jpg", grayImage );


return 0;

}


이와같이 사용하시면 이미지 불러오기와 저장을 할 수 있습니다.

'STUDY > Android' 카테고리의 다른 글

Android 개발환경 설정하기 1  (0) 2013.11.25
  • 다음의 링크를 클릭하신 후에 사용자 환경에 맞는 프로그램을 다운 받으시면 됩니다.

https://www.gnu.org/software/octave/download.html




  • 먼저 homebrew와 XQuartz 설치를 합니다. (설치 되어있으시면, 다음 단계로 넘어가시면 됩니다. )

    $ curl http://xquartz-dl.macosforge.org/SL/XQuartz-2.7.7.dmg -o /tmp/XQuartz.dmg

    $ open /tmp/XQuartz.dmg

    $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


  • homebrew와 XQuartz 설치 후 아래의 명령어를 입력하여 Octave 설치하자.
    • $ brew tap homebrew/science

      $ brew update && brew upgrade

      $ brew install gcc

      $ brew install octave

  • Octave가 설치 완료가 되었습니다. 일반적으로 터미널에서 octave 명령어를 입력하면 바로 실행이 됩니다. 그렇지 않으신분들은 다음 경로로 이동하여 실행하시면 됩니다. (
    /usr/local/Cellar/octave/3.8.1_1/bin/octave)


  • Octave를 실행시키고 "1+1"를 실행한 결과 화면 입니다.

    모두들 Octave와 즐거운 시간 가지세요~


      'STUDY > Octave' 카테고리의 다른 글

      Octave 란?  (0) 2016.02.11

      + Recent posts