本文整理汇总了C++中FlexImage::setExternal方法的典型用法代码示例。如果您正苦于以下问题:C++ FlexImage::setExternal方法的具体用法?C++ FlexImage::setExternal怎么用?C++ FlexImage::setExternal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlexImage
的用法示例。
在下文中一共展示了FlexImage::setExternal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testExternal
void testExternal() {
report(0, "testing external image...");
unsigned char buf[EXT_HEIGHT][EXT_WIDTH];
{
for (int x=0; x<EXT_WIDTH; x++) {
for (int y=0; y<EXT_HEIGHT; y++) {
buf[y][x] = 20;
}
}
}
ImageOf<PixelMono> img1;
img1.setExternal(&buf[0][0],EXT_WIDTH,EXT_HEIGHT);
checkEqual(img1.width(),EXT_WIDTH,"width check");
checkEqual(img1.height(),EXT_HEIGHT,"height check");
int mismatch = 0;
for (int x=0; x<img1.width(); x++) {
for (int y=0; y<img1.height(); y++) {
img1.pixel(x,y) = 5;
if (buf[y][x]!=5) {
mismatch++;
}
}
}
checkEqual(mismatch,0,"delta check");
report(0, "testing various padding + alignments...");
for (int ww=1; ww<=17; ww++) {
for (int hh=1; hh<=17; hh++) {
for (int pad1=1; pad1<=9; pad1++) {
for (int pad2=1; pad2<=9; pad2++) {
int wwp1 = (ww%pad1)?(ww+pad1-(ww%pad1)):ww;
FlexImage img;
char *data = new char[wwp1*hh*3];
yAssert(data);
img.setQuantum(pad1);
img.setPixelCode(VOCAB_PIXEL_RGB);
img.setPixelSize(3);
img.setExternal(data,ww,hh);
ImageOf<PixelRgb> target;
target.setQuantum(pad2);
target.copy(img);
delete[] data;
}
}
}
}
}
示例2: getVideo
bool getVideo(ImageOf<PixelRgb>& image) {
if (frameFinished) {
FlexImage flex;
flex.setPixelCode(VOCAB_PIXEL_RGB);
flex.setQuantum((pFrameRGB->linesize[0]));
flex.setExternal(pFrameRGB->data[0],
pCodecCtx->width,
pCodecCtx->height);
image.copy(flex);
}
return frameFinished;
}
示例3: wrapIplImage
void Image::wrapIplImage(void *iplImage) {
yAssert(iplImage!=NULL);
IplImage *p = (IplImage *)iplImage;
ConstString str = p->colorModel;
int code = -1;
int color_code = -1;
if (str=="rgb"||str=="RGB"||
str=="bgr"||str=="BGR"||
str=="gray"||str=="GRAY"||
str=="graygray"||str=="GRAYGRAY") {
str = p->channelSeq;
if (str=="rgb"||str=="RGB") {
color_code = VOCAB_PIXEL_RGB;
} else if (str=="bgr"||str=="BGR") {
color_code = VOCAB_PIXEL_BGR;
} else if (str=="gray"||str=="GRAY"||
str=="graygray"||str=="GRAYGRAY") {
color_code = VOCAB_PIXEL_MONO;
} else {
printf("specific IPL RGB order (%s) is not yet supported\n",
str.c_str());
printf("Try RGB, BGR, or \n");
printf("Or fix code at %s line %d\n",__FILE__,__LINE__);
exit(1);
}
}
// Type translation is approximate. Patches welcome to flesh out
// the types available.
if (p->depth == IPL_DEPTH_8U) {
code = color_code;
} else if (p->depth == IPL_DEPTH_8S) {
switch (color_code) {
case VOCAB_PIXEL_MONO:
code = VOCAB_PIXEL_MONO_SIGNED;
break;
case VOCAB_PIXEL_RGB:
code = VOCAB_PIXEL_RGB_SIGNED;
break;
case VOCAB_PIXEL_BGR:
code = color_code; // nothing better available
break;
}
} else if (p->depth == IPL_DEPTH_16U || p->depth == IPL_DEPTH_16S) {
switch (color_code) {
case VOCAB_PIXEL_MONO:
code = VOCAB_PIXEL_MONO16;
break;
case VOCAB_PIXEL_RGB:
case VOCAB_PIXEL_BGR:
fprintf(stderr,"No translation currently available for this pixel type\n");
exit(1);
break;
}
} else if (p->depth == IPL_DEPTH_32S) {
switch (color_code) {
case VOCAB_PIXEL_MONO:
code = VOCAB_PIXEL_INT;
break;
case VOCAB_PIXEL_RGB:
case VOCAB_PIXEL_BGR:
code = VOCAB_PIXEL_RGB_INT;
break;
}
} else if (p->depth == IPL_DEPTH_32F) {
switch (color_code) {
case VOCAB_PIXEL_MONO:
code = VOCAB_PIXEL_MONO_FLOAT;
break;
case VOCAB_PIXEL_RGB:
case VOCAB_PIXEL_BGR:
code = VOCAB_PIXEL_RGB_FLOAT;
break;
}
}
if (code==-1) {
fprintf(stderr,"IPL pixel type / depth combination is not yet supported\n");
fprintf(stderr,"Please email a YARP developer to complain, quoting this:\n");
fprintf(stderr," %s:%d\n", __FILE__, __LINE__);
}
if (getPixelCode()!=code && getPixelCode()!=-1) {
printf("your specific IPL format (%s depth %d -> %s) does not match your YARP format (%s)\n",
str.c_str(),
p->depth,
Vocab::decode(code).c_str(),
Vocab::decode(getPixelCode()).c_str());
printf("Making a copy instead of just wrapping...\n");
FlexImage img;
img.setQuantum(p->align);
img.setPixelCode(code);
img.setExternal(p->imageData,p->width,p->height);
copy(img);
} else {
setQuantum(p->align);
setPixelCode(code);
setExternal(p->imageData,p->width,p->height);
}
}