Creating and reading an image with metadata - clojure

I could not find anything online.
Im planning on saving Software small software data in the file.
I've had a look at clj-exif and exif-processor
but both do not seem to return what i need

You can use Java interop to read/write any type of file. You could use output-stream
to write any type of bytes to a file, such as the bytes of a jpeg image.
See also the Clojure Cookbook online for more tips, and this list of Clojure documentation.

Related

Parse GML to use in map creation

so I posted a question on OpenData and after advancing me a bit further in my quest to create maps from real cartographic information, I was advised to post my follow up questions on this website.
So after this intro, here is the original question:
I'm creating a 2D realistic RTS (Real time strategy game) and I wanted to be able to use real locations as the scenarios for the games.
The game will be developed via unreal engine which uses c++. The idea is for the engine to read an file and convert into a grid (coordinate point) where each square has type of terrain associated, like in this image of a scenario editor.
The file resulting from the other website is a GML (Geographic Markup Language) of a given location in the globe. GML is a XML extension.
The problem I'm facing is converting that GML for a given location into data that can be used by my game, like an location array or something like that.
Any sugestions?
There are many possibilities into doing this but the general guidelines or concepts should be as follows:
Know the data structure used by your engine
Open the incoming file and being able to parse and extract the needed data
Populate your structures or classes
Use your custom structures or classes to create game content (map data).
The first suggestion that I can give would be to read up on any and all documentation on the GML file format to know how the tags of the marked up language works then from there look to see if you can find any libraries that make it easy to read in a GML or XML file type and to generate C++ classes or structures, otherwise you will have to write both the file loader and gml(xml)parser with schema manually. Then from those structures being able to extract the data that you need and to pass them or store them into your engine's custom data structures. Then finally you should be able to use the stored data in your engine to generate the content that you want.
References
www.opengeospatial.org
www.w3.org
www.ogcnetwork.net
www.gdal.org
www.svgopen.org
Books
Geo-Informatics... 200+ page preview of almost 1,000 pages
Whitepapers
ResearchGate
Tools - Some Free Some Not
Google Search - GML File Converter
GoLoader by Snowflake Software
Various Sources by OGCNetwork
Open Source software from opengeospatial
GML Reader by tsusiatsoftware
Libraries
Question found on Stack Exchange
Various Libraries & Frameworks for Different Formats and Languages
gmXML Parser by YOYO games - *This Might be for the GameMaker Language
Java Code Examples for org.geotools.xml.Parser from programcreek
GML API for C/C++ Documentation
GML - The Geometric Modelling Library - API & GUI
Open Source - CityGML
The information needed is out there; it just takes time and effort; good research and the ability to apply what you have read into an actual code base.

Convert Movie to OpenNI *.oni video

The Kinect OpenNI library uses a custom video file format to store videos that contain rgb+d information. These videos have the extension *.oni. I am unable to find any information or documentation whatsoever on the ONI video format.
I'm looking for a way to convert a conventional rgb video to a *.oni video. The depth channel can be left blank (ie zeroed out). For example purposes, I have a MPEG-4 encoded .mov file with audio and video channels.
There are no restrictions on how this conversion must be made, I just need to convert it somehow! Ie, imagemagick, ffmpeg, mencoder are all ok, as is custom conversion code in C/C++ etc.
So far, all I can find is one C++ conversion utility in the OpenNI sources. From the looks of it, I this converts from one *.oni file to another though. I've also managed to find a C++ script by a phd student that converts images from a academic database into a *.oni file. Unfortunately the code is in spanish, not one of my native languages.
Any help or pointers much appreciated!
EDIT: As my usecase is a little odd, some explanation may be in order. The OpenNI Drivers (in my case I'm using the excellent Kinect for Matlab library) allow you to specify a *.oni file when creating the Kinect context. This allows you to emulate having a real Kinect attached that is receiving video data - useful when you're testing / developing code (you don't need to have the Kinect attached to do this). In my particular case, we will be using a Kinect in the production environment (process control in a factory environment), but during development all I have is a video file :) Hence wanting to convert to a *.oni file. We aren't using the Depth channel at the moment, hence not caring about it.
I don't have a complete answer for you, but take a look at the NiRecordRaw and NiRecordSynthetic examples in OpenNI/Samples. They demonstrate how to create an ONI with arbitrary or modified data. See how MockDepthGenerator is used in NiRecordSynthetic -- in your case you will need MockImageGenerator.
For more details you may want to ask in the openni-dev google group.
Did you look into this command and its associated documentation
NiConvertXToONI --
NiConvertXToONI opens any recording, takes every node within it, and records it to a new ONI recording. It receives both the input file and the output file from the command line.

Read/Write file metadata using C/C++

Searched through net, could't find a way to read/write file metadata using C or C++, however, there are tools available for this, and also there are API's in C# and Java to do this. But I want to do it from scratch in C or C++.
For example, read/write image metadata.
Have found out that there are three formats in which metadata is written to files. EXIF, IPTC and XMP.
Thanks.
Why would you want to do it from scratch?
Anyway, you need documentation and you may also want to look at an existing library for helps, expecially if you have no experience in the field.
Have you tried Exiv ?
Exiv2 is a C++ library and a command
line utility to manage image metadata.
It provides fast and easy read and
write access to the Exif, IPTC and XMP
metadata of images in various formats.
Exiv2 is available as free software
and with a commercial license, and is
used in many projects.
There are different solutions. One is to define a structure (but make sure the field alignements are correct), then read the data, and use the structure to access the fields. Trivial example:
struct header {
uint32_t len;
unsigned char type;
char name[16];
};
struct header hdr;
read(fd,&hdr,sizeof(hdr));
... access your fields using the structure ...
The topic is a bit more complex than this ;) But since you did not specified much more I think this still can help a bit.

Edit Metadata of PDF File with C/C++?

Could anyone please provide me a sample C/C++ code to read and edit PDF Metadata?
If it is XMP, what else to do?
If it's XMP, I think there's an SDK available from Adobe. But beware, PDF metadata has a long history and isn't only stored in XMP.
You might best be off using a library that allows PDF manipulation. There are several commercial ones available. I have no idea whether there's something usable available for free.
https://github.com/hfiguiere/exempi -- C-library to read and write XMP.
The XMP SDK from adobe does not read/write metadata of PDF files. PDF reading/writing is a complicated task. Your best bet is to use a third party PDF library, or commands like pdfleo.
If you haven't tried XMPToolkit yet, give it a shot and see if it meets your needs.

Decode JPEG to obtain uncompressed data

I want to decode JPEG files and obtain uncompressed decoded output in BMP/RGB format.I am using GNU/Linux, and C/C++.
I had a look at libjpeg, but there seemed not to be any good documentation available.
So my questions are:
Where is documentation on libjpeg?
Can you suggest other C-based jpeg-decompression libraries?
The documentation for libjpeg comes with the source-code. Since you haven't found it yet:
Download the source-code archive and open the file libjpeg.doc. It's a plain ASCII file, not a word document, so better open it in notepad or another ASCII editor.
There are some other .doc files as well. Most of them aren't that interesting though.
Unfortunately I cannot recommend any other library besides libjpeg. I tried a couple of alternatives, but Libjpeg always won. Is pretty easy to work with once you have the basics done. Also it's the most complete and most stable jpeg library out there.
MagickWand is the C API for ImageMagick:
http://imagemagick.org/script/magick-wand.php
I have not used it, but the documentation looks quite extensive.
You should check out Qt's QImage. It has a pretty easy interface that makes this task really easy. Setup is pretty simple for every platform.
If Qt is overkill, you can try Magick++ http://www.imagemagick.org/Magick++/. It supports similar operations and is also well suited for that sort of task. The last time I used it, I struggled a bit with dependencies for it on Windows, but don't recall much trouble on Linux.
For Magick++'s Image class, the function you probably want is getConstPixels.
I have code that you can copy ( or just use as a reference ) for loading a jpeg image using the libjpeg library.
You can browse the code here: http://code.google.com/p/kgui/source/browse/trunk/kguiimage.cpp
Just look for the function LoadJPGImage.
The code is setup to handle c++ binding of my DataHandle class to it for loading the image, that way the image can be a file or data already in memory or whatever.
A slightly out of the box solution is to acquire a copy of the netpbm tools, which transform images from pretty much any format to any other format via one of several very simple intermediate formats. They work well from the shell, and are most often used in pipes to read some arbitrary image, perform an operation on it, and write it out to some other format.
The pbm formats can be as simple as a plain ASCII header followed by the RGB data in ASCII or binary. They are intended to be simple enough to use without required a library to implement.
JPEG is supported in netpbm by read and write filters that are implemented on top of libjpeg.