API in Windows for Matlab - how to compile?

286 views
Skip to first unread message

Douglas

unread,
Sep 11, 2009, 4:09:41 PM9/11/09
to ViPER Mailing List
Hi,

This is my third post in a row, but I promise that I am not trying to
dominate this mailing list.

I suspect that it might be David who is first to reply and, so I would
like to thank him for all the help he has already provided. (Did you
see my reply to your advice on
http://groups.google.co.uk/group/viper-toolkit/browse_thread/thread/d0464eff931bc594
?)

Okay, here is my new question. I would like to import ViPER xml data
into Matlab. In theory, I could use Java calls from Matlab with the
ViPER api. Unfortunately, I am working in a Windows environment and I
assume that I will have to compile the specific Java in Windows for
this purpose - correct me if I am wrong. I have downloaded the full
source and so would like advice on the compilation process, in
Windows, for the api part of the code. To get a clue, I have had a
look at the make file in the api directory but don't understand it.

I have no Java experience but guess that my Visual Studio has hooks to
a Java compiler - it seems to recognise the Java source files.

Thank you,

Douglas

David Mihalcik

unread,
Sep 11, 2009, 11:51:46 PM9/11/09
to viper-...@googlegroups.com
Matlab supports native access to java, so you should be able to point
your copy of matlab to load all of the .jar files in the viper-light
distribution and access them that way. For an overview of how to add
java classes to your matlab instance, check out here:

http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/matlab_external/f4863.html&http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclient&gfns=1&q=matlab+java

You will have to add most of the .jar files in the viper-light package
available.

On the viper web site, there is some minimal documentation, for some
ideas about how to write scripts that read or write viper data files.
There are two formats, the .xgtf xml format, and an older,
easier-on-the-eyes plain text format (you can convert between the two
with the xml2gtf and gtf2xml tools). The main difference, other than
the way they look, is that the xml format supports describing multiple
media files from a single metadata file.

http://viper-toolkit.sourceforge.net/docs/scripting/

If you want to actually build the thing, I use Eclipse, IBM's free
java IDE. However, I'd suggest just munging with the files directly.
I'll see if I can upload a generated api documentation file somehow,
which would make it a lot easier to use the API for reading and
writing viper metadata files.

David Mihalcik

David Mihalcik

unread,
Sep 12, 2009, 12:15:28 AM9/12/09
to ViPER Mailing List
I've uploaded the javadocs here:

http://github.com/dmihalcik/viper-toolkit/downloads

From the scripting viper documentation, to load a file, you'll have to
do something like this:

-- first, import the necessary classes.. I might be missing a few.

import java.io.*
import javax.xml.*
import viper.api.*
import viper.api.impl.*

-- next, load the file

FileInputStream inFile = new FileInputStream ("gt.xml");
Element documentEl = DocumentBuilderFactory.newInstance()
.newDocumentBuilder()
.parse(inFile)
.getDocumentElement();
inFile.close();
ViperData newFile = ViperParser.parseDoc (documentEl);

- finally, read data from newFile

for (Descriptor d : newFile.getSourcefile
("yourFile.mpg").getDescriptors()) {
// do something with the descriptor
}

I don't have a copy of matlab handy, and i don't quite remember how to
translate java syntax into matlab syntax.

On Sep 11, 11:51 pm, David Mihalcik <kraka...@gmail.com> wrote:
> Matlab supports native access to java, so you should be able to point
> your copy of matlab to load all of the .jar files in the viper-light
> distribution and access them that way. For an overview of how to add
> java classes to your matlab instance, check out here:
>
> http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/acc...
>
> You will have to add most of the .jar files in the viper-light package
> available.
>
> On the viper web site, there  is some minimal documentation, for some
> ideas about how to write scripts that read or write viper data files.
> There are two formats, the .xgtf xml format, and an older,
> easier-on-the-eyes plain text format (you can convert between the two
> with the xml2gtf and gtf2xml tools). The main difference, other than
> the way they look, is that the xml format supports describing multiple
> media files from a single metadata file.
>
> http://viper-toolkit.sourceforge.net/docs/scripting/
>
> If you want to actually build the thing, I use Eclipse, IBM's free
> java IDE. However, I'd suggest just munging with the files directly.
> I'll see if I can upload a generated api documentation file somehow,
> which would make it a lot easier to use the API for reading and
> writing viper metadata files.
>
> David Mihalcik
>
> On Fri, Sep 11, 2009 at 4:09 PM, Douglas <dug.armad...@googlemail.com> wrote:
>
> > Hi,
>
> > This is my third post in a row, but I promise that I am not trying to
> > dominate this mailing list.
>
> > I suspect that it might be David who is first to reply and, so I would
> > like to thank him for all the help he has already provided. (Did you
> > see my reply to your advice on
> >http://groups.google.co.uk/group/viper-toolkit/browse_thread/thread/d...

Douglas

unread,
Sep 14, 2009, 10:40:50 AM9/14/09
to ViPER Mailing List
Hi David,

I was nearly going to give up but I seem to have made some small
progress. However, I am stuck again. I hope that you, or somone, can
assist.

This is what I have done in Matlab:

>> import javax.xml.parsers.*

>> docBuilder = DocumentBuilderFactory.newInstance()

>> docElement = docBuilder.newDocumentBuilder().parse('test.xgtf').getDocumentElement()

>> parser = viper.api.impl.ViperParser

>> parser.parseDoc(docElement)

14-Sep-2009 15:26:41 viper.api.datatypes.Lvalue setConfig

WARNING: lvalues should enumerate all possible values in the <lvalue-
possibles> tag.

14-Sep-2009 15:26:41 viper.api.impl.ViperParser parseAttr

SEVERE: Missing important XML attribute.

java.lang.NullPointerException

at viper.api.impl.ViperParser.parseAttr(Unknown Source)

at viper.api.impl.ViperParser.parseAttrs(Unknown Source)

at viper.api.impl.ViperParser.parseSourcefile(Unknown Source)

at viper.api.impl.ViperParser.parseData(Unknown Source)

at viper.api.impl.ViperParser.parseDoc(Unknown Source)

14-Sep-2009 15:26:41 viper.api.impl.ViperParser parseAttr

SEVERE: Missing important XML attribute.

java.lang.NullPointerException

......

And the xml file is:

<?xml version="1.0" encoding="UTF-8"?>
<viper xmlns="http://lamp.cfar.umd.edu/viper#" xmlns:data="http://
lamp.cfar.umd.edu/viperdata#">
<config>
<descriptor name="Information" type="FILE">
<attribute dynamic="false" name="SOURCETYPE" type="http://
lamp.cfar.umd.edu/viperdata#lvalue">
<data:lvalue-possibles>
<data:lvalue-enum value="SEQUENCE"/>
<data:lvalue-enum value="FRAMES"/>
</data:lvalue-possibles>
</attribute>
<attribute dynamic="false" name="NUMFRAMES" type="http://
lamp.cfar.umd.edu/viperdata#dvalue"/>
<attribute dynamic="false" name="FRAMERATE" type="http://
lamp.cfar.umd.edu/viperdata#fvalue"/>
<attribute dynamic="false" name="H-FRAME-SIZE"
type="http://lamp.cfar.umd.edu/viperdata#dvalue"/>
<attribute dynamic="false" name="V-FRAME-SIZE"
type="http://lamp.cfar.umd.edu/viperdata#dvalue"/>
</descriptor>
<descriptor name="People" type="OBJECT">
<attribute dynamic="false" name="Bounding box"
type="http://lamp.cfar.umd.edu/viperdata#circle"/>
</descriptor>
</config>
<data>
<sourcefile filename="file:/C:/Documents%20and%20Settings/
dougmacd/Desktop/testSequence/test_images/test_images.info">
<file id="0" name="Information">

......ETC

I feel I am so close to getting this working.

Thank you for your kind help,

Douglas
Reply all
Reply to author
Forward
0 new messages