예제 #1
0
IplImage* SimpleFilter::process( IplImage* frame )
{
    IplImage* gray = 0;

    gray = cvCreateImage( cvGetSize(frame), IPL_DEPTH_8U, 1 );

    cvCvtColor( frame, gray, CV_RGB2GRAY );

    cvThreshold( gray, gray, 135, 255, CV_THRESH_BINARY );

    //cvLaplace( gray, gray, 1 );

    /*
    for( int i = 0; i < gray->width; ++i )
    {
        for( int j = 0; j < gray->height; ++j )
        {
            if( gray->imageData[ i + gray->widthStep * j] < 130 )
            {
                gray->imageData[ i + gray->widthStep * j] = 255;
            }
            else
            {
                gray->imageData[ i + gray->widthStep * j] = 0;
            }
        }
    }
    */

    //return gray;

    //cvErode( gray, gray, NULL, 1 );

    //if( gray->imageData[ i + gray->widthStep * j] == 0)

    //cvLaplace( gray, gray, 1 );

    //return gray;

    //return gray;

    CvMemStorage* storage = cvCreateMemStorage( 0 );

    CvSeq* root = NULL;
    cvFindContours( gray, storage, &root, sizeof( CvContour ), CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, cvPoint( 0, 0 ) );

    QVector<CvSeq*> contours = collectContours( root );

    QVector<Vertex> qrCodes = findQrCode( contours );

    drawDebugInfo( frame, qrCodes, contours );

    cvReleaseImage( &gray );
    cvReleaseMemStorage( &storage );
    return frame;
}
예제 #2
0
파일: callbacks.cpp 프로젝트: reafle/kgps3
void SceneDisplayCallback(void) {

    // Setup viewing transformation
    glLoadIdentity();
    glScalef(scale, scale, scale);
    glTranslatef(translation[0], translation[1], 0.0);

    // Set projection transformation
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45.0, (GLfloat) GLUTwindow_width / (GLfloat) GLUTwindow_height, 0.1, 100.0);

    // Set camera transformation
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslatef(translation[0], translation[1], translation[2]);
    glScalef(scale, scale, scale);
    glRotatef(rotation[0], 1.0, 0.0, 0.0);
    glRotatef(rotation[1], 0.0, 1.0, 0.0);
    glRotatef(rotation[2], 0.0, 0.0, 1.0);
    glTranslatef(-center[0], -center[1], -center[2]);

    // Clear window 
    glClearColor(0.0, 0.0, 0.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Set lights
    glLightfv(GL_LIGHT0, GL_POSITION, difflight_position);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, difflight_color);

    static GLfloat light1_position[] = {-3.0, -4.0, -5.0, 0.0};
    glLightfv(GL_LIGHT1, GL_POSITION, light1_position);


    // Draw stuff 
    drawScene();
    drawDebugInfo();

    processAnimation();
    // Swap buffers 
    glutSwapBuffers();

}
예제 #3
0
파일: drawings.cpp 프로젝트: reafle/kgps1
void drawScene(void) {

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

    glLoadIdentity();
    glTranslatef(-1, -1, 0);

    glPushMatrix();
    glScalef((GLfloat) 2 / MATRIX_SIZE, (GLfloat) 2 / MATRIX_SIZE, 0);
    glColor3f(0.7f, 0.7f, 0.7f);

    for (int i = 0; i < MATRIX_SIZE; i++) {
        for (int j = 0; j < MATRIX_SIZE; j++) {
            glPushMatrix();
            glTranslatef((GLfloat) i, (GLfloat) j, 0);
            drawSquareBorder();
            glPopMatrix();
        }
    }

    glPopMatrix();


    /* making sure we have both points set */
    if (linex1 * liney1 * linex2 * liney2 > 0) {
        drawBresenhamLine();
        drawLine();
    }

    drawLinePoints();
    drawDebugInfo();

    glFlush();

}