Exemplo n.º 1
0
//----------------------------------------------------------------------------
//
//  Test:           test_tuner
//
//  Description:    Iterates through each of the known local channels,
//                  and attempts to save an image from each of them.
//
//  Setup:          - Source is TV tuner
//                  - Tunes to each local channel sequentially
//                  - Uses standard window sizing
//                  - Saves in RGB24 format
//
//----------------------------------------------------------------------------
int test_tuner( FRAMEGRABBER* fg )
{
    FRAME* frame = NULL;
    char fname[32];
    int i;

    _T( fg_set_format( fg, VIDEO_PALETTE_RGB32 ) );
    _T( fg_set_capture_window( fg, 0, 0, 320, 240 ) );
    _N( frame = fg_new_compatible_frame( fg ) );

    for ( i = 0; i < sizeof(local)/sizeof(CHANNEL); i++ )
    {
        printf( "%u. Saving %s @ %fMHz\n", i, local[i].name, local[i].freq );

        _T( fg_set_channel( fg, local[i].freq ) );

        // Catch up to the new tuning
        _N( fg_grab_frame( fg, frame ) );
        _N( fg_grab_frame( fg, frame ) );

        snprintf( fname, sizeof(fname), "test_%s.ppm", local[i].name );

        _T( frame_save( frame, fname ) );
    }
    frame_release( frame );

    return 0;
}
Exemplo n.º 2
0
FRAME* fg_grab( FRAMEGRABBER* fg )
{
    return fg_grab_frame( fg,
                          frame_new( fg->window.width,
                                     fg->window.height,
                                     fg->picture.palette ) );
}
Exemplo n.º 3
0
//----------------------------------------------------------------------------
//
//  Test:           test_timing
//
//  Description:    Grabs a series of frames, and times how long each takes
//                  in a tight loop that also pretends to do some "processing"
//                  (by sleeping).
//
//  Setup:          - Source is default
//                  - Tuned to default
//                  - Uses standard window sizing and format
//
//----------------------------------------------------------------------------
int test_timing( FRAMEGRABBER* fg )
{
    FRAME* frame = NULL;
    struct timeval start_time, end_time;
    int i;

    printf( "Capture timings...\n" );

    _T( fg_set_channel( fg, local[0].freq ) );
    _T( fg_set_format( fg, VIDEO_PALETTE_RGB32 ) );
    _T( fg_set_capture_window( fg, 0, 0, 768, 576 ) );

    _N( frame = frame_new( 768, 576, VIDEO_PALETTE_RGB32 ) );

    for ( i = 0; i < 20; i++ )
    {
        gettimeofday( &start_time, NULL );

        fg_grab_frame( fg, frame );

        // Image crunching step would be here
        usleep(35);

        gettimeofday( &end_time, NULL );

        // This subtraction doesn't handle wrapping
        printf( "Elapsed time = %lu secs %lu usecs\n",
                ( end_time.tv_sec  - start_time.tv_sec  ),
                ( end_time.tv_usec - start_time.tv_usec ) );
    }

    return 0;
}
Exemplo n.º 4
0
fg_frame *fg_grab(fg_grabber *fg)
{
    fg_frame *fr = fg_frame_new(fg);

    if (fr == NULL)
    {
        fg_debug_error("fg_grab(): ran out of memory allocating frame");
        return NULL;
    }

    if (fg_grab_frame(fg, fr) == -1)
    {
        free(fr);
        return NULL;
    }

    return fr;
}