示例#1
0
 void read_from_yaml(cv::FileNode node, bool& b)
 {
   ntk_throw_exception_if(node.empty(), "Could not read " + node.name() + " from yaml file.");
   int i = cvReadInt(*node, -1);
   ntk_assert(i >= 0 && i <= 1, "Invalid boolean value");
   b = i;
 }
示例#2
0
文件: rfs.cpp 项目: sc2h6o/Face-LBF
void RFS::read(const cv::FileNode &fn)
{
	rtrees.clear();
	for (auto it = fn.begin(); it != fn.end(); ++it)
	{
		RTree rfs;
		*it >> rfs;
		rtrees.push_back(rfs);
	}
}
示例#3
0
 cv::Ptr<Camera> Camera::read( const cv::FileNode& node )
 {
   std::string myName=node.name( );
   if( myName != "Camera" )
   {
     std::string error = "Camera FileNode is not correct!\nExpected \"Camera\", got ";
     error += node.name();
     CV_Error( CV_StsError, error.c_str() );
   }
   //nothing to do as we are a fake camera...
   return cv::Ptr<Camera>( NULL );
 }
bool ConfigurationDataReader::loadConfigurationFromFileNode(const cv::FileNode &dataFileNode)
{
    bool success = true;
    
    cv::FileNodeIterator itEnd = dataFileNode.end();
    for (cv::FileNodeIterator it = dataFileNode.begin(); it != itEnd && success; it++)
    {
        const char *newDataValueName = (*it).name().c_str();
        success = success && loadNodeFromFileNode(dataFileNode, newDataValueName);
    }
    
    return success;
}
示例#5
0
inline void read(const cv::FileNode& node, LabelInfo& x, const LabelInfo& default_value = LabelInfo())
{
    if(node.empty())
        x = default_value;
    else
        x.read(node);
}
示例#6
0
 void read(const cv::FileNode &fn, BikeFeatures &bf, const BikeFeatures & default_value) {
   if (fn.empty()) {
     bf = default_value;
   } else {
     bf.read(fn);
   }
 }
示例#7
0
void read(const cv::FileNode& node, ImageSourceSettings& settings,
    const ImageSourceSettings& default_settings)
{
    if(node.empty())
    settings = default_settings;
    else
    settings.read(node);
}
示例#8
0
void read(const cv::FileNode& node, MeshLoadingSettings& settings,
    const MeshLoadingSettings& default_settings)
{
    if(node.empty())
    settings = default_settings;
    else
    settings.read(node);
}
示例#9
0
void read(const cv::FileNode& node, TrackerSettings& settings,
    const TrackerSettings& default_settings)
{
    if(node.empty())
    settings = default_settings;
    else
    settings.read(node);
}
示例#10
0
// Following must be defined for the serialization in FileStorage to work
static void read(
    const cv::FileNode &node, FeatureTrackerOptions &x,
    const FeatureTrackerOptions &default_value = FeatureTrackerOptions()) {
  if (node.empty())
    x = default_value;
  else
    x.read(node);
}
示例#11
0
文件: rfs.cpp 项目: sc2h6o/Face-LBF
void read(const cv::FileNode& node, RFS &f, const RFS& default_value)
{
	if (node.empty())
	{
		f = default_value;
		cout << "! One default Regressor." << endl;
	}
	else
		f.read(node);
}
void read(const cv::FileNode& node, Regressor& r, const Regressor& default_value)
{
	if (node.empty())
	{
		r = default_value;
		cout << "One default Regressor. Model file is corrupt!" << endl;
	}
	else
		r.read(node);
}
static void read(const cv::FileNode& node, observation& x,
		const observation& default_value = observation()) {
	if (node.empty()) {
		x = default_value;
	} else {

		x.cam_id = (int) node["cam_id"];
		x.point_id = (int) node["point_id"];
		x.coord[0] = (float) node["coord0"];
		x.coord[1] = (float) node["coord1"];
	}
}
示例#14
0
void read(const cv::FileNode& node, vector<vector< pair<int, int> > >& termPair)
{

    cv::FileNodeIterator it = node.begin(), it_end = node.end();
    for( ; it != it_end; ++it)
    {
        vector<int> first_part;
        vector<int> second_part;
        (*it)["first"] >> first_part;
        (*it)["second"] >> second_part;
        vector<pair<int, int> > first_second;
        first_second.resize(first_part.size());
        for(int j = 0; j < first_part.size(); ++j)
        {
            first_second[j].first =  first_part[j];
            first_second[j].second = second_part[j];
        }
        termPair.push_back(first_second);
    }
    
}
bool AnnotationRect::read(cv::FileNode& obj) {
	if (!obj.isMap())
		return false;

	cv::FileNodeIterator it;

	cv::Point2f center;
	cv::Size2f size;
	float angle;

	obj["targetWidth"] >> targetWidth;
	obj["targetHeight"] >> targetHeight;
	obj["targetHeight"] >> targetHeight;
	obj["annotationAngle"] >> angle;
	it = obj["annotationCenter"].begin();
	it >> center.x >> center.y;
	it = obj["annotationSize"].begin();
	it >> size.width >> size.height;
	obj["id"] >> id;

	annotation = cv::RotatedRect(center, size, angle);

	return true;
}
 void read ( const cv::FileNode& node, map< string, V >&result)
 {
   bool node_type_ok = (node.type() & FileNode::MAP) > 0;
   if(!node_type_ok)
   {
     cout << node.type() << endl;
     cout << (node.type() & FileNode::MAP) << endl;
     cout << ((node.type() & FileNode::MAP) > 0) << endl;
     assert(node_type_ok);
   }
   
   for(FileNodeIterator iter = node.begin(); iter != node.end(); ++iter)
   {
     string node_name = (*iter).name();
     V value;
     //iter >> value; 
     deformable_depth::read_in_map(*iter,value);
     result[node_name] = value;
   }
 }
示例#17
0
  void SequenceAnalyzer::read( const cv::FileNode& node, SequenceAnalyzer& me )
  {
    std::string myName=node.name( );
    if( myName != "SequenceAnalyzer" )
    {
      std::string error = "FileNode is not correct!\nExpected \"SequenceAnalyzer\", got ";
      error += node.name();
      CV_Error( CV_StsError, error.c_str() );
    }
    if( node.empty( ) || !node.isMap( ) )
      CV_Error( CV_StsError, "SequenceAnalyzer FileNode is not correct!" );

    int nb_pictures = ( int ) node[ "nbPictures" ];
    //initialisation of all empty vectors
    for( int i=0; i<nb_pictures; i++ )
    {
      Ptr<PointsToTrack> ptt;
      if( i<me.images_.size() )
      {
        ptt = Ptr<PointsToTrack>( 
          new PointsToTrackWithImage( i, me.images_[i] ));
      }
      else
      {
        ptt = Ptr<PointsToTrack>( new PointsToTrack( i ));
      }
      me.points_to_track_.push_back( ptt );

      Ptr<PointsMatcher> p_m = Ptr<PointsMatcher>( new PointsMatcher(
        *me.match_algorithm_ ) );
      p_m->add( ptt );

      me.matches_.push_back( p_m );
    }

    cv::FileNode node_TrackPoints = node[ "TrackPoints" ];

    //tracks are stored in the following form:
    //list of track where a track is stored like this:
    // nbPoints idImage1 point1  idImage2 point2 ...
    if( node_TrackPoints.empty( ) || !node_TrackPoints.isSeq() )
      CV_Error( CV_StsError, "SequenceAnalyzer FileNode is not correct!" );
    cv::FileNodeIterator it = node_TrackPoints.begin( ),
      it_end = node_TrackPoints.end( );
    while( it != it_end )
    {
      cv::FileNode it_track = ( *it )[ 0 ];
      int nbPoints,track_consistance;
      it_track[ "nbPoints" ] >> nbPoints;
      it_track[ "track_consistance" ] >> track_consistance;
      bool has_3d_point = false;
      it_track[ "has_3d_position" ] >> has_3d_point;
      TrackOfPoints track;
      if( has_3d_point )
      {
        cv::Vec3d point;
        point[ 0 ] = it_track[ "point3D_triangulated" ][ 0 ];
        point[ 1 ] = it_track[ "point3D_triangulated" ][ 1 ];
        point[ 2 ] = it_track[ "point3D_triangulated" ][ 2 ];
        track.point3D = Ptr<cv::Vec3d>( new cv::Vec3d( point ) );
      }
      int color;
      it_track[ "color" ] >> color;
      track.setColor( *((unsigned int*)&color) );
      cv::FileNodeIterator itPoints = it_track[ "list_of_points" ].begin( ),
        itPoints_end = it_track[ "list_of_points" ].end( );
      while( itPoints != itPoints_end )
      {
        int idImage;
        cv::KeyPoint kpt;
        idImage = ( *itPoints )[ 0 ];
        itPoints++;
        kpt.pt.x = ( *itPoints )[ 0 ];
        kpt.pt.y = ( *itPoints )[ 1 ];
        kpt.size = ( *itPoints )[ 2 ];
        kpt.angle = ( *itPoints )[ 3 ];
        kpt.response = ( *itPoints )[ 4 ];
        kpt.octave = ( *itPoints )[ 5 ];
        kpt.class_id = ( *itPoints )[ 6 ];

        unsigned int point_index = me.points_to_track_[ idImage ]->
          addKeypoint( kpt );
        track.addMatch( idImage,point_index );

        itPoints++;
      }
      track.track_consistance = track_consistance;
      me.tracks_.push_back( track );
      it++;
    }
  }
示例#18
0
	persistStore();
}

void ViolenceModel::storeInit(cv::FileStorage &file, std::string exampleStoreName, cv::Mat &exampleStore,
													 std::string classStoreName, cv::Mat &classStore,
													 std::string indexCacheName, std::map<std::string, time_t> &indexCache)
{
	// Read the data structures in from the training store.
	file[exampleStoreName] >> exampleStore;
	std::cout << exampleStoreName << " loaded. size: " << exampleStore.size() << "\n";

	file[classStoreName] >> classStore;
	std::cout << classStoreName << " loaded. size: " << classStore.size() << "\n";

	cv::FileNode indexedFilePaths = file[indexCacheName];
	cv::FileNodeIterator iter = indexedFilePaths.begin(), end = indexedFilePaths.end();
	while ( iter != end )
	{
		std::string path = (*iter)[VIOLENCE_MODEL_TRAINING_EXAMPLE_PATH];
		//std::cout << "found path: " << path << "\n";
		int modTime = (int)(*iter)[VIOLENCE_MODEL_TRAINING_EXAMPLE_MOD_DATE];
		indexCache[path] = (time_t)modTime;
		iter++;
	}

	// Ensure we go no further the height (rows) are not equivalent.
	std::cout << "classes: " << classStore.size().height << " examples: " << exampleStore.size().height << " indices: " << indexCache.size() << "\n";
	assert(classStore.size().height == exampleStore.size().height && classStore.size().height == indexCache.size());
}
示例#19
0
void Regression::verify(cv::FileNode node, cv::InputArray array, double eps, ERROR_TYPE err)
{
    int expected_kind = (int)node["kind"];
    int expected_type = (int)node["type"];
    ASSERT_EQ(expected_kind, array.kind()) << "  Argument \"" << node.name() << "\" has unexpected kind";
    ASSERT_EQ(expected_type, array.type()) << "  Argument \"" << node.name() << "\" has unexpected type";

    cv::FileNode valnode = node["val"];
    if (isVector(array))
    {
        int expected_length = (int)node["len"];
        ASSERT_EQ(expected_length, (int)array.total()) << "  Vector \"" << node.name() << "\" has unexpected length";
        int idx = node["idx"];

        cv::Mat actual = array.getMat(idx);

        if (valnode.isNone())
        {
            ASSERT_LE((size_t)26, actual.total() * (size_t)actual.channels())
                    << "  \"" << node.name() << "[" <<  idx << "]\" has unexpected number of elements";
            verify(node, actual, eps, cv::format("%s[%d]", node.name().c_str(), idx), err);
        }
        else
        {
            cv::Mat expected;
            valnode >> expected;

            if(expected.empty())
            {
                ASSERT_TRUE(actual.empty())
                    << "  expected empty " << node.name() << "[" <<  idx<< "]";
            }
            else
            {
                ASSERT_EQ(expected.size(), actual.size())
                        << "  " << node.name() << "[" <<  idx<< "] has unexpected size";

                cv::Mat diff;
                cv::absdiff(expected, actual, diff);

                if (err == ERROR_ABSOLUTE)
                {
                    if (!cv::checkRange(diff, true, 0, 0, eps))
                    {
                        if(expected.total() * expected.channels() < 12)
                            std::cout << " Expected: " << std::endl << expected << std::endl << " Actual:" << std::endl << actual << std::endl;

                        double max;
                        cv::minMaxIdx(diff.reshape(1), 0, &max);

                        FAIL() << "  Absolute difference (=" << max << ") between argument \""
                               << node.name() << "[" <<  idx << "]\" and expected value is greater than " << eps;
                    }
                }
                else if (err == ERROR_RELATIVE)
                {
                    double maxv, maxa;
                    int violations = countViolations(expected, actual, diff, eps, &maxv, &maxa);
                    if (violations > 0)
                    {
                        FAIL() << "  Relative difference (" << maxv << " of " << maxa << " allowed) between argument \""
                               << node.name() << "[" <<  idx << "]\" and expected value is greater than " << eps << " in " << violations << " points";
                    }
                }
            }
        }
    }
    else
    {
        if (valnode.isNone())
示例#20
0
 void read_from_yaml(cv::FileNode node, int& i)
 {
   ntk_throw_exception_if(node.empty(), "Could not read " + node.name() + " from yaml file.");
   i = cvReadInt(*node, -1);
 }
示例#21
0
 void read_from_yaml(cv::FileNode node, double& b)
 {
   ntk_throw_exception_if(node.empty(), "Could not read " + node.name() + " from yaml file.");
   b = cvReadReal(*node, 0);
 }
示例#22
0
 void read_from_yaml(cv::FileNode node, cv::Mat& matrix)
 {
   CvMat* m = (CvMat*)node.readObj();
   ntk_throw_exception_if(!m, std::string("Could not read field ") + node.name() + " from yml file.");
   matrix = m;
 }