示例#1
0
/*
 * Draws results to the image
 */
void LinemodInterface::drawResults(cv::Mat &image, const std::vector<Result> &results)
{
  for(int i = 0; i < (int)results.size(); ++i)
  {
    drawResult(image, results[i]);
  }
}
示例#2
0
文件: MainWindow.cpp 项目: Hexta/GRES
    void etch(int simType_, int IterCount, float* rates) {
        GRES::SimType sT = static_cast<GRES::SimType>(simType_);
        QTime t;
        // t.start();
        bool perfect = false;
        auto surface = surfaceXYZ;

        for (int n = 0; n < IterCount; ++n) {
            if (sT == GRES::SimType::KMC)
                perfect = surface->deleteRandomAtomKmc(neighbors, z_min, mask, rates);
            else if (sT == GRES::SimType::CA)
                perfect = surface->deleteRandomAtomCa(z_min, mask, rates);

            if (perfect) {
                surface->addLayer(neighbors, SIZE_X, SIZE_Y, SIZE_Z);
                ++SIZE_Z;
                perfect = true;
            }

            z_min = surface->findZmin(z_min);
            surface->optimize(z_min);
        }
        // qDebug() << "etch: " << t.elapsed();
        z_center = (SIZE_Z - 2 + z_min) / 2;
        drawResult();
    }
示例#3
0
void drawGame(void)
{
    if (state == STATE_LEAVE) return;
    if (isInvalid) {
        arduboy.clear();
        if (state == STATE_ISSUES) {
            drawIssues();
        } else if (state == STATE_RESULT) {
            drawResult();
        } else {
            drawField();
            if (state == STATE_PLAYING) {
                drawStrings();
                drawCursor();
            }
            if (blinkFrameFrames > 0 && blinkFlg) arduboy.drawRect(0, 0, WIDTH, HEIGHT, WHITE);
        }
        isInvalid = false;
    }
    if (state == STATE_MENU || state == STATE_RESULT) {
        drawMenuItems(false);
        arduboy.setRGBled(0, 0, 0);
    } else {
        if (state == STATE_OVER) drawOverAnimation();
        arduboy.setRGBled(ledRGB[0] * vanishFlashFrames, ledRGB[1] * vanishFlashFrames,
                ledRGB[2] * vanishFlashFrames);
    }
}
示例#4
0
文件: IBLWidget.cpp 项目: wdas/brdf
void IBLWidget::paintGL()
{
    if(!isShowing())
        return;

    glcontext->makeCurrent(this);

    glf->glClearColor( 0, 0, 0, 0 );
    glf->glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    recreateFBO();

    envRotMatrix = glm::rotate(glm::mat4(1.f), envPhi, glm::vec3(0, 1, 0));
    envRotMatrix = glm::rotate(envRotMatrix, envTheta, glm::vec3(0, 1, 0));
    envRotMatrixInverse = glm::inverse(envRotMatrix);

    if( numSampleGroupsRendered < stepSize )
    {
        fbo->bind();
        glf->glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
        renderObject();
        fbo->unbind();

        ///////////////////////////////////////
        compResult();

        // another sample group rendered!
        numSampleGroupsRendered++;

        if( renderWithIBL )
        {
            if( numSampleGroupsRendered < stepSize )
                startTimer();
            else
            {
                printf( "done!\n" );
                stopTimer();
            }
        }
        ///////////////////////////////////////
    }

    // now draw the final result
    drawResult();

    glcontext->swapBuffers(this);
}
示例#5
0
void matchImages(int right_img_ix)
{
   // The keypoint structure is expected to have members called x, y, ori,
   // scale, and image. See also MyKeypoint.h
   std::vector< MyKeypoint > left_kpts, right_kpts;

   // A descriptor is stored as a std::bitset
   BRIEF desc;
   std::vector< std::bitset< BRIEF::DESC_LEN > > feat_left, feat_right;

   // Structure providing the ground truth
   static const float TOL = 2.f;     // pixel tolerance for accepting a match
   MatchVerifier< MyKeypoint, GroundTruthMiko > verif("wall/", TOL);

   // Load images
   const IplImage *left_img = verif.getGroundTruth().getImage(1);
   const IplImage *right_img = verif.getGroundTruth().getImage(right_img_ix);
   assert(left_img);
   assert(right_img);

   // Detect, for example, SURF points
   detectSURF(left_img, std::back_inserter(left_kpts), BRIEF::INIT_PATCH_SZ);
   detectSURF(right_img, std::back_inserter(right_kpts), BRIEF::INIT_PATCH_SZ);

   // Compute descriptors
   desc.getBRIEF(left_kpts, feat_left);
   desc.getBRIEF(right_kpts, feat_right);

   // Match descriptors
   printf("[OK] Matching %i against %i descriptors...\n",
          (int)feat_left.size(), (int)feat_right.size());
   BRIEFMatcher< MyKeypoint, BRIEF::DESC_LEN > matcher;
   std::vector< MyKeypoint > match_left, match_right;
   matcher.matchLeftRight(feat_left, feat_right, left_kpts, right_kpts,
                          std::inserter(match_left, match_left.begin()),
                          std::inserter(match_right, match_right.begin()));

   // Compute percentage of correct matches
   float rr = verif.getRecognitionRate(match_left, match_right, right_img_ix);
   printf("[OK] Got %.2f%% of %i retrieved matches right\n", rr*100, (int)match_left.size());

   // Save result image
   drawResult(match_left, match_right, left_img, right_img);
}
示例#6
0
文件: MainWindow.cpp 项目: Hexta/GRES
    void newDocument() {
        mask.clear();
        etchingAction->setEnabled(true);
        maskAction->setEnabled(true);
        saveAct->setEnabled(true);

        QTime t;
        z_min = 0;
        int const xMax = SIZE_X;
        int const yMax = SIZE_Y;
        int const zMax = SIZE_Z;
        z_center = z_min + (zMax - 2 - z_min) / 2;

        cell = Cell(h, k, l);
        Xsize = cell.getXSize();
        Ysize = cell.getYSize();
        Zsize = cell.getZSize();

        Vx = cell.getVx();
        Vy = cell.getVy();
        Vz = cell.getVz();

        cell.optimize();

        auto const numberOfAtomInCell =
            static_cast<unsigned int>(cell.size());
        neighbors = cell.findNeighbors(Xsize, Ysize, Zsize);

        surfaceXYZ.reset(new Surface3D(cell));
        surfaceXYZ->clear();
        surfaceXYZ->reserve(SIZE_Z);
        for (int z = 0; z < SIZE_Z; ++z) {
            Surface2D surfaceXY;
            surfaceXY.reserve(SIZE_Y);
            for (int y = 0; y < SIZE_Y; ++y) {
                Surface1D surfaceX;
                surfaceX.reserve(SIZE_X);
                for (int x = 0; x < SIZE_X; ++x) {
                    Cell cell;
                    for (unsigned char a = 0; a < numberOfAtomInCell; ++a) {
                        Neighbors neighbs;
                        char numberNeighbs = 0; // number of the first neighbors
                        for (int nb = 0; nb < 4; ++nb) {
                            auto& neighborsANb = neighbors[a][nb];
                            if (x + neighborsANb.x >= 0
                                && y + neighborsANb.y >= 0
                                && z + neighborsANb.z >= 0
                                && x + neighborsANb.x < xMax
                                && y + neighborsANb.y < yMax
                                && z + neighborsANb.z < zMax + 1) {
                                ++numberNeighbs;
                                AtomType neighb = {x + neighborsANb.x, y + neighborsANb.y,
                                                   z + neighborsANb.z, neighborsANb.type,
                                                   false};
                                neighbs.push_back(neighb);
                            }
                        }

                        AtomInfo atom;
                        atom.neighbors = neighbs;
                        atom.firstNeighborsCount = numberNeighbs;
                        atom.deleted = numberNeighbs == 0;
                        // TODO: atom.type =
                        cell.addAtom(atom);
                    }
                    surfaceX.push_back(cell);
                }
                surfaceXY.push_back(surfaceX);
            }
            surfaceXYZ->push_back(surfaceXY);
        }
        surfaceXYZ->rebuildSurfaceAtoms();
        drawResult();
    }