当前位置: 首页>>代码示例>>C++>>正文


C++ FlexImage::height方法代码示例

本文整理汇总了C++中FlexImage::height方法的典型用法代码示例。如果您正苦于以下问题:C++ FlexImage::height方法的具体用法?C++ FlexImage::height怎么用?C++ FlexImage::height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FlexImage的用法示例。


在下文中一共展示了FlexImage::height方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

yarp::os::Things& DepthImageConverter::update(yarp::os::Things& thing)
{
    FlexImage* img = thing.cast_as< FlexImage >();
    inMatrix = (float **) img->getRawImage();

    outImg.setPixelCode(VOCAB_PIXEL_MONO);
    outImg.setPixelSize(1);
    outImg.resize(img->width(), img->height());

    outImg.zero();
    float *inPixels = (float *)img->getRawImage();
    unsigned char *pixels = outImg.getRawImage();
    for(int h=0; h<img->height(); h++)
    {
        for(int w=0; w<img->width(); w++)
        {
            float inVal = inPixels[w + (h * img->width())];
            if (inVal != inVal /* NaN */ || inVal < min || inVal > max) {
                pixels[w + (h * (img->width() ))] = 0;
            } else {
                int val = (int) (255.0 - (inVal * 255.0 / (max - min)));
                if(val >= 255)
                    val = 255;
                if(val <= 0)
                    val = 0;
                pixels[w + (h * (img->width() ))] = (char) val;
            }
        }
    }
    th.setPortWriter(&outImg);
    return th;
}
开发者ID:CV-IP,项目名称:yarp,代码行数:32,代码来源:DepthImage.cpp

示例2: write

bool MjpegCarrier::write(ConnectionState& proto, SizedWriter& writer) {
    WireImage rep;
    FlexImage *img = rep.checkForImage(writer);

    if (img==NULL) return false;
    int w = img->width();
    int h = img->height();
    int row_stride = img->getRowSize();
    JOCTET *data = (JOCTET*)img->getRawImage();

    JSAMPROW row_pointer[1];

    struct jpeg_compress_struct cinfo;
    struct jpeg_error_mgr jerr;
    cinfo.err = jpeg_std_error(&jerr);
    cinfo.client_data = &proto;
    jpeg_create_compress(&cinfo);
    jpeg_net_dest(&cinfo);
    cinfo.image_width = w;
    cinfo.image_height = h;
    cinfo.input_components = 3;
    cinfo.in_color_space = JCS_RGB;
    jpeg_set_defaults(&cinfo);
    //jpeg_set_quality(&cinfo, 85, TRUE);
    dbg_printf("Starting to compress...\n");
    jpeg_start_compress(&cinfo, TRUE);
    if(!envelope.empty()) {
        jpeg_write_marker(&cinfo, JPEG_COM, reinterpret_cast<const JOCTET*>(envelope.c_str()), envelope.length() + 1);
        envelope.clear();
    }
    dbg_printf("Done compressing (height %d)\n", cinfo.image_height);
    while (cinfo.next_scanline < cinfo.image_height) {
        dbg_printf("Writing row %d...\n", cinfo.next_scanline);
        row_pointer[0] = data + cinfo.next_scanline * row_stride;
        jpeg_write_scanlines(&cinfo, row_pointer, 1);
    }
    jpeg_finish_compress(&cinfo);
    jpeg_destroy_compress(&cinfo);

    return true;
}
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:41,代码来源:MjpegCarrier.cpp

示例3: threadInit

bool LogPolarTransformThread::threadInit() 
{
    /* grab an image to set the image size */
    FlexImage *image;
    do {
        image = imagePortIn->read(true);
    } while (image == NULL && !isStopping());

    if (isStopping())
        return false;

    const int width  = image->width();
    const int height = image->height();
    // the logpolar mapping has always depth 3 (RGB) but we need to copy the input image in case it's monochrome.
    const int depth = 3; 
 
    cout << "||| logPolarTransformThread: width = " << *xSizeValue << " height = " << *ySizeValue << endl;
    cout << "||| logPolarTransformThread: angles = " << *anglesValue << " rings = " << *ringsValue << endl;

    /* create the input image of the correct resolution  */
    if (*directionValue == CARTESIAN2LOGPOLAR) {
        *xSizeValue = width;
        *ySizeValue = height;
    }

    cout << "||| initializing the logpolar mapping" << endl;
    if (!allocLookupTables(*directionValue, *ringsValue, *anglesValue, *xSizeValue, *ySizeValue, *overlapValue)) {
        cerr << "can't allocate lookup tables" << endl;
        return false;
    }
    cout << "||| lookup table allocation done" << endl;

    inputImage = new ImageOf<PixelRgb>;
    inputImage->resize(width, height);

    return true;
}
开发者ID:robotology,项目名称:logpolar,代码行数:37,代码来源:logPolarTransform.cpp

示例4: testCreate

 void testCreate() {
     report(0,"testing image creation...");
     FlexImage image;
     image.setPixelCode(VOCAB_PIXEL_RGB);
     image.resize(256,128);
     checkEqual(image.width(),256,"check width");
     checkEqual(image.height(),128,"check height");
     ImageOf<PixelInt> iint;
     iint.resize(256,128);
     long int total = 0;
     for (int x=0; x<iint.width(); x++) {
         for (int y=0; y<iint.height(); y++) {
             int v = (x+y)%65537;
             iint.pixel(x,y) = v;
             total += v;
         }
     }
     for (int x2=0; x2<iint.width(); x2++) {
         for (int y2=0; y2<iint.height(); y2++) {
             total -= iint.pixel(x2,y2);
         }
     }
     checkEqual(total,0,"pixel assignment check");
 }
开发者ID:apaikan,项目名称:yarp,代码行数:24,代码来源:ImageTest.cpp

示例5: read

bool Image::read(yarp::os::ConnectionReader& connection) {

    // auto-convert text mode interaction
    connection.convertTextMode();
    
    ImageNetworkHeader header;
    
    bool ok = connection.expectBlock((char*)&header,sizeof(header));
    if (!ok) return false;
        
    imgPixelCode = header.id;
    
    int q = getQuantum();
    if (q==0) {
        //q = YARP_IMAGE_ALIGN;
        setQuantum(header.quantum);
        q = getQuantum();
    }
    if (q!=header.quantum) {
        if ((header.depth*header.width)%header.quantum==0 &&
            (header.depth*header.width)%q==0) {
            header.quantum = q;
        }
    }
        
    if (getPixelCode()!=header.id||q!=header.quantum) {
        // we're trying to read an incompatible image type
        // rather than just fail, we'll read it (inefficiently)
        FlexImage flex;
        flex.setPixelCode(header.id);
        flex.setQuantum(header.quantum);
        flex.resize(header.width,header.height);
        if (header.width!=0&&header.height!=0) {
            unsigned char *mem = flex.getRawImage();
            yAssert(mem!=NULL);
            if (flex.getRawImageSize()!=header.imgSize) {
                printf("There is a problem reading an image\n");
                printf("incoming: width %d, height %d, code %d, quantum %d, size %d\n",
                       (int)header.width, (int)header.height, 
                       (int)header.id,
                       (int)header.quantum, (int)header.imgSize);
                printf("my space: width %d, height %d, code %d, quantum %d, size %d\n",
                       flex.width(), flex.height(), flex.getPixelCode(),
                       flex.getQuantum(), 
                       flex.getRawImageSize());
            }
            yAssert(flex.getRawImageSize()==header.imgSize);
            ok = connection.expectBlock((char *)flex.getRawImage(),
                                        flex.getRawImageSize());
            if (!ok) return false;
        }
        copy(flex);
    } else {
        yAssert(getPixelCode()==header.id);
        resize(header.width,header.height);
        unsigned char *mem = getRawImage();
        if (header.width!=0&&header.height!=0) {
            yAssert(mem!=NULL);
            if (getRawImageSize()!=header.imgSize) {
                printf("There is a problem reading an image\n");
                printf("incoming: width %d, height %d, code %d, quantum %d, size %d\n",
                       (int)header.width, (int)header.height, 
                       (int)header.id,
                       (int)header.quantum, (int)header.imgSize);
                printf("my space: width %d, height %d, code %d, quantum %d, size %d\n",
                       width(), height(), getPixelCode(), getQuantum(), getRawImageSize());
            }
            yAssert(getRawImageSize()==header.imgSize);
            ok = connection.expectBlock((char *)getRawImage(),
                                        getRawImageSize());
            if (!ok) return false;
        }
    }
    
    return !connection.isError();
}
开发者ID:Karma-Revolution,项目名称:yarp,代码行数:76,代码来源:Image.cpp


注:本文中的FlexImage::height方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。