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


C++ Sensor::getFrame方法代码示例

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


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

示例1: syncTest

void syncTest() {
    using namespace FCam::F2;
    using namespace std;

    printf("syncTest: Testing basic frame-level control\n"
           "-------------------------------------------\n");

    // Initialize a sensor
    Sensor sensor;
    unsigned int n = 10;

    // Create a n-image burst with one image with different parameters

    Burst testShots(1);

    testShots[0].exposure = 1000;
    testShots[0].gain = 10;
    testShots[0].frameTime = 40000;
    testShots[0].image = FCam::Image(640, 480, FCam::UYVY);

    for (unsigned int i=1; i < n;i++) {
        testShots.push_back(testShots[0]);
        testShots[i].image = FCam::Image(640,480, FCam::UYVY);
        if (i >= n/2) testShots[i].exposure = 20000; //25000;
    }
    testShots[n-1].exposure = 40000;

    sensor.stream(testShots);

    vector<vector<float> > lums(n);
    vector<vector<float> > deltaT(n);

    int testFrames = n*10;
    FCam::Time prevTime = FCam::Time::now();
    bool startup = true;
    int startupIgnoreCount = 0; //n-1;

    printf("* Capturing %d frames of a %d-shot burst\n", testFrames, n);
    while (testFrames-- > 0) {
        unsigned int index;
        FCam::Frame::Ptr f = sensor.getFrame();
        
        for (index=0; index<n ;index++ ) {
            if (testShots[index].id == f->shot().id) break;
        }
        if (index == n) {
            printf("Unknown frame returned! Something wrong in the shot cloning, perhaps?\n");
            exit(0);
        }

        if (startupIgnoreCount-- == 0)
            startup=false;

        if (!startup) {
            float dt = (f->processingDoneTime-prevTime) / 1000.;
            printf("Frame %d: Time from previous frame: %.2f ms, supposed to be %.2f\n", index, dt,
                   f->frameTime/1000.);
            deltaT[index].push_back(dt);
        } 

        prevTime = f->processingDoneTime;
            
        if (!f->image.valid()) {
            printf(" Frame %d Came back with no image data!\n", index);
            continue;
        } 

        // Calculate some statistics 
        unsigned int totalY=0;
        unsigned char *yPtr = f->image.data+1; // Offset to get to a Y
        unsigned int count=0;
        while (yPtr < f->image.data + 2*f->image.size.width*f->image.size.height) {
            totalY+= *yPtr;
            yPtr += 100;
            count++;
        }        
        lums[index].push_back( ((float)totalY)/count);
    }
    sensor.stopStreaming();

    printf("Writing stats to syncTest.csv\n");
    ofstream stats("syncTest.csv");   
    bool done = false;
    unsigned int row = 0;
    while (!done) {        
        int haveData=0;
        for (unsigned int i=0;i < n; i++) {
            if (row < lums[i].size()) {
                stats << lums[i][row] << ", ";
                haveData++;
            } else {
                stats << "-1 ,";
            }
            if (row < deltaT[i].size()) {
                stats << deltaT[i][row];
                haveData++;
            } else {
                stats << "-1";
            }
            if (i < n-1)
//.........这里部分代码省略.........
开发者ID:ahaug,项目名称:CamSync,代码行数:101,代码来源:testF2.cpp


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