OpenCV — 픽셀 데이터에 접근하기

Nanyoung Kim
1 min readAug 5, 2020

how to access pixel data

접근 방법

1. At approach

  • 가장 안정적
  • 속도 느림

2. Ptr approach

  • At 보다 빠르고 안전 (Data approach 보다 느림)
  • 사용하기 까다로움

3. Data approach

  • 속도 가장 빠름
  • 포인터를 이용해서 데이터에 바로 접근하기 때문에 오류 검증 안 됨. 포인터 잘 못 쓰면 프로그램 종료될 위험 있음.

4. Iterator approach

Mat & Vector

  1. Vector를 Mat으로 복사
 memcpy(M.data, Vf,data(), Vf.size()*sizeof(float));

2. Mat를 Vector로 복사

Vf2.assign((float*)M.datastart, (float*)M.dataend);

3. ImageBuffer를 Mat으로 복사

Mat InImg(height, width, CV_8UC1;
memcpy(InImg.data, pData, sizeof(unsigned char)*width*height);

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response