일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- public
- SERIAL
- preprocessing
- mfc
- file access
- Contour
- memory
- Overloading
- wpf
- Read
- Android
- length
- java
- Encapusulation
- sensor
- Barcode
- atmega328
- digitalRead
- APP
- Pointer
- Class
- flutter
- inheritance
- stream
- parameter
- UNO
- compare
- Unity
- c++
- aduino
- Today
- Total
폴크(FOLC)
머신 비전 사용법 - 버퍼 데이터 복사 본문
# 8bit / 16bit / 24bit / 32bit 등의 여러가지 이미지 데이터 포멧이 있다.
> CImage 형태 이용
> 8bit : 0 ~ 255까지의 값을 표현 ( Gray )
> 16bit : 0 ~ 65,535까지의 값을 표현 ( HQ Gray )
> 24bit : 0 ~ 16,777,215까지의 값을 표현 ( RGB )
> 32bit : 0 ~ 4,294,967,295까지의 값을 표현 ( RGBA )
# 소스 코드
const int src_sizex = src.GetWidth();
const int src_sizey = src.GetHeight();
const int src_pitch = abs(src.GetPitch());
const int src_bitpp = src.GetBPP();
const BYTE *srcPtr = (BYTE *)src.GetImageBuffer();
const int dst_sizex = dst.GetWidth();
const int dst_sizey = dst.GetHeight();
const int dst_pitch = abs(dst.GetPitch());
const int dst_bitpp = dst.GetBPP();
BYTE *dstPtr = (BYTE *)dst.GetImageBuffer();
for (int y = 0; y < src_sizey; ++y)
{
for (int x = 0; x < src_sizex; ++x)
{
const int src_pos = y * src_pitch + x;
const int dst_pos = y * dst_pitch + (x * (dst_bitpp / 8));
for (int bt = 0; bt < (dst_bitpp / 8); bt++)
{
dstPtr[bt] = srcPtr[src_pos];
}
}
}
# 특수한 경우 ( 자료형이 float(실수) 으로 정해진 상태 )
const int src_sizex = src.GetWidth();
const int src_sizey = src.GetHeight();
const int src_pitch = abs(src.GetPitch());
const int src_bitpp = src.GetBPP();
const BYTE *srcPtr = (BYTE *)src.GetImageBuffer();
const int dst_sizex = dst.GetWidth();
const int dst_sizey = dst.GetHeight();
const int dst_pitch = abs(dst.GetPitch());
const int dst_bitpp = dst.GetBPP();
float *dstPtr = (float *)dst.GetImageBuffer();
for (int y = 0; y < src_sizey; ++y)
{
for (int x = 0; x < src_sizex; ++x)
{
const int src_pos = y * src_pitch + x;
const int dst_pos = y * dst_pitch / (dst_bitpp / 8) + x;
dstPtr[dst_pos] = (float)srcPtr[src_pos];
}
}
'머신 비전 > 머신 비전 사용법 CPP' 카테고리의 다른 글
머신 비전 알고리즘 OpenCV 개발 환경 구성 ( CPP ) (0) | 2021.10.15 |
---|---|
머신 비전 알고리즘 소개 (0) | 2021.07.17 |