Ejemplo n.º 1
0
void Wind::keyPressed( int key )
{
	switch (key){
		case 'c':
			setContrast1( contrast_1 * 1.05f );
			break;
		case 'C':
			setContrast1( contrast_1 / 1.05f );
			break;
		case 'r':
			setContrast2( contrast_2 * 1.05f );
			break;
		case 'R':
			setContrast2( contrast_2 / 1.05f );
			break;
		case 'd':
			draw_debug = !draw_debug;
			break;
			/*		case 'h':
			 which_hsv_channel = 0;
			 break;
			 case 's':
			 which_hsv_channel = 1;
			 break;
			 case 'v':
			 which_hsv_channel = 2;
			 break;
			 case 'g':
			 which_hsv_channel = 3;
			 break;*/
		case 's':
			setStride( stride+1 );
			break;
		case 'S':
			setStride( stride-1 );
			break;
		case 'o':
			setOffset( offset+1 );
			break;
		case 'O':
			setOffset( offset-1 );
			break;
		case 't':
			setStep( step+0.25f );
			break;
		case 'T':
			setStep( step-0.25f );
			break;
			
			
			
		default:
			break;
			
	}
	
}
Ejemplo n.º 2
0
pxError pxOffscreen::init(int width, int height)
{
    // Optimization
    if (bitmap)
    {
        if (width == pxBuffer::width() && height == pxBuffer::height())
            return PX_OK;
    }

    term();  // release all resources if this object is reinitialized

    void *base;
    BITMAPINFO bmpInfo = { { sizeof(BITMAPINFOHEADER), width, height, 1, 32 } };            
    
    bitmap = CreateDIBSection(NULL, (BITMAPINFO*)&bmpInfo, DIB_RGB_COLORS, 
                                (void **)&base, NULL, NULL);
    
    setBase(base);
    setWidth(width);
    setHeight(height);
    setStride(width*4);
    setUpsideDown(true);
    
    return bitmap?PX_OK:PX_FAIL;
}
Ejemplo n.º 3
0
bool Image::copyPixels(unsigned char* pix, unsigned int w, unsigned int h, unsigned format) {

  if(!setPixelFormat(format)) {
    return false;
  }

  if(pixels) {
    delete[] pixels;
    pixels = NULL;
  }

  setWidth(w);
  setHeight(h);
  setStride(w * (bits_per_pixel / 8));
  unsigned int num_bytes =  h * stride;
  pixels = new unsigned char[num_bytes];

  if(!pixels) {
    RX_ERROR(ERR_IMG_CANNOT_ALLOCATE);
    return false;
  }
  
  memcpy(pixels, pix, num_bytes);

  

  return true;
}
Ejemplo n.º 4
0
void ActionWithGrid::turnOnDerivatives(){
  needsDerivatives(); ActionWithValue::turnOnDerivatives(); 
  if( getStride()==1 ) setStride(0);
  else if( getStride()!=0 ) error("conflicting instructions for grid - stride was set but must be evaluated on every step for derivatives - remove STRIDE keyword");
  if( clearstride>1 ) error("conflicting instructions for grid - CLEAR was set but grid must be reset on every step for derivatives - remove CLEAR keyword" ); 
  if( weights.size()>0 ) error("conflicting instructions for grid - LOGWEIGHTS was set but weights are not considered when derivatives of grid are evaluated - remove LOGWEIGHTS keyword"); 
}
Ejemplo n.º 5
0
pxError pxOffscreen::init(int32_t width, int32_t height)
{
  term();

  pxError e = PX_FAIL;

  data = (char*) new unsigned char[width * height * 4];

  if (data)
  {
    setBase(data);
    setWidth(width);
    setHeight(height);
    setStride(width*4);
    setUpsideDown(false);
    e = PX_OK;
  }

  return e;
}
Ejemplo n.º 6
0
bool Wind::buttonPressCallback( GuiButton* b )
{
	//oflog( of_log_verbose, "button pressed: %s (%s)", b->gettitle().c_str(), b->gettag().c_str() );
	bool close_menu = false;
	
	string tag = b->getTag();
	if ( tag == "view_focus" )
	{
		showing_image = SI_FOCUS;
		if ( xoffs == -1 )
		{
			xoffs = colorImg.getWidth()/2-80;
			yoffs = colorImg.getHeight()/2-60;
		}
	}
	else if ( tag == "view_focus_centre" )
	{
		xoffs = colorImg.getWidth()/2-80;
		yoffs = colorImg.getHeight()/2-60;
	}
	else if ( tag == "view_focus_left" )
	{
		xoffs = max(0,xoffs-10);
	}
	else if ( tag == "view_focus_right" )
	{
		xoffs = min(int(colorImg.getWidth()-160),xoffs+10);
	}
	else if ( tag == "view_focus_up" )
	{
		yoffs = max(0,yoffs-10);
	}
	else if ( tag == "view_focus_down" )
	{
		yoffs = min(int(colorImg.getHeight()-120),yoffs+10);
	}

	else if ( tag == "view_none" )
		showing_image = SI_NONE;
	
	else if ( tag == "view_diff" )
		showing_image = SI_DIFF;
	
	else if ( tag == "view_gray_contrasted" )
		showing_image = SI_GRAY_CONTRASTED;
	
	else if ( tag == "calc_cont1_+" )
		setContrast1( contrast_1 * 1.05f );
	else if ( tag == "calc_cont1_-" )
		setContrast1( contrast_1 / 1.05f );
	
#ifndef NEW_TINY
	else if ( tag == "calc_cont2_+" )
		setContrast2( contrast_2 * 1.05f );
	else if ( tag == "calc_cont2_-" )
		setContrast2( contrast_2 / 1.05f );
#endif
	
	else if ( tag == "calc_stride_+" )
		setStride( stride+1 );
	else if ( tag == "calc_stride_-" )
		setStride( stride-1 );
	else if ( tag == "calc_offset_+" )
		setOffset( offset+1 );
	else if ( tag == "calc_offset_-" )
		setOffset( offset-1 );
	else if ( tag == "calc_step_+" )
		setStep( step + 0.25f );
	else if ( tag == "calc_step_-" )
		setStep( step - 0.25f );
	
	else if ( tag == "calc_hsv_seth" )
		setWhichHSVChannel(0);
	else if ( tag == "calc_hsv_sets" )
		setWhichHSVChannel(1);
	else if ( tag == "calc_hsv_setv" )
		setWhichHSVChannel(2);
	else if ( tag == "calc_hsv_setall" )
		setWhichHSVChannel(3);
	
	else if ( tag == "sys_save" )
	{
		((testApp*)ofGetAppPtr())->saveSettings();
		close_menu = true;
	}
	else if ( tag == "sys_reboot_n" || tag == "sys_shutdown_n" )
		close_menu = true;
	else if ( tag == "sys_shutdown_y" )
		system("sudo poweroff");
	else if ( tag == "sys_reboot_y" )
		system("sudo reboot");
	else if ( tag == "sys_cyclewifi" )
	{
		system("sudo cyclewlan0" );
		close_menu = true;
	}
	
	return close_menu;
}
Ejemplo n.º 7
0
void Wind::setup( ofxXmlSettings& data )
{
	
	tiny = (unsigned char*)malloc( TINY_WIDTH*TINY_HEIGHT );
	
	draw_debug = false;
	first_frame = true;
	
	
	pd = new ofxPd();
	pd->init( 0,2,FREQ );
	
	
	pd->openPatch( "sound1/_main.pd" );
	
	bLearnBakground = true;
	threshold = 30;
	
	
	data_send_start_timer = DATA_SEND_START_TIMER;
	
	
#ifdef SCREEN
	screen.setup( "/dev/spidev1.1", /*SPI_CPHA | SPI_CPOL*/0, 40000000 );
	input.setup( "/dev/spidev1.0", 0, 10000000 );
	if ( !input.loadCalibration( data ) )
	{
		input.startCalibration();
	}
#endif
	
	// gui
	gui.setup( 320, 240 );
	gui.setListener( this );
	gui.addButton( "View", "view" );
	gui.addButton( "view", "None", "view_none" );
	gui.addButton( "view", "Focus", "view_focus" );
	gui.addButton( "view_focus", "Centre", "view_focus_centre" );
	gui.addButton( "view_focus", "<-", "view_focus_left" );
	gui.addButton( "view_focus", "->", "view_focus_right" );
	gui.addButton( "view_focus", "/\\", "view_focus_up" );
	gui.addButton( "view_focus", "\\/", "view_focus_down" );
	gui.addButton( "view", "Calc", "view_calc" );
	gui.addButton( "view_calc", "GrayCn", "view_gray_contrasted" );
	gui.addButton( "view_calc", "Diff", "view_diff" );
	
	gui.addButton( "Calc", "calc" );
	gui.addButton( "calc", "Cont 1", "calc_cont1" );
	gui.addButton( "calc_cont1", "+", "calc_cont1_+" );
	gui.addButton( "calc_cont1", "-", "calc_cont1_-" );
#ifndef NEW_TINY
	gui.addButton( "calc", "Cont 2", "calc_cont2" );
	gui.addButton( "calc_cont2", "+", "calc_cont2_+" );
	gui.addButton( "calc_cont2", "-", "calc_cont2_-" );
#endif
	gui.addButton( "calc", "Offset", "calc_offset" );
	gui.addButton( "calc_offset", "+", "calc_offset_+" );
	gui.addButton( "calc_offset", "-", "calc_offset_-" );
	gui.addButton( "calc", "Stride", "calc_stride" );
	gui.addButton( "calc_stride", "+", "calc_stride_+" );
	gui.addButton( "calc_stride", "-", "calc_stride_-" );
	gui.addButton( "calc", "Step", "calc_step" );
	gui.addButton( "calc_step", "+", "calc_step_+" );
	gui.addButton( "calc_step", "-", "calc_step_-" );
	gui.addButton( "calc", "HSV", "calc_hsv" );
	gui.addButton( "calc_hsv", "H(0)", "calc_hsv_seth" );
	gui.addButton( "calc_hsv", "S(1)", "calc_hsv_sets" );
	gui.addButton( "calc_hsv", "V(2)", "calc_hsv_setv" );
	gui.addButton( "calc_hsv", "All(3)", "calc_hsv_setall" );
	
	
	
	gui.addButton( "Sys", "sys" );
	gui.addButton( "sys", "Save", "sys_save" );
	gui.addButton( "sys", "S/down", "sys_shutdown" );
	gui.addButton( "sys_shutdown", "S/down", "sys_shutdown_y" );
	gui.addButton( "sys_shutdown", "Cancel", "sys_shutdown_n" );
	gui.addButton( "sys", "Reboot", "sys_reboot" );
	gui.addButton( "sys_reboot", "Reboot", "sys_reboot_y" );
	gui.addButton( "sys_reboot", "Cancel", "sys_reboot_n" );
	gui.addButton( "sys", "CyWifi", "sys_cyclewifi" );
	
	
	gui.addValue( "Contr1", "cont1", "%.2f" );
	gui.addValue( "Contr2", "cont1", "%.2f" );
	gui.addValue( "Offset", "offset", "%.0f" );
	gui.addValue( "Stride", "stride", "%.0f" );
	gui.addValue( "Step", "step", "%.2f" );
	gui.addValue( "HSV", "hsv", "%.0f" );
	
	showing_image = SI_NONE;
	prev_showing_image = SI_FOCUS;
	xoffs = -1;
	yoffs = -1;
	
	
	
	setWhichHSVChannel( data.getValue( "which_hsv_channel", DEFAULT_HSV_CHANNEL ));
	setContrast1(data.getValue("contrast_1", DEFAULT_CONTRAST_1 ));
	setContrast2(data.getValue("contrast_2", DEFAULT_CONTRAST_2 ));
	setStride(data.getValue( "stride", DEFAULT_STRIDE ));
	setOffset(data.getValue( "offset", DEFAULT_OFFSET ));
	setStep(data.getValue( "step", DEFAULT_STEP ));
	
	
	
	
}