xmlregionhandler.cc

来自「VC视频对象的跟踪提取原代码(vc视频监控源码)」· CC 代码 · 共 164 行

CC
164
字号
// Thu Feb 14 16:58:28 GMT 2002  by  nts//////////////////////////////////////////////////////////////////////////////////////                                                                                //// class XMLRegionHandler : public DefaultHandler                                 ////                                                                                //// This class defines an interface to XML Region data as defined by the XML       //// Schema namespace "http://www.cvg.cs.reading.ac.uk/ADVISOR" (the current name). ////                                                                                //// Similar in design to our ImageSource classes, some methods are pure virtual    //// and the class should therefore not be instantiated directly.                   ////                                                                                //// The XMLRegionHandler class is derived from the XML SAX2 DefaultHandler class   //// which is designed to ignore all requests.  We only redefine the methods that   //// we need such that there is little overhead.                                    ////                                                                                //////////////////////////////////////////////////////////////////////////////////////#include "XMLRegionHandler.h"#include <util/XMLString.hpp>  // XMLString class with static character conversion methods#include <sax2/Attributes.hpp>#include "Region.h"#include "RegionSet.h"#include "text_output.h"namespace ReadingPeopleTracker{////////////////////////////////////////////////////////////////////////////   Constructor and Destructor                                         ////////////////////////////////////////////////////////////////////////////XMLRegionHandler::XMLRegionHandler(){    // initialise variables to sensible values...    frame_count = 0;    parsing_level = 0;    new_region = NULL;    current_region_set = NULL;    have_valid_region_set = false;    region_set_has_been_queried = true;}XMLRegionHandler::~XMLRegionHandler(){    // nothing}////////////////////////////////////////////////////////////////////////////   Access function to query current region set                        ////////////////////////////////////////////////////////////////////////////RegionSet *XMLRegionHandler::get_current(){    // check whether the current_region_set is valid    if (have_valid_region_set)    {	// remember that RegionSet has been queried	region_set_has_been_queried = true;		// return current complete set	return current_region_set;    }        // we have no complete RegionSet yet!    //   give an error message and return an empty new RegionSet:    cerror << " XMLRegionHandler::get_current() : RegionSet queried before it was complete "	   << endl;        return new RegionSet;}////////////////////////////////////////////////////////////////////////////  Implementation of the SAX2 DocumentHandler interface                ////////////////////////////////////////////////////////////////////////////void XMLRegionHandler::startDocument(){     // initialise parsing level to 0 (toplevel)     parsing_level = 0;}void XMLRegionHandler::endDocument(){    // signal that the RegionSet current_regions we have is now complete    //   but is has not been queried using get_current() yet    region_set_has_been_queried = false;    have_valid_region_set = true;        assert (parsing_level == 0);   // check for valid XML document structure        // if the region set has not been collected via get_current() it will    // have to be de-allocated. }void XMLRegionHandler::startElement(const XMLCh *const uri,				    const XMLCh *const localname,				    const XMLCh *const qname,				    const XERCES_CPP_NAMESPACE::Attributes &attributes){    // There are currently 5 valid elements we recognise (level in brackets) :-    //   MD_blob_frame (0), blob(1), info2d(2), info3d(2), occlusion(2).    //   All data (coordinates etc) is given in attributes.    //   see http://www.cvg.cs.reading.ac.uk/~nts/ADVISOR/motion_detector.xsd    char *element_name = XMLString::transcode(localname);        if (strcasecmp(element_name, "md_blob_frame") == 0)  // matched this element name?    {	// call specific function	handle_frame(&attributes);		// we have gone one level further into the document	parsing_level++;  	return;    }        if (strcasecmp(element_name, "blob") == 0)  // matched this element name?    {	// call specific function	handle_blob(&attributes);		// we have gone one level further into the document	parsing_level++;  	return;    }        if (strcasecmp(element_name, "info2d") == 0)  // matched this element name?    {	// call specific function	handle_info2d(&attributes);		// we have gone one level further into the document	parsing_level++;  	return;    }        if (strcasecmp(element_name, "info3d") == 0)  // matched this element name?    {	// call specific function	handle_info3d(&attributes);		// we have gone one level further into the document	parsing_level++;  	return;    }        if (strcasecmp(element_name, "occlusion") == 0)  // matched this element name?    {	// call specific function	handle_occlusion(&attributes);		// we have gone one level further into the document	parsing_level++;  	return;    }    // if we end up here, the element name was not matched    //   give an error message and ignore the data    cerror << " XMLRegionHandler::startElement(): Unknown XML element 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?