Object Detection using FERNS - opencv

I am new to image processing and have just started working in OpenCV. I was trying to do object detection using GenericDescriptorMatcher of type fern. But I don't know what to pass as the params_filename. What should be the format of the file? What parameters do I write in the file and in what format?
Ptr<GenericDescriptorMatcher> descriptorMatcher = GenericDescriptorMatcher::create("FERN", params_filename);

The opencv-2.x.x/samples/cpp should contain an example version of 'fern_params.xml', which according to opencv-2.4.8 contains the following xml content,
<?xml version="1.0"?>
<opencv_storage>
<nclasses>0</nclasses>
<patchSize>31</patchSize>
<signatureSize>INT_MAX</signatureSize>
<nstructs>50</nstructs>
<structSize>9</structSize>
<nviews>1000</nviews>
<compressionMethod>0</compressionMethod>
</opencv_storage>

Related

Even after adding new mime type for Tika file is still detected as application/x-bplist

I was trying to use Apache Tika to detect a .memgraph file exported out of Xcode. But the problem is that it was getting detected as application/x-bplist using the Tika() detector. So I created a new file org/apache/tika/mime/custom-mimetypes.xmland added the following to it:
<?xml version="1.0" encoding="UTF-8"?>
<mime-info>
<mime-type type="application/memgraph">
<glob pattern="*.memgraph"/>
</mime-type>
</mime-info>
But even after adding this the file was still getting detected as application/x-bplist. Will I have to write my own custom detector? And how will I go about writing one?

How I can read xml not written by openCV

For detection, I need to read number of points in xml file which was not written by openCV
so it starts like this
<?xml version="1.0" encoding="utf-8"?>
<KisaLibraryIndex>
....
<KisaLibraryIndex>
I tried to read this xml file using
FileStorage fs(filename, FileStorage::READ);
but it wasn't work with error message "abort() has been called"
I think the library index isn't matching with <opencv storage>
Is it impossible to read xml file doesn't written in openCV ::WRITE???

How to read a xml file with python with xml.dom

i am having one xml file and i need to fetch value of tags postnumer and regarding every postnumber all the valid number values...i am using xml.dom for reading xml file in python what is the code to fetch the value...how can i do this? please help
xml code:
-<post>
<PostNumber>180</postNumber>
-<validList>
<validNumber>208</validNumber>
<validNumber>209</validNumber>
<validNumber>210</validNumber>
</validlist>
</post>
-<post>
<postNumber>1023832</postNumber>
-<validlist>
<validNumber>264</validNumber>
<validNumber>401</validNumber>
</validlist>
</post>

Simple and quick way to parse an XML file in iOS7

I have a simple XML file like this
<?xml version="1.0"?>
<catalog>
<timezone>
<name>UTC-11:00</name>
<place>
<value>American Samoa</value>
<value>Samoa</value>
</place>
</timezone>
<timezone>
<name>UTC-10:00</name>
<place>
<value>Honolulu</value>
<value>Tahiti</value>
</place>
</timezone>
</catalog>
What is the canonical/standard way to parse this in iOS? I want to save "names" and "places" for each name.
NSXMLParser is already built in. You should look at this article for a more thorough comparison.
http://www.raywenderlich.com/553/xml-tutorial-for-ios-how-to-choose-the-best-xml-parser-for-your-iphone-project
It is NSXMLParser. Official documentation

How to provide an empty Source in xslTransformer.transform() method?

I have an xslt 2.0 file which is being used to transform a csv file to an xml file. The xsl has been taken from here:
http://p2p.wrox.com/xslt/40898-transform-csv-file-xml.html#post164344
Now I am trying to execute this through Java transformer (using the Saxon9 xsl transformer factory). Since the csv file is being passed into the xsl as a parameter, there is no need for me to pass anything in the Source parameter in the transform method. Since the javadocs for the transform method state the following:
The javadocs for the Transformer.transform method clearly state that the following:
"An empty Source is represented as an empty document as constructed by DocumentBuilder.newDocument(). The result of transforming an empty Source depends on the transformation behavior; it is not always an empty Result."
I tried to create an empty document and try the transformation as seen below:
TransformerFactory transformerFactory = TransformerFactory.newInstance("net.sf.saxon.TransformerFactoryImpl",null);
Source xsltSource = new StreamSource("file:///C:/my.xsl");
Transformer xsltTransformer = transformerFactory.newTransformer(xsltSource);
xsltTransformer.setParameter("pathToCSV", "'file:///C:/input.csv'");
StringWriter writer = new StringWriter();
xsltTransformer.transform(new DOMSource(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument()), new StreamResult(writer));
The above piece of code does not output anything and does not work as expected since I think the empty document given as input is taken into consideration rather than the csv file passed in the following line in the xsl:
<xsl:param name="pathToCSV" />
<xsl:variable name="input" select="unparsed-text($pathToCSV)"/>
Could anyone give me pointers on how to accomplish what I am trying to achieve?
Consider to use the Saxon API http://saxonica.com/documentation/html/using-xsl/embedding/s9api-transformation.html and not to use the JAXP API if you want to use XSLT 2.0 features like starting with a named template as the XSLT you linked to requires. Or, if you want to use JAXP with an empty dummy document you at least need to add a template doing
<xsl:template match="/">
<xsl:call-template name="main"/>
</xsl:template>

Resources