Пример #1
0
//--------------------------------------------------------------
void testApp::keyPressed(int key){
    
    
    if (key == 101){            // if 'e' pressed, export points
        
        for (int i = 0; i < points.size(); i++){
            ofLogNotice() << points.at(i);
        }
        
    } else if (key == 99){      // 'c' to generate new colors
        generateColors();
    } else if (key == 357) {    // 'up' to move hue clockwise
        myHue++;
        ofLogNotice() << myHue;
        generateColors();
    } else if (key == 359) {    // 'down' to move hue counterclockwise
        myHue--;
        ofLogNotice() << myHue;
        generateColors();
    } else if ( key == 97){     // 'a' to check smoothing disabled
        ofDisableSmoothing();
    } else if (key == 115){     // 's' save pdf
        saveScreen = true;
    } else {
        ofLogNotice() << key;
    }

}
Пример #2
0
GeometryBufferPtr GizmoRotate::generateCircles()
{
	// Vertex data
	std::vector< Vector3 > pos;
	std::vector< Vector3 > colors;

	Matrix4x3 transform;

	// X axis
	std::vector< Vector3 > posX;
	generateCircle(posX, SLICES);
	generateColors(colors, X);

	transform = Matrix4x3::createScale( Vector3(0.4f) );
	TransformVertices(pos, posX, transform);

	// Y axis
	std::vector< Vector3 > posY;
	generateCircle(posY, SLICES);
	generateColors(colors, Y);
	
	transform = Matrix4x3::createScale( Vector3(0.4f) );
	transform = transform*Matrix4x3::createRotation( EulerAngles(0, 90, 0) );
	TransformVertices(pos, posY, transform);
	
	// Z axis
	std::vector< Vector3 > posZ;
	generateCircle(posZ, SLICES);
	generateColors(colors, Z);

	transform = Matrix4x3::createScale( Vector3(0.4f) );
	transform = transform*Matrix4x3::createRotation( EulerAngles(90, 0, 0) );
	TransformVertices(pos, posZ, transform);

	// Translate it a bit.
	transform = Matrix4x3::createTranslation( Vector3::UnitY * 0.5f );
	for( uint i = 0; i < pos.size(); i++ )
	{
		Vector3& v = pos[i];
		v = transform*v;
	}

	// Vertex buffer setup
	GeometryBufferPtr gb = AllocateHeap(GeometryBuffer);

	assert( pos.size() == colors.size() );

	gb->set( VertexAttribute::Position, pos );
	gb->set( VertexAttribute::Color, colors );
	
	return gb;
}
Пример #3
0
action2ValuePair min_Value(int clr,int alpha, int beta){
	action2 a2;
	if(terminal_Test()){
		double util=currentState->utility(count);
		int d=currentState->depth;
		action2ValuePair a2v(chance[d]*util,a2);
		return a2v;
	}
	double v=10000;
	vector<colorNode> cn=generateColors(clr);
	vector<action2> actions=chaosActions(cn);
	int l=actions.size();
	for(int i=0;i<l;i++){
		nodecount++;
		action2 a=actions.at(i);
		chaosMove(a);
		double val=max_Value(alpha,beta).value;
		chaosDeMove(a);
		if(v>val){
			v=val;
			a2=a;
		}
		if(v<alpha){
			action2ValuePair a2v(v,a2);
			return a2v;
		}
		if(beta>v){
			beta=v;
		}
	}
	action2ValuePair a2v(v,a2);
	return a2v;
}
Пример #4
0
Board::Board(int topleftX, int topleftY) : numSquaresWide(10)
{
	generateColors();

	createBoard(topleftX, topleftY);

	liveSquares.insert(board[0]);
}
Пример #5
0
//--------------------------------------------------------------
void testApp::setup(){
    
    ofEnableSmoothing();
    
    myHue = 136.70;
    
    // Debug mode was used to draw out my points.
    // I played around with the points and the triangles for a while
    // just trying to find what shape I liked.
    // The shape I came up with was inspired by, but didn't use
    // Delaunay triangulation
    if (debug){
        for (int i = 0; i < 10; i++){
            points.push_back(ofPoint(0,0));
        }
        currentPoint = 0;
    } else {
        points.push_back(ofPoint(235, 149));
        points.push_back(ofPoint(366, 93));
        points.push_back(ofPoint(321, 211));
        points.push_back(ofPoint(412, 215));
        points.push_back(ofPoint(469, 167));
        points.push_back(ofPoint(483, 257));
        points.push_back(ofPoint(424, 360));
        points.push_back(ofPoint(286, 353));
        points.push_back(ofPoint(302, 279));
        points.push_back(ofPoint(206, 231));
    }
    
    triangles.push_back(ofVec3f(0, 1, 2));
    triangles.push_back(ofVec3f(1, 2, 3));
    triangles.push_back(ofVec3f(1, 3, 4));
    triangles.push_back(ofVec3f(3, 4, 5));
    triangles.push_back(ofVec3f(3, 5, 6));
    
    triangles.push_back(ofVec3f(6, 3, 2));
    triangles.push_back(ofVec3f(6, 8, 7));
    triangles.push_back(ofVec3f(7, 8, 9));
    triangles.push_back(ofVec3f(9, 8, 2));
    triangles.push_back(ofVec3f(0, 9, 2));


    
    
    
    
    
    generateColors();
    
    
    
}
/**
 * Escribe los resultados en el archivo dado. Genera una imagen
 * PNG.
 *
 * @param output Archivo de salida.
 * @param sol    Solución final.
 * @param k      Cantidad de clusters.
 */
void ImageReader::write(char* output, int* sol, float** colors, int k){
    int i;
    //float **colors;
    vector<unsigned char> image;
    image.resize(N * 4);
    vector<unsigned char>::iterator imageIterator = image.begin();

    if(GENERATION) {
        if( (colors = (float **) calloc(k, sizeof(float *) )) == NULL){
            fprintf(stderr, "Error pidiendo memoria.\n");
            exit(1);
        }

        for(i = 0; i < k; ++i)
            colors[i] = new float[M];

        generateColors(colors, k);
    }

    i = 0;
    while (imageIterator != image.end()) {
        *imageIterator = (unsigned char) (colors[sol[i]][0]);
        imageIterator++;
        *imageIterator = (unsigned char) (colors[sol[i]][1]);
        imageIterator++;
        *imageIterator = (unsigned char) (colors[sol[i]][2]);
        imageIterator++;
        *imageIterator = (unsigned char) 255;
        imageIterator++;
        ++i;
    }
    LodePNG::encode(output, image, (int)width, (int)height);

    //Hacer Tabla de resultados. Probablemente hay que agregar
    //parámetros.

    if(GENERATION) {
        for(i = 0; i < k; ++i)
            delete [] colors[i];
        free(colors);
    }
}
Пример #7
0
antPlane::antPlane
( float width, float depth, int nColumns, int nRows,
 int nVbo, bool genColors,
 bool genNormals, bool genTexCoords ) :
antDrawable( nVbo, ATTR_POSITION ),
m_width( width ),
m_depth( depth ),
m_nColumns( nColumns ),
m_nRows( nRows )
{
    m_nVertices = ( m_nColumns * m_nRows * 6 );

    antRGBA color1( 0.f, 0.f, 0.f, 1.f );
    antRGBA color2( 1.f, 1.f, 1.f, 1.f );
    
    generateVertices();
    
    if ( genColors ) { generateColors( color1, color2 ); }
    if ( genNormals ) { generateNormals(); }
    if ( genTexCoords ) { generateTexCoords(); }    
}
Пример #8
0
const glm::vec4& ColorManager::newColor()
{
  if (_index >= static_cast<int>(_colors.size()))
    generateColors(50);
  return _colors[_index++];
}
Пример #9
0
int main(int argc, char **argv)
{
  /* create resizable window */
  cvNamedWindow(window_name, CV_WINDOW_NORMAL);
  cvStartWindowThread();

  ros::init(argc, argv, "points_image_d_viewer");
  ros::NodeHandle n;
  ros::NodeHandle private_nh("~");

  std::string image_topic_name;
  std::string car_node;
  std::string pedestrian_node;
  std::string points_node;

  if (private_nh.getParam("image_raw_topic", image_topic_name)) {
    ROS_INFO("Setting image topic to %s", image_topic_name.c_str());
  } else {
    ROS_INFO("No image topic received, defaulting to image_raw, you can use _image_raw_topic:=YOUR_NODE");
    image_topic_name = "/image_raw";
  }

  if (private_nh.getParam("car_node", car_node)) {
    ROS_INFO("Setting car positions node to %s", car_node.c_str());
  } else {
    ROS_INFO("No car positions node received, defaulting to car_pixel_xyz, you can use _car_node:=YOUR_TOPIC");
    car_node = "/obj_car/image_obj_ranged";
  }

  if (private_nh.getParam("pedestrian_node", pedestrian_node)) {
    ROS_INFO("Setting pedestrian positions node to %s", pedestrian_node.c_str());
  } else {
    ROS_INFO("No pedestrian positions node received, defaulting to pedestrian_pixel_xyz, you can use _pedestrian_node:=YOUR_TOPIC");
    pedestrian_node = "/obj_person/image_obj_ranged";
  }

  if (private_nh.getParam("points_node", points_node)) {
    ROS_INFO("Setting pedestrian positions node to %s", points_node.c_str());
  } else {
    ROS_INFO("No points node received, defaulting to points_image, you can use _points_node:=YOUR_TOPIC");
    points_node = "/points_image";
  }

#if (CV_MAJOR_VERSION == 3)
	generateColors(_colors, 25);
#else
	cv::generateColors(_colors, 25);
#endif

  ros::Subscriber scriber = n.subscribe(image_topic_name, 1,
                                        image_cb);
  ros::Subscriber scriber_car = n.subscribe(car_node, 1,
                                            car_updater_callback);
  ros::Subscriber scriber_ped = n.subscribe(pedestrian_node, 1,
                                            ped_updater_callback);
  ros::Subscriber scriber_points = n.subscribe(points_node, 1,
                                               points_cb);

  cv::Mat grayscale(256,1,CV_8UC1);
  for(int i=0;i<256;i++) {
    grayscale.at<uchar>(i)=i;
  }
  cv::applyColorMap(grayscale,colormap,cv::COLORMAP_JET);

  ros::spin();

  cvDestroyWindow(window_name);

  return 0;
}
ClosePointDitherGenerator::ClosePointDitherGenerator()
                          :ColorGenerator(){
    generateColors();
}