Esempio n. 1
0
void progress_setinfo( char * info )
{
  /*if( progress_info != info )
  {*/
    ObjcString( progress_tree, PB_STATUS, info );
    progress_display_object( PB_STATUS );
    progress_info = info;
    progress_display();
  /*} */
}
Esempio n. 2
0
void progress_setcount( long count )
{
  progress_count = count;
  if( progress_calc_prct() != progress_prct )
    progress_display();
}
void ComputeFeatureChannelsApplication::main_loop()
{

    const bool should_print = not silent_mode;
    if(silent_mode)
    {
        printf("The application is running in silent mode. "
               "No information will be printed until all the frames have been processed.\n");
    }


    int num_iterations = 0;
    const int num_iterations_for_timing = 10;
    //const int num_iterations_for_timing = 100;
    double cumulated_processing_time = 0;
    double start_wall_time = omp_get_wtime();

    bool video_input_is_available = directory_input_p->next_frame();

    AbstractChannelsComputer::channels_t channels;
    ImagesFromDirectory::input_image_view_t input_view = directory_input_p->get_image();
    channels.resize(boost::extents[channels_computer_p->get_num_channels()][input_view.height()][input_view.width()]);

    progress_display_with_eta progress_display(num_files_to_process);
    bool end_of_game = false;

    while(video_input_is_available and (not end_of_game))
    {

        // update video input --
        ImagesFromDirectory::input_image_view_t input_view = directory_input_p->get_image();

        // we start measuring the time before uploading the data to the GPU
        const double start_processing_wall_time = omp_get_wtime();

        if((static_cast<size_t>(input_view.height()) != channels.shape()[1])
                or (static_cast<size_t>(input_view.width()) != channels.shape()[2]))
        {
            printf("First image size (height, width) == %zix%zi\n", channels.shape()[1], channels.shape()[2]);
            printf("Current input image size (height, width) == %lix%li\n", input_view.height(), input_view.width());
            throw std::invalid_argument("ComputeFeatureChannelsApplication"
                                        "expects all input images to have the same size");
        }

        channels_computer_p->set_image(input_view);
        channels_computer_p->compute();

        const AbstractChannelsComputer::channels_t &computed_channels = \
                channels_computer_p->get_input_channels_uint16();

        assert(channels.shape()[0] == computed_channels.shape()[0]);
        assert(channels.shape()[1] == computed_channels.shape()[1]);
        assert(channels.shape()[2] == computed_channels.shape()[2]);

        channels = computed_channels; // copy the elements

        // Hack to create paper image
        if(false) //and ((input_view.width() == 96) and (input_view.height() == 160)))
        {
            patch_borders(channels);

            const int shrinking_factor = 4;

            AbstractChannelsComputer::channels_t shrunk_channels;
            allocate_shrunk_channels(channels, shrinking_factor, shrunk_channels);
            shrink_channels(channels, shrinking_factor, shrunk_channels);

            /*typedef boost::multi_array_types::index_range range;
            AbstractChannelsComputer::channels_t::const_array_view<3>::type detection_channels_view =
                    shrunk_channels[
                    boost::indices[range()]
                    [range(16/shrinking_factor, (16+128)/shrinking_factor)]
                    [range(16/shrinking_factor, (16+64)/shrinking_factor)] ];

            channels.resize(boost::extents[detection_channels_view.shape()[0]]
                    [detection_channels_view.shape()[1]]
                    [detection_channels_view.shape()[2]]);

            channels = detection_channels_view; // copy the data*/

            channels.resize(boost::extents[shrunk_channels.shape()[0]]
                    [shrunk_channels.shape()[1]]
                    [shrunk_channels.shape()[2]]);

            channels = shrunk_channels; // copy the data

        }


        cumulated_processing_time += omp_get_wtime() - start_processing_wall_time;


        // save the channels in the corresponding file --
        std::string filename = directory_input_p->get_image_name();
        filename.append(".png"); // the final filename will be of the kind "something.jpeg.png"
        //const boost::filesystem::path output_filename = output_path / filename;
        const boost::filesystem::path output_filename = get_recording_path() / filename;
        save_channels_to_file(channels, output_filename);

        // update user interface --
        end_of_game = update_gui();

        num_iterations += 1;

        // false since progress_display will provide the corresponding information
        if(false and should_print and ((num_iterations % num_iterations_for_timing) == 0))
        {
            printf("Average iteration speed  %.4lf [Hz] (in the last %i iterations)\n",
                   num_iterations_for_timing / (omp_get_wtime() - start_wall_time) , num_iterations_for_timing );
            start_wall_time = omp_get_wtime(); // we reset timer
        }


        ++progress_display; // update progress display

        // retrieve next input image
        video_input_is_available = directory_input_p->next_frame();

    } // end of "while video input and not end of game"


    printf("Processed a total of %i input frames\n", num_iterations);
    if(cumulated_processing_time > 0)
    {
        printf("Average processing time per iteration %.2lf [Hz] (in the last %i iterations)\n",
               num_iterations / cumulated_processing_time , num_iterations );
    }


    return;
} // end of void ComputeFeatureChannelsApplication::main_loop