Beispiel #1
0
Try<bool> exists(
    const string& link,
    const Handle& parent,
    uint16_t protocol)
{
  return internal::exists(link, parent, Classifier(protocol));
}
Beispiel #2
0
signed ClassifierPriorityMap (struct classifier_priority_map * map)

{
	printf ("%s Any ", reword (LE32TOH (map->Priority), actions, SIZEOF (actions)));
	Classifier (&map->CLASSIFIER);
	printf (" add perm\n");
	return (0);
}
Beispiel #3
0
Try<bool> update(
    const string& link,
    const Handle& parent,
    uint16_t protocol,
    const action::Mirror& mirror)
{
  return internal::update(
      link,
      Filter<Classifier>(
          parent,
          Classifier(protocol),
          None(),
          None(),
          mirror));
}
Beispiel #4
0
Try<bool> create(
    const string& link,
    const Handle& parent,
    uint16_t protocol,
    const Option<Priority>& priority,
    const Option<Handle>& classid)
{
  return internal::create(
      link,
      Filter<Classifier>(
          parent,
          Classifier(protocol),
          priority,
          None(),
          classid));
}
Beispiel #5
0
signed AutoConnection (struct auto_connection * auto_connection)

{
	int i;
	if (auto_connection->MACTION == ACTION_TAGTX)
	{
		printf ("-T 0x%08X -V %d ", ntohl (auto_connection->cspec.VLAN_TAG), LE16TOH (auto_connection->cspec.CSPEC_VERSION));
	}
	printf ("%s", reword (auto_connection->MACTION, actions, SIZEOF (actions)));
	printf (" %s ", reword (auto_connection->MOPERAND, operands, SIZEOF (operands)));
	for (i = 0; i < LE16TOH (auto_connection->NUM_CLASSIFIERS); ++i)
	{
		Classifier (&auto_connection->CLASSIFIER [i]);
		putchar (' ');
	}
	printf ("add perm\n");
	return (0);
}
Beispiel #6
0
	/**
	*	trains an svm model using the InriaPerson training dataset
	*	choses a number of negative detections randomly chosen from each image
	*	saves the freshly trained model to the harddisk
	*	@param string modelFile: path to the model file
	*/
	void trainSVM(string modelFile){
		vector<string> pos_examples;
		vector<string> neg_examples;
		Classifier classifier = Classifier();
		RNG random_index = RNG( time (NULL) );

		Rect roi(Point(16,16), Point(80, 144));
		Preprocessing::loadPathsByDirectory(TRAIN_POS_NORMALIZED, pos_examples);
		Preprocessing::loadPathsByDirectory(TRAIN_NEG_ORIGINAL, neg_examples);
		for(vector<string>::iterator posIt = pos_examples.begin(); posIt != pos_examples.end(); ++posIt)
		{
			OriginalImage img( *posIt );
			( img ).image = ( img ).image(roi);
			FeatureExtraction::extractHOGFeatures( img );
			classifier.addPositiveExample(img.hog_features);
		}
		for(vector<string>::iterator negIt = neg_examples.begin(); negIt != neg_examples.end(); ++negIt)
		{

			OriginalImage img( *negIt );
			FeatureExtraction::computeHOGPyramid( img );
			FeatureExtraction::computeSlidingWindows( img );

			for(std::vector<Image>::iterator scaleIt = ( img ).lower_images.begin(); scaleIt != ( img ).lower_images.end(); ++scaleIt)
			{
				FeatureExtraction::computeSlidingWindows(*scaleIt);
				
			}

			int count = 0;
			double howMuch = ( (double)( MAXRANDOMELEMENTS ) / (double)( img.lower_images.size() + 1 ) );
			for( int i = 0; i < (int)( howMuch ); i++ )
			{
				classifier.addNegativeExample( img.slidingWindows[ random_index.uniform( 0, img.slidingWindows.size() ) ].hog_features );
				count++;
			}
			howMuch = howMuch + ( (double)( MAXRANDOMELEMENTS ) / (double)( img.lower_images.size() + 1) ) - (int)howMuch;
			if( howMuch < MAXRANDOMELEMENTS )
				for( int current = 0; current < img.lower_images.size(); current++ )
				{
					for( int i = 0; i < (int)( howMuch ); i++ )
					{
						int y = random_index.uniform( 0, img.lower_images[ current ].slidingWindows.size() );
						Mat hog_features = img.lower_images[ current ].slidingWindows[ y ].hog_features;
						classifier.addNegativeExample( hog_features );
						count++;
					}
					howMuch = howMuch + ( (double)( MAXRANDOMELEMENTS ) / (double)( img.lower_images.size() + 1) ) - (int)howMuch;
				}
				while( count < MAXRANDOMELEMENTS )
				{
					int x = random_index.uniform( 0, img.lower_images.size() );
					int y = random_index.uniform( 0, img.lower_images[ x ].slidingWindows.size() );
					Mat hog_features = img.lower_images[ x ].slidingWindows[ y ].hog_features;
					classifier.addNegativeExample( hog_features );
					count++;
				}
				
		}
		classifier.train( MODEL_STANDARD_FILE );

		classifier.loadModel( MODEL_STANDARD_FILE );

		for(vector<string>::iterator negIt = neg_examples.begin(); negIt != neg_examples.end(); ++negIt)
		{

			OriginalImage img( *negIt );
			FeatureExtraction::computeHOGPyramid( img );
			FeatureExtraction::computeSlidingWindows( img );

			
			for( vector<SlidingWindow>::iterator it= img.slidingWindows.begin(); it != img.slidingWindows.end(); ++it )
			{
				if( classifier.classify( ( *it ).hog_features ) > 0.0 )
				{
					classifier.addNegativeExample( (*it ).hog_features );
				}

			}


			for(std::vector<Image>::iterator scaleIt = ( img ).lower_images.begin(); scaleIt != ( img ).lower_images.end(); ++scaleIt)
			{
				FeatureExtraction::computeSlidingWindows(*scaleIt);

				for( vector<SlidingWindow>::iterator it= ( *scaleIt ).slidingWindows.begin(); it != ( *scaleIt ).slidingWindows.end(); ++it )
				{
					if( classifier.classify( ( *it ).hog_features ) > 0.0 )
					{
						classifier.addNegativeExample( (*it ).hog_features );
					}

				}
				
			}



		}

		classifier.train( MODEL_HARD_EX_FILE );
	}