I use openCV. I've trained SVM, but the output file is too large (after svm.save()). I want to use trained SVM in iPhone's application, but the file is about 300 Mb. File's size after archive is about 6 Mb.
So, my questions:
1) Can I extract the archive with bzip2 when iPhone application starts and then use this file with SVM::load ?
2) Can CvSVM's save/load methods work with binary formats?
3) Do I need all information from output file to do a prediction?
4) Does a better solution exist for this problem?
Thank you in advance!
You may try to save svm object with bzip library (if it is possible, I don't know this library) and try to load the object with bzip afterwards to memory and for example use a pointer to it. CvSVM.load() generates xml file with support vectors and some additional data. I don't know if any of it is optional, but I doubt it.
Related
So I am trying out tesseract at the moment, and it does work, but it is not accurate enough. I know that the image quality plays a role as well, etc. etc., but some of the documents I am using use a rather unusual font. It still does recognise parts of it though (about 50-60%, which is pretty good), but this is obviously not entirely satisfying.
I would like to know now whether it's possible to train tesseract, but not to create an entirely new language, but to use the data I am already using, and build on this and improve it?
Second, if this is possible, would this even be advisable? Or (2) would it be better to create new languages for every new font I encounter, or (3) create new languages for each new font I encounter, but not from scratch but always built upon the default data I am using right now? What do you think? If you can provide any links on how to train tesseract & make use of the training data already provided, do let me know please.
You can extract the files from .traineddata file as given in documentation :
specify option -u to unpack all the components to the specified path:
combine_tessdata -u tessdata/eng.traineddata /home/$USER/temp/eng.
This will create /home/$USER/temp/eng.* files with individual tessdata components from tessdata/eng.traineddata.
There are other options too,please check the documentation on the following link.
https://github.com/tesseract-ocr/tesseract/blob/master/doc/combine_tessdata.1.asc
But rather than playing with original files its advisable to train tesseract for a new language.
(2)You dont have to create new language for each font.You have to create image,box and training file for each font .All of these will then be combined into a single language's traineddata file.
(3)This is possible too.PLease visit
https://github.com/tesseract-ocr/tesseract/wiki/Training-Tesseract-3.00%E2%80%933.02#bootstrapping-a-new-character-set
I'm using the following method to compress a bunch of textures:
public void OnPostprocessTexture (Texture2D t) {
EditorUtility.CompressTexture(t, TextureFormat.DXT5, 2);
}
The idea is to try to compress the texture when importing it. I have a project with many textures which are not using an optimal format.
The problem is that these changes are not saved anywhere, if you check the editor you'll see that the format remains the same. I can leave the script there and reimport everything in the build server, but I'd like a way to save these changes.
The only way I can think of this is to create another texture using the format I want and copying/replace the texture. Is there a better way to do this?
Edit
Doing some more tests, I noticed something strange: EditorUtility.CompressTexture is somehow compressing NPOT textures. This is before running the script:
And this is after running EditorUtility.CompressTexture:
How does this work?
While Sergey's answer helps me change the format, it won't compress NPOT textures and I really need to save these bytes.
You have 2 problems here.
Problem 1
You are trying to do it inside OnPostprocessTexture method, which is too late. You need to do it inside OnPreprocessTexture method instead.
Problem 2
EditorUtility.CompressTexture compresses a texture object itself (an object that resides in RAM), not a corresponding asset (an object that resides on disk).
The correct way of doing what you want to do is using TextureImporter.textureFormat.
Solution
Here is a working example:
public void OnPreprocessTexture()
{
TextureImporter textureImporter = assetImporter as TextureImporter;
textureImporter.textureFormat = TextureImporterFormat.DXT5;
}
Answer to comment
Another detail: I don't agree that CompressTexture creates an object in RAM instead of the disk, I think it creates a file inside the Library folder (that at some point is loaded into the RAM).
No, it doesn't create anything inside Library folder. It's quite easy to check:
Start with minimal Unity3D project: only one texture and only one editor script (a descendant of AssetPostprocessor with your OnPostprocessTexture method.
Open Library folder and write down number of files and their size.
Reimport the texture from Unity editor (it will result in execution of your OnPostprocessTexture method).
Open Library folder and see that no files were added and total size of files remains the same (at least this is how it works on my machine).
Answer to edited question
Doing some more tests, I noticed something strange: EditorUtility.CompressTexture is somehow compressing NPOT textures.
If I try to reproduce it, Unity outputs an error line to console: "!hasError".
Despite that Unity editor says that the texture is compressed with DXT5 after such a manipulations, the actual texture format is D3DFMT_A8R8G8B8 when you check it in a plugin.
One thing to note here. Actually, DXT compression doesn't require textures to be of power of two size. It requires them to be of size of multiple of 4. Hope this helps :)
I am trying to change the value of a tag from a TIFF object in my matlab code. I keep getting this error:
Error using tifflib
Tag number (273) is unrecognized by the TIFF library.
Error in Tiff/setTag (line 1146)
tifflib('setField',obj.FileID, ...
The code I am using is included below:
fname='C:\FileLocation\pcd144_012.tif';
t=Tiff(fname,'r+');
t.getTag('StripOffsets')
t.setTag('StripOffsets',[8, 16392])
Why is it I can get the tag and see it, but cannot set the tag to a different value?
Here is a link to the tiff I am working with:
Tiff Data
I think that you're out of luck with this approach. The setTag methods are mostly used when building a TIFF from scratch. My guess is that the 'StripOffsets' field is not modifiable. Keep in mind that these tools are designed for the normal case of non-broken image files and that changing this field in such cases would either break the file or necessitate re-encoding of the data most of the time. The function should give better feedback (documentation for the TIFF could be better in general) so you might still contact The MathWorks to let them know about this.
As far as finding a way to edit these tags/fields, you might look for and try out some TIFF tag viewer/editor programs to see if they might do it. Otherwise it may come down to parsing the header yourself to find the relevant bytes.
One of my Simulink SLX files has stopped opening as a model. Apparently it was corrupted. Are there any means to repair such a files or extract some information of them? File looks like being a MZ executable. Where is the block schema stored?
SLX is a compressed file which contains XML files with model information. You can try opening the SLX file in winzip and check. See http://www.mathworks.com/help/simulink/ug/saving-a-model.html#btbr7kx-1 for SLX format. I do not think there is any utility to repair corrupted SLX files.
DiffPlug's Simulink Viewer has an .slx parser that was developed independent of The Mathworks, and it's a little more "lenient" than The Mathworks' implementation. You might want to try opening your model in DiffPlug's viewer (it's free, so you don't have much to lose I guess...).
That way you'll at least be able to scout around the model so you can see what piece has been corrupted.
Disclaimer: I work for DiffPlug.
If there's a lot of time invested in the model, I'd be happy to open your model up and poke around inside it using our internal API. It'd only take me a few minutes, and it might be an easy fix like a mis-matched Stateflow id.
Remove the extension 'original' from the file name 'X.slx.original'. This worked for me.
You can actually still load the system using load_system(), use bdroot to see if it loaded, then use save_system() to save what is returned by bdroot, using a new filename. The new model should open correctly.
need some help on this.
Currently I am doing a project on computer vision that requires me to train a new model to detect a certain object.
In this case, I am using the system provided by P. Felzenszwalb, D. McAllester, D. Ramaman and his team => Discriminatively trained deformable part models which is implemented in Matlab.
Project webpage: http://www.cs.uchicago.edu/~pff/latent/.
However I have no idea how to direct the system to use my dataset(a collection of images and annotation) which is different from the the PASCAL datasets so as to train a new model.
By directing, I meant a line of code that allows me to change the dataset the system reads from, for training a model.
E.g.
% directory for caching models, intermediate data, and results
cachedir = ['/var/tmp/rbg/YOURPATH/' VOCyear '/'];
I tried looking at their Readme and documentation guides but they do not make any mention. Do correct me if I am wrong.
Let me know if I have not made my problem clear enough.
I tried looking at some files such as global.m but no go.
Your help is much appreciated and thanks in advance!
You can try to read pascal.m in the DPM package(voc-release5), there are similar code working on VOC2007/2010 dataset.
There are plenty of parts that need to be adapted to achieve this. For example the voc_config has to be adapted in order to read from your files.
The same with the pascal_train.m function. Depending on the images and the way you parse them, this may require quite some time to adapt this function.
Other functions to consider:
imreadx
pascal_test
pascaleval