Feature detection for windows phone? - c#

I'd like to know how to create arbitrary image detection using the following library: http://facedetectwp7.codeplex.com/ . In the description it states that any object can be detected if the models are added to the project. Does anyone know how to create these models? Thanks.

The model is an XML file that is created as a result of training a Haar Classifer. The XML file that is included with the library is the default file that's used by OpenCV.
To create a model file for a custom set of objects, you'll need a large set of positive images (images that have the objects), and negative images (without the object).
You'll then "train" the classifier on these two image sets, and this will produce a single xml file.
Check out this link for more info.

Related

Good practices for storing readonly data in Unity

I'm making a visual novel and my game uses some custom classes that store important data.
Example:
public class Speech
{
public Sprite CharacterHead; // Holds a reference to a sprite which is the "head" of who's currently speaking
public LocalizedString SpeechOrigin; // Holds a reference to a localizedstring that is what that character is saying based on the language. (Uses Unity.Localization)
public string Name; // the name of the character that is speaking
}
This "Speech" class should never be changed during runtime and only needs to be read during dialogues.
My question is: what is a general good-practice way to store this type of data? I'm fairly new to unity and the only way i found to do this yet is through declaring a List on monobehaviour classes and editing them through the Inspector but this does not seems to be a effective way of handling this in a game that's going to have 1000+ different "Speech".
Ps:Don't mind all the variables being public, they are this way right now to make some parts of development easier, i will change the necessary ones when the time comes.
Why don't you just use ScriptableObject? It's the default way for Unity to store data in the game. You can also edit it from the Unity Editor instead of using another external editor. You can also drag-and-drop any resource from the game project's folder into it (eg. the texture of the head, the whole localized sting as data, the dialog audio clips, etc)
https://docs.unity3d.com/Manual/class-ScriptableObject.html
https://youtu.be/aPXvoWVabPY
There are a few good ways to store this information, especially if you are localising them too. Essentially, you would store an ID that you refer to the various strings with, which would be constant across language files.
CSV format files
Basically, you can use some spreadsheet software (like Google Sheets) and have all your speech there; a column for the ID of the string, and a column for the actual value. You can export the sheet as a CSV file and load into Unity.
You can then write some simple parsing code to read each line from the file, and split out the ID and the value and store it in a dictionary.
JSON format files
With JSON, if you architect it correctly, you can use Unity's built in JSON utility, or other better ones, to read the data directly into C# object classes.
A decent video explaining this can be found here.
YAML format files
YAML is basically the same as JSON, but with less brackets. It is also the format that Unity uses for its serialisation. However, you can only use this format by writing your own parser, or using a third party one, because there is no built in parser.
JSON files are generally industry standard for data storage these days, but eventually it is up to you which format you find easiest to work with. I've tried to list these in the order of how easy it is to add and remove strings from the file.
You should not store a lot of data in c# code use external files that are designed for data by creating a JSON file, XML file, or any other type of both human and computer readable format.
XML should be the perfect choise for your usecase, it is widely used for dialogue trees
Here is an example of what you can do with XML in your usecase
<npcs>
<npc name="Oren">
<dialogue>
<text>Hi #{PlayerName} do you want to eat falafel? </text>
<options>
<option action="yes">yes, I would like</option>
<option action="no">no...</option>
</options>
</dialogue>
</npc>
</npcs>
it's fairly simple to use XML, and it fits dialogues perfectly

Kofax Export Connector - check for attached components

I have a webservice that publishes the scanned Kofax documents to another application.
This application webservice takes the following data:
the document (binary)
the IDs of meta fields (from the application) and their values (the index fields from Kofax)
When creating a mapping for the meta fields I would store the selected index field with the meta field ID to the releaseSetupData custom properties.
releaseSetupData.CustomProperties.Add("MetaFieldID", "IndexFieldValue");
When publishing the scanned document I want to publish a PDF file when the PDF Generator is attached otherwise a multipage TIFF file.
How can I check if this generator is attached to the batch class?
As far as I know the TIFF files from Kofax are single pages so I would have to setup a workaround by code?
tldr:
To answer your first question: While I am not sure whether the export connector has access to the queues of the relevant, just use the PDF whenever one is available, and TIFFs otherwise.
I'd check if if a file exists using DocumentData.KofaxPDFPath as path. If that is the case, upload a PDF. If no file exists, I'd save the images to a temporary folder using DocumentData.ImageFiles.Copy(). In both cases you may want to use File.ReadAllBytes(), depending on how your web service call handles said attachments.
Second question: just use 0 for the ImageType as the second argument to DocumentData.ImageFiles.Copy().
More detailed explanation:
Unfortunately, Kofax's object model is a bit messy, here's how PDFs are handled:
The property DocumentData.KofaxPDFFileName will contain a full/absolute path to the converted PDF file, if available. This usually points to a file contained in subfolders in the server file share (i.e. CaptureSV\Images)
The method DocumentData.CopyKofaxPDFFile() will allow you to copy aforementioned file to the path DocumentData.KofaxPDFPath, if defined during setup.
It's a bit of a different story for images:
Images are exposed as a collection of ImageFile in DocumentData.ImageFiles. However, as you already mentioned - these are mostly single page TIFFs.
DocumentData.ImageFiles.Copy() will either allow you to copy all images to the path as defined during setup, i.e. DocumentData.ImageFilePath - alternatively, you can provide a string argument with any custom path. Further, it allows you to define an ImageType, and 0 means Multipage TIFFs, CCITT Group 4 (please refer to the API Reference for further details).

How to extract geometric positions from 2d .dwg using Forge AutoDesk APIs?

Using Model derivative API I am able to get geometric properties of 3d dwg file but for 2d dwg I am facing the issue(Unrecoverable exit code from extractor: -1073741831) on extracting geometric properties.
I also understand that model derivative API doesn't provide a support for extracting 2d geometries.
Is any other way to extract geometry of 2d file using programming API(c#)?
EDIT
I have added ObjectTree JSON file and POST URL of "Extract Geometry for Selected Objects into an OBJ File" in the following GitHub link.
https://github.com/Jothipandiyan-jp1/Autodesk
From the error, it seems that your 2D drawing is somehow broken, or not uploaded right. Or is it a vertical file, like Plant 3D or Map 3D?
The Model Derivative should extract the 2D View, you can try the file on A360 Viewer or via API at this sample (C# source).
EDIT
From the comments, it seems you are trying to extract the .obj from a single objectId in the 2D DWG. This should not trigger errors, but it may return empty file as the OBJ format is intended for 3D shapes. Can you update your question with the full POST job used on your code? Make sure the modelGuid and objectIds parameters are correct.

Read and write image data

I have been programming a map editor to use when making 2D games. I have nearly completed it, however I can't load maps.
I have multiple options for saving and loading maps. I have:
DAT File
BIN File
MAP File
XML File
XML isn't the issue but the other file types are. I need to be able to read and write image data to these other 3 file types. I would suggest just removing these file types, but sometimes having maps that aren't XML are useful.
UPDATE:
I'm not asking to follow an algorithm that is already produced. What I mean is to write the image data to a file, and then read the data back into a bitmap object.
It sounds like what you're talking about is having a proprietary format for your game map data.
What you want to do is take a look at Object Relational Mapping (you could start here: http://en.wikipedia.org/wiki/Object-relational_mapping). You want to come up with a good way to structure your object (map image) in a store (a binary file). You'll want to write up some kind of class that follows this kind of interface:
public interface ORMap
{
public void Save(MyMap map, string fileIdentifier);
}
It sounds like you've already done this for XML.
You could the implement that interface to transform and/or serialize your MyMap object to the desired format and write it to disk using fileIdentifier as the name.
There is no one standard way of doing this, but if you have examples from other similar games you could try to look at their API and/or file structure and imitate it.

How to get all file properties of an Image in C# winforms

I am trying to get all properties in C# of an Image file downloaded from camera. I can get general file properties using FileInfo and FileAttributes. But image taken from camera have special properties tab named Camera what I want to retrieve in C#. Here is the snapshot of properties.
I want to get special properties like ISO, f-Stops and camera name in C#. Is there any class which can be used to get that or any other open source project?
Here you can find more info about this
http://www.developerfusion.com/article/84474/reading-writing-and-photo-metadata/
There are lots of examples online, i.e:
http://msdn.microsoft.com/en-us/library/xddt0dz7(v=vs.110).aspx
http://msdn.microsoft.com/en-Us/library/windows/apps/windows.storage.fileproperties.imageproperties?cs-save-lang=1&cs-lang=csharp#code-snippet-1
http://tech.pro/tutorial/782/getting-image-metadata-with-csharp

Categories

Resources