Beispiel #1
0
void MainError::show_error_local(const char *string)
{
SET_TRACE
// assume user won't get to closing the GUI here
	lock_window("MainError::show_error_local");
SET_TRACE
	if(get_gui())
	{
SET_TRACE
		MainErrorGUI *gui = (MainErrorGUI*)get_gui();
		gui->lock_window("MainError::show_error_local");
SET_TRACE
		append_error(string);
SET_TRACE
		gui->list->update(&errors,
			0,
			0,
			1,
			gui->list->get_xposition(),
			gui->list->get_yposition(),
			gui->list->get_highlighted_item(),  // Flat index of item cursor is over
			0,     // set all autoplace flags to 1
			1);
SET_TRACE
		gui->unlock_window();
		unlock_window();
SET_TRACE
		start();
SET_TRACE
	}
	else
	{
Beispiel #2
0
int
ChromaKeyColorThread::handle_new_color (int output, int alpha)
{
  plugin->config.red = (float) (output & 0xff0000) / 0xff0000;
  plugin->config.green = (float) (output & 0xff00) / 0xff00;
  plugin->config.blue = (float) (output & 0xff) / 0xff;

  get_gui()->unlock_window();
  gui->lock_window("ChromaKeyColorThread::handle_new_color");
  gui->update_sample ();
  gui->unlock_window();
  get_gui()->lock_window("ChromaKeyColorThread::handle_new_color");


  plugin->send_configure_change ();
  return 1;
}
Beispiel #3
0
void Application::run(const std::string &filename)
{
	GuiEditorWindow main_window(get_gui());

	if(!filename.empty())
		main_window.load(filename);

	gui.exec();
}
Beispiel #4
0
void PreferencesThread::update_rates()
{
	if(thread_running)
	{
		lock_gui("PreferencesThread::update_framerate");
		PreferencesWindow *window = (PreferencesWindow*)get_gui();
		if(window) window->update_rates();
		unlock_gui();
	}
}
Beispiel #5
0
void ConfirmScanThread::handle_done_event(int result)
{
	gui->channel_picker->save_scan_defaults(&gui->thread->scan_params);
	if(!result)
	{
		get_gui()->hide_window();
		gui->lock_window("ConfirmScanThread::handle_done_event");
		gui->scan();
		gui->unlock_window();
	}
}
Beispiel #6
0
C_RESULT output_gtk_stage_transform( void *cfg, vp_api_io_data_t *in, vp_api_io_data_t *out)
{
  static int frame = 0;
  static int mass = 0, x_center = -1, y_center = -1;
  unsigned char mask_buf[WIDTH*HEIGHT];
  uint8_t display_data[WIDTH*HEIGHT*3];
  int is_hover;
  static int width, height;
  static int is_face = 0;
  int camshift_error;
  static float this_hue_buf[WIDTH*HEIGHT];
  static float last_hue_buf[WIDTH*HEIGHT];
  int i;
  static camshift_frames = 0;
  FILE *fp;
  char filename[50];
  
  frame++;

  // GET FRAME FROM VIDEO FEED
  vp_os_mutex_lock(&video_update_lock);
  pixbuf_data      = (uint8_t*)in->buffers[0];
  vp_os_mutex_unlock(&video_update_lock);

  // Process frame for orange ball
  // UNCOMMENT TO DETECT BALL
  //process_frame_ball(pixbuf_data, mask_buf, &mass, &x_center, &y_center);
  
  // UNCOMMENT TO DETECT FACES
  if (is_face == 0) {
    //printf("Detecting face...\n");
    process_frame_face(pixbuf_data, &mass, &x_center, &y_center, &width, &height);
    if (mass > 8) {
      is_face = 1;
      rgb2hue(pixbuf_data, last_hue_buf);
      printf("DETECT!!! x,y = %d, %d\n", x_center, y_center);
    }
  } else {
    rgb2hue(pixbuf_data, this_hue_buf);
    camshift_error = camshift(last_hue_buf, this_hue_buf, &x_center, &y_center, width, height);
    printf("camshift x,y = %d, %d\n", x_center, y_center);

    // copy this buffer to last buffer
    for (i=0; i<WIDTH*HEIGHT; i++) {
      last_hue_buf[i] = this_hue_buf[i];
    }
    
    if (camshift_error) {
      printf("CAMSHIFT ERROR\n");
      is_face = 0;
      x_center = -1;
      y_center = -1;
    }
    camshift_frames++;
    // about two seconds
    if (camshift_frames > 30) {
      printf("!!check to see if we are still tracking\n");
      camshift_frames = 0;
      is_face = 0;
    }
  }
  
  // we did not use the mask, so make it all black
  clear_mask(mask_buf);

  // write pixbuf to file
  sprintf(filename, "/home/a/pixbuf/pixbuf_%d.ppm", frame);
  fp = fopen(filename, "w");
  // write header
  fprintf(fp, "P6\n320 240\n255\n");
  for (i=0; i<320*240*3; i++) {
    fprintf(fp, "%c", pixbuf_data[i]);
  }
  fclose(fp);
  
  fp = fopen("/home/a/meanshift_log.txt", "a");
  // write log
  // framenum, mass, centroid_x, centroid_y, width, height
  fprintf(fp, "%d %d %d %d %d %d\n", frame, mass, x_center, y_center, width, height);
  
  // Get mask display
  display_mask(mask_buf, display_data, x_center, y_center);
  
  // Fly drone
  is_hover = fly(x_center, y_center, mass);

  // Print status
  printf("Frame number: %d\n", frame);
  printf("Mass: %d; Centroid: (%d, %d)\n", mass, x_center, y_center);
  printf("Meanshift Width: %d; Height: %d\n", width, height);
  printf("\033[2J");

  gdk_threads_enter();
  // GdkPixbuf structures to store the displayed picture
  static GdkPixbuf *pixbuf = NULL;
  static GdkPixbuf *maskbuf = NULL;

  if (pixbuf != NULL) {
    g_object_unref(pixbuf);
    pixbuf=NULL;
  }

  // Create GdkPixbuf from color frame data
  pixbuf = gdk_pixbuf_new_from_data(pixbuf_data,
  				    GDK_COLORSPACE_RGB,
  				    FALSE,    // No alpha channel
  				    8,        // 8 bits per pixel
  				    320,      // Image width
				    240,
  				    320 * 3,  // new pixel every 3 bytes (3channel per pixel)
  				    NULL,     // Function pointers
  				    NULL);
  // Create the GdkPixbuf from color mask display buffer
  maskbuf = gdk_pixbuf_new_from_data(display_data,
  				    GDK_COLORSPACE_RGB,
  				    FALSE,    // No alpha channel
  				    8,        // 8 bits per pixel
  				    320,      // Image width
				    240,
  				    320 * 3,  // new pixel every 3 bytes (3channel per pixel)
  				    NULL,     // Function pointers
  				    NULL);
  gui_t *gui = get_gui();

 // Display the image
  if (gui && gui->cam) {
    gtk_image_set_from_pixbuf(GTK_IMAGE(gui->cam), pixbuf);
    // also display the pixbuf in a second window
    if (gui->mask_cam) {
      gtk_image_set_from_pixbuf(GTK_IMAGE(gui->mask_cam), maskbuf);
    }
  }
  gdk_threads_leave();
  
  return (SUCCESS);
}