{"id":70,"date":"2005-05-23T18:43:40","date_gmt":"2005-05-23T23:43:40","guid":{"rendered":"http:\/\/crschmidt.net\/blog\/?p=70"},"modified":"2005-05-23T18:43:40","modified_gmt":"2005-05-23T23:43:40","slug":"more-on-image-regions","status":"publish","type":"post","link":"https:\/\/crschmidt.net\/blog\/archives\/70\/more-on-image-regions\/","title":{"rendered":"More on Image Regions"},"content":{"rendered":"<p>My post last night was a bit cryptic, so let me walk through a bit more clearly what I&#8217;ve been doing, since I seem to have picked up the interest of some more people.<\/p>\n<p>I currently am using Flickr to annotate my photos: primarily because I like their image region annotations, and partially because their API offers me a way to get lots of data out that I&#8217;ve put in, which is useful to me. So, that&#8217;s what I&#8217;m using for photo annotation at the moment, which may change at any point.<\/p>\n<p>Masahide has a flickr2rdf service: <a href=\"http:\/\/purl.org\/net\/kanzaki\/flickr2rdf\">flickr2rdf<\/a> takes a Flickr Photo page URI and exports RDF from it: For example, a picture of myself, my ex girlfriend, and Foghorn Leghorn can be seen, fully annotated, using XSLT+RDF, <a href=\"http:\/\/www.kanzaki.com\/works\/2005\/imgdsc\/flickr2rdf?u=http%3A%2F%2Fwww.flickr.com%2Fphotos%2Fcrschmidt%2F13444147%2F\">via  the flickr2rdf tool<\/a>.<\/p>\n<p>Additionally, the original photos stored at flickr (full size) have EXIF information: this information can be exported via Masahide&#8217;s equally cool exif2rdf tool: <a href=\"http:\/\/www.kanzaki.com\/test\/exif2rdf?xsl=on&#038;u=http:\/\/photos9.flickr.com\/13444147_19d43ba986_o.jpg\">Foghorn Leghorn Example<\/a>.<\/p>\n<p>Once I have the photo_id of a photo, I can collect all these statements together. Additionally, since I am using tags from <a href=\"http:\/\/www.geobloggers.com\">GeoBloggers<\/a> for geolocation, I have a tool which parses out these tags (using the Flickr API) and creates Geo data for them.<\/p>\n<p>I add a few tracking statements: specifically, links to seeAlso the final RDF\/XSLT view of the image, (again, <a href=\"http:\/\/crschmidt.net\/albums\/flickr\/13444147\">Foghorn Leghorn example<\/a>). I serialize the Model out from Redland, and get a directory full of files full of RDF singletons. From here, I use <a href=\"http:\/\/www.w3.org\/2000\/10\/swap\/doc\/cwm.html\">cwm<\/a> to process the singletons into an abbreviated RDF\/XML file. These files are then synced to the http:\/\/crschmidt.net\/albums\/flickr\/ directory. Here, I use a couple little tricks to add an XSLT declaration as the first line of each file, so that the content negotiated version offers XML delivered as application\/xml, rather than just application\/rdf+xml (which Firefox won&#8217;t display in a browser).<\/p>\n<p>Next step is to add each of these files into an RDF model. Since I&#8217;m still occasionally changing statements, I&#8217;ve been dropping the whole model and readding every time: this doesn&#8217;t take too long, as it&#8217;s only a few hundred files, and Redland is speedy quick.<\/p>\n<p>So, now we have a database full of RDF statements. Fine. But that&#8217;s not too useful. So, I have my SPARQL query interface. Which is all well and good, for people who have lots of knoweldge of RDF. It can provide some cool results.<\/p>\n<p>But it doesn&#8217;t really do anything *fun*. So last night, I added an optional checkbox, that said &#8220;If you ahve something in a specific query format, process an XSLT file against it&#8221;. I tweaked this XSLT from masahide&#8217;s example, linked yesterday, into what it is now, which you can <a href=\"http:\/\/crschmidt.net\/xslt\/imgreg.xsl\">see<\/a>, if you&#8217;re interested.<\/p>\n<p>Well, that&#8217;s all well and good, but most people don&#8217;t understand SPARQL enough to know what they should type in. What&#8217;s the use of having to learn a language just to see some pictures? So, my next step was to add a search box specifically for Regions: my <a href=\"http:\/\/crschmidt.net\/albums\/sparql\">sparql page<\/a> has a search box now specifically for this purpose.<\/p>\n<p>I realized after a couple times, though, that using client side XSLT to process the XML was really slow, clunky, and generally ugly. Not to mention that Mozilla&#8217;s XSLT doesn&#8217;t let me disable-output-escaping on variables: so, I installed php4-xslt, and started using that implementation on the server side.<\/p>\n<p>Yeah, that&#8217;s all well and good too, but now my pretty RDF with queries and all went away! So, I added them back: at the end of the <a href=\"http:\/\/crschmidt.net\/albums\/sparql?search=Foghorn\">Foghorn Search<\/a>, in a comment, you&#8217;ll see:<\/p>\n<p>Generated using the XSLT stylesheet at http:\/\/crschmidt.net\/xslt\/imgreg.xsl against the data generated by the query:<\/p>\n<p>PREFIX dc: &lt;http :\/\/purl.org\/dc\/elements\/1.1\/&gt;<br \/>\nPREFIX foaf: &lt;http :\/\/xmlns.com\/foaf\/0.1\/&gt;<br \/>\nPREFIX imgreg: &lt;http :\/\/www.w3.org\/2004\/02\/image-regions#&gt;<br \/>\nSELECT ?img,?title,?page,?desc,?atitle,?coord<br \/>\nWHERE {<br \/>\n?img<br \/>\n  dc:title ?title;<br \/>\n  foaf:page ?page;<br \/>\n  dc:description ?desc;<br \/>\n  imgreg:hasRegion ?r.<br \/>\n?r<br \/>\n  dc:title ?atitle;<br \/>\n  imgreg:coords ?coord.<br \/>\nFILTER REGEX(?atitle ,&#8221;Foghorn&#8221;) }<\/p>\n<p>Data was: <\/p>\n<p>followed by the XML version of the SPARQL query results.<\/p>\n<p>Another interesting example: <a href=\"http:\/\/crschmidt.net\/albums\/sparql?search=Schmidt\">Schmidt<\/a> &#8211; myself, family members, and others.<\/p>\n<p>Anyway, being a bit more informative seemed appropriate given the situation. So there&#8217;s my implementation toy of the day.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My post last night was a bit cryptic, so let me walk through a bit more clearly what I&#8217;ve been doing, since I seem to have picked up the interest of some more people. I currently am using Flickr to annotate my photos: primarily because I like their image region annotations, and partially because their [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,14,5,8,29],"tags":[],"class_list":["post-70","post","type-post","status-publish","format-standard","hentry","category-flickr","category-geolocation","category-image-description","category-rdfcat","category-sparql"],"_links":{"self":[{"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/posts\/70","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/comments?post=70"}],"version-history":[{"count":0,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/posts\/70\/revisions"}],"wp:attachment":[{"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/media?parent=70"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/categories?post=70"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/tags?post=70"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}