本文整理汇总了C++中CDib::BitCount方法的典型用法代码示例。如果您正苦于以下问题:C++ CDib::BitCount方法的具体用法?C++ CDib::BitCount怎么用?C++ CDib::BitCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDib
的用法示例。
在下文中一共展示了CDib::BitCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CellPhonePartRecog
/////// -----------------------------------------------------------------------
/////// 휴대폰 부품 인식 모듈
TargetObject CVisionTab::CellPhonePartRecog(CDib* pImg)
{
TargetObject obj;
if(pImg->BitCount() > 8) {
cout << "Input image should be gray scale! " << endl;
return obj;
}
CDib* src = pImg->CopyCDib();
int width = src->Width();
int height = src->Height();
int bitcount = src->BitCount();
register int i, j;
CKde* kdemat;
kdemat = new CKde;
kdemat->initKDEmask(width, height, 4); // initialize KDE function
for(j=0; j<src->Height(); j++)
{
unsigned char *ptr = src->GetPointer(0,j);
for(i=0; i<src->Width(); i++, ptr++)
{
if(*ptr == 255) {
kdemat->setSumKDEmask(i,j);
}
}
}
CPoint cp = kdemat->GetMaxCoordi(); // Clip image에서의 KDE max 좌표
CPoint center = kdemat->GetThresMeanCoordiClip(0.2, cp, 60); // depth 정보에 따른 Area 계산식 구현할 것!
obj.density = kdemat->GetMaxValue();
if(obj.density > 0.6) {
//cout << "den" << kdemat->GetMaxValue() << endl;
// Clip image 좌표
obj.cix = center.x;
obj.ciy = center.y;
}
//// 전체 image 좌표
obj.ix = m_ClipRect.left + obj.cix;
obj.iy = m_ClipRect.top + obj.ciy;
//// Object ID 분류
obj.cnt = src->GetTruePixelNumB();
int range = 100;
if(obj.cnt > 2050-range && obj.cnt < 2050+range) // 크래들
{
obj.ID = CRADLE;
}
else if(obj.cnt > 760-range && obj.cnt < 760+range) // 플러그
{
obj.ID = PLUG;
}
else if(obj.cnt > 920-range && obj.cnt < 920+range) // USB 커넥터
{
obj.ID = USBCON;
}
else if(obj.cnt > 500-range && obj.cnt < 500+range) // 이어폰
{
obj.ID = EARPHONE;
}
else
{
obj.ID = -1;
}
// 여기에 orientation 삽입?
// 메모리 해제
kdemat->releaseKDEMask();
delete src;
return obj;
}
示例2: ColorBoxRecog
///////////// Vision Class Implementation //////////////
CDib* CVisionTab::ColorBoxRecog(CDib* pImg)
{
// ------------------------------------------------------
// ------------------- Color Slicing &-------------------
// ------------- Kernel density estimation --------------
// ------------------------------------------------------
//CalcTime();
// input image 영상 처리 및 복사
CDib* src = pImg->GetSingleScaleRetinexImage(1.5);
//CDib* src = pImg->CopyCDib();
int width = src->Width();
int height = src->Height();
//int bitcount = src->BitCount();
int bitcount = 8;
CDib* pRed = new CDib;
pRed->Allocate(width, height, bitcount);
pRed->SetGrayPalette();
CDib* pGreen = new CDib;
pGreen->Allocate(width, height, bitcount);
pGreen->SetGrayPalette();
CDib* pBlue = new CDib;
pBlue->Allocate(width, height, bitcount);
pBlue->SetGrayPalette();
CDib* pYellow = new CDib;
pYellow->Allocate(width, height, bitcount);
pYellow->SetGrayPalette();
register int i, j;
double h, s, v;
int step = (int)src->BitCount()/8;
RGBQUAD quad;
CKde* kdemat[NUMBOX];
for(i=0; i<NUMBOX; i++) {
kdemat[i] = new CKde;
kdemat[i]->initKDEmask(width, height, 4); // initialize KDE function
}
for(j=0; j<src->Height(); j++)
{
unsigned char *ptr = src->GetPointer(0,j);
for(i=0; i<src->Width(); i++, ptr+=step)
{
quad.rgbBlue = *(ptr+0); quad.rgbGreen = *(ptr+1); quad.rgbRed = *(ptr+2);
src->RGBtoHSV(quad, &h, &s, &v);
// normalize Hue
h /= 360;
// Red Box: 0.93, 0.97
if(h > 0.91 && h < 0.99 && s > TS && v > Ti) {
unsigned char *pr = pRed->GetPointer(i,j);
*(pr+0) = 255;
kdemat[RED]->setSumKDEmask(i,j);
}
// Green Box: 0.25, 0.37
if(h > 0.24 && h < 0.38 && s > TS && v > Ti) { // default: 0.27, 0.36
unsigned char *pg = pGreen->GetPointer(i,j);
*(pg+0) = 255;
kdemat[GREEN]->setSumKDEmask(i,j);
}
// Blue: 0.59, 0.65
if(h > 0.59 && h < 0.65 && s > TS && v > Ti) {
unsigned char *pb = pBlue->GetPointer(i,j);
*(pb+0) = 255;
kdemat[BLUE]->setSumKDEmask(i,j);
}
// Yellow: 0.12, 0.14
if(h > 0.11 && h < 0.15 && s > TS && v > Ti) {
unsigned char *py = pYellow->GetPointer(i,j);
*(py+0) = 255;
kdemat[YELLOW]->setSumKDEmask(i,j);
}
}
}
// *****************************************************************
//
// 본 프로그램의 좌표는 크게 아래 3가지로 나뉜다.
//.........这里部分代码省略.........