My goal is to validate some XML document against Schematron file in Android.
At the moment I am trying to use this library for Java.
So far, it doesn't seem to be working at all, I simply get empty array as the result of transform. This is piece of code from the library method I adjusted a bit.
Source xsltSource = (Source) jur.resolve( "iso_svrl_for_xslt2.xsl", null );
Source schemaSource = new StreamSource(this.schemaAsStream);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(xsltSource);
transformer.transform(xsltSource, new StreamResult( baos ));
Does anyone have an idea how to get Transformer working for Android?
Thanks in advance.
The Extensible Stylesheet Language Transformations (XSLT) APIs can be used for many purposes. For example, with a sufficiently intelligent stylesheet, you could generate PDF or PostScript output from the XML data. But generally, XSLT is used to generate formatted HTML output (that we can consume in our Android Webview), or to create an alternative XML representation of the data. This will help you.
Related
There are the Bitmap for Android and UIImage for iOS. Is there a way to display both somehow in the Xamarin Forms Image control?
Obviously I need the Dependency Service. I will have two implementations that create either a bitmap or an uiimage using some source, but how do I bring those two products together to a single forms control? Both Android and iOS methods have to return something, that the image control can understand and display. I don't know what that might be.
Edit: I look for a way where I don't use storage space, if possible.
Edit2:
I tried Jasons suggestion and it works fine.
I create a bitmap in the Android project and return a MemoryStream object:
MemoryStream stream = new MemoryStream();
newImage.Compress(Bitmap.CompressFormat.Png, 0, stream);
return stream;
Then I consume it in my Xamarin.Forms Image control:
var stream = DependencyService.Get<ICrossPlatformImageProcesor>().Combine_Images(imagePath);
stream.Position = 0;
img_ImageView.Source = Xamarin.Forms.ImageSource.FromStream(() => stream);
I will have two implementations that create either a bitmap or an uiimage using some source, but how do I bring those two products together to a single forms control?
You can simply use Image Control of xamarin forms, images can be loaded specifically for each platform, or they can be downloaded for display.
For more information, you can refer to Working with Images.
I look for a way where I don't use storage space, if possible.
I'm not quite understand this, if you mean don't use memory, then I think it is not possible. If you mean your images are not saved in storage, then possibly you have an URL address on internet of your images?
Anyway, Image control in Xamarin.Forms support image source form ImageSource instance, file, Uri, and resources, to load image from uri, you can simply code like this:
var webImage = new Image { Aspect = Aspect.AspectFit };
webImage.Source = ImageSource.FromUri(new Uri("https://xamarin.com/content/images/pages/forms/example-app.png"));
I've been struggling to make the tess-two OCR project work, and when I finally did, it did recognize text when it's clear and when there are multiple lines there.
The whole point of this is that I need to use OCR to extract credit card number when the user takes a photo of it.
Here is an example of a credit card number:
This is just an example I used many pictures. for instance with this image I got the following text:
1238 5578 8875 5877
1238 5578 8875 5877
1238 5578 8875 5877
Here is the code I use for this:
TessBaseAPI baseApi = new TessBaseAPI();
baseApi.init("/mnt/sdcard/tesseract-ocr", "eng");
baseApi.setImage(bm);
baseApi.setPageSegMode(6);
String whiteList = "/1234567890";
baseApi.setVariable(TessBaseAPI.VAR_CHAR_WHITELIST, whiteList);
String recognizedText = baseApi.getUTF8Text();
baseApi.end();
Any help would be much appreciated.
Thanks !
Maybe some preprocessing steps of the image would make tesseract have a better performance.
I could suggest you a whole paper(http://wbieniec.kis.p.lodz.pl/research/files/07_memstech_ocr.pdf)
If you have time, if not, try to play with the image's contrast for example.
Here are also some ideas that can fit your issue:
http://www.ocr-it.com/user-scenario-process-digital-camera-pictures-and-ocr-to-extract-specific-numbers
Example images are allready fit for OCR, but as far as i see you're using tesseract's built-in "eng.traineddata" model and its not suitable (in terms of accuracy / performance) for credit card scanning. (Credit cards use the font "OCR-A"). Thus you'll need to either find pretrained model and replace it on initialization of tessApi or train it yourself from stratch.
For training tesseract model with custom font, see Yash Modi's answer at
here
I am using libgdx 0.9.8 and trying to load .obj files as Mesh.But as specified in various tutorials and in the documentation its not taking Stream as paramtetr rather its asking for FileHandle. What should be passsed is it because of the version ?
I am currently using this code, but I am still struggling with texture loading:
ObjLoader model = new ObjLoader();
meshCar = model.loadObj(
Gdx.files.internal("data/car_white.obj"),
Gdx.files.internal("data/car_white"),
true
);
I have a one question, because I`m not a programmer, I use only tutorials for teaching Flex and programming in his.
Is possible to make new render file for s:Label or s:Text property? Because I make a small RSS application for mobile and I have this code for showing images from description of RSS items (this code is located on DetailsView.mxml): var descArr:Array = rdesc.split("src="); var resArr:Array = descArr[1].split(".jpg"); var resArr2:Array = resArr[0].split("\""); rimage = resArr2[1] + ".jpg";
In new renderer file I will hide html tags, because if I use this code: var p:RegExp = /(,
So, I need render on new .mxml document with same code of DetailsView, but in new render (if it possible) I use this RegExp for hiding html text… How I set s:Label or s:Text to show renderer from new document?
Thanks for any help
Is possible to make new render file for s:Label or s:Text property?
No! Renderers only exist in list based classes or with DataGroups. You can read more about itemRenderers and what they do here.
Now if you want to make a component that includes text and images and can be used as a renderer, that is possible. Read more about creating components.
HI,
I am currently studying how Android decode and image file. When I checked the code, it seems like it is calling the SKIA library. But, how do I know what are the image file format supported by android/skia basing on the source code?
I am not an expert in programming, so I am still trying to understand C++ and Java language.
I am now lost at SkImageDecoder* decoder = SkImageDecoder::Factory(stream); inside the BitmapFactory.cpp (JNI file). SkImageDecoder::Factory(stream) seems to be a template.
Anyone can explain me what is happening inside SKImageDecoder::Factory()? Any feedback will be greatly appreciated.
Thanks,
artsylar
In skia/include/images/SkImageDecoder.h file, there is the image list decoding supported by Skia:
enum Format {
kUnknown_Format,
kBMP_Format,
kGIF_Format,
kICO_Format,
kJPEG_Format,
kPNG_Format,
kWBMP_Format,
kWEBP_Format,
kLastKnownFormat = kWEBP_Format
};
In SkImageDecoder::Factory(stream) function, it will new a decoder instance according to analyze the Stream's header.
By looking at the source codes of Android, I think the following image formats are supported.
ICO (Windows ICON image format), BMP, JPEG, WBMP, GIF, and PNG.
Please correct me if I am wrong. Thank you.
PNG, JPEG, and GIF are the supported formats. The primary formats used on Android are PNG and JPEG.