Enabling PDF417 Decoding in Zxing - java

I am trying to get PDF417 barcode reading to be enabled in ZXing (Zebra Crossing). I did a pull from the github repo and built the library according to the wiki. The ant build output seems to indicate that the PDF417 submodule is being built. I tried to test everything according to the wiki using these images but I get a "no barcode found" error.
kscottz#kscottz-laptop:~/barcode/zxing$ java -cp javase/javase.jar:core/core.jar com.google.zxing.client.j2se.CommandLineRunner Sample_PDF417.png
file:/home/kscottz/barcode/zxing/Sample_PDF417.png: No barcode found
kscottz#kscottz-laptop:~/barcode/zxing$ java -cp javase/javase.jar:core/core.jar com.google.zxing.client.j2se.CommandLineRunner bc.png
file:/home/kscottz/barcode/zxing/bc.png: No barcode found
kscottz#kscottz-laptop:~/barcode/zxing$ java -cp javase/javase.jar:core/core.jar com.google.zxing.client.j2se.CommandLineRunner sanitycheck.jpg
file:/home/kscottz/barcode/zxing/sanitycheck.jpg (format: QR_CODE, type: TEXT):
Raw result:
<-- SNIP -->
What gives? Am I missing a flag to enable PDF417? Where would one look to set these sorts of configuration options? I am regularly a Python/C/C++ developer so I may be missing something pretty basic.

Try --try_harder, otherwise it's in the mode suitable for mobile devices, instead of using more CPU to scan the image more. --pure_barcode will probably work too since these are synthetic images.
In general. These don't seem to decode though. I can't access the first image, and the second isn't found even in the online decoder (which you can always use as a check): http://zxing.elasticbeanstalk.com/w/decode.jspx
I don't know why since I presume it's valid. You can run through the debugger to see exactly what goes wrong.

So I ran the ZXing test script on the test barcodes and they do pass, so I am going to assume it is enabled. It appears that when zxing says alpha they really mean alpha. =(

Basically to detect only PDF417 barcode using ZXING library, you need to pass in the hints asking ZXING to only look for PDF417 type.
try below,
hints.put(DecodeHintType.POSSIBLE_FORMATS, EnumSet.of(BarcodeFormat.PDF_417));
Checkout the below example,
LuminanceSource source = new BufferedImageLuminanceSource(bufferedImage);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Map<DecodeHintType, Object> hints = new EnumMap<>(DecodeHintType.class);
hints.put(DecodeHintType.POSSIBLE_FORMATS, EnumSet.of(BarcodeFormat.PDF_417));
//hints.put(DecodeHintType.POSSIBLE_FORMATS, EnumSet.allOf(BarcodeFormat.class));
hints.put(DecodeHintType.CHARACTER_SET, "utf-8");
hints.put(DecodeHintType.TRY_HARDER, true);
Result result = new MultiFormatReader().decode(bitmap, hints);

Related

Can't set options to LibVLC

I have been trying to utilize the Android SDK from Maffen:
https://github.com/mrmaffen/vlc-android-sdk/ in order to stream RTSP.
So I found the following stack overflow thread:
vlc-android-sdk - cannot view RTSP live video
Which has a number of answers of how to do this.
However, the problem I am having is that when I try to set the options for LibVLC it will not allow me to do so.
For example:
ArrayList<String> options = new ArrayList<String>();
options.add("--no-drop-late-frames");
options.add("--no-skip-frames");
options.add("--rtsp-tcp");
options.add("-vvv");
videoVlc = new LibVLC(options)
When I try to run this I get the following error message in Android Studio:
"error: incompatible types: ArrayList cannot be converted to Context"
Also if I hover over the "LibVLC(options)" section of the code it comes up with the following message:
"LibVLC (android.content.Context) in LibVLC cannot be applied to (java.util.ArrayList)
I'm no Java expert, so perhaps this is an easy fix but I have been trying different sample codes from around the internet all day and every single one sets those options and I can't do it.
Any help would be much appreciated. Thank you!
EDIT:
This problem was solved using the following:
videoVlc = new LibVLC(this, options);
I had simply forgot about including the context part of the LibVLC.
I forgot to go back and edit this once I had arrived at a solution.
maffen vlc android sdk. the constructor LibVLC takes two params. context and options. option can be null. and options should be the second one. the older version may only takes one param option

How to use SchemaCrawler's Offline Snapshots in Java code

I think the header explains it all: Is there a nice way to create and load offline snapshots of database schema using SchemaCrawler without using command line? If yes, can you provide some example code / link please? If not, some example java code to use command line options would be helpful too (I don't have much experience with that)!
Thanks for any kind of help!
PS: I managed to create offline snapshot with this code:
final SchemaCrawlerOptions options = new SchemaCrawlerOptions();
// Set what details are required in the schema - this affects the
// time taken to crawl the schema
options.setSchemaInfoLevel(SchemaInfoLevelBuilder.standard());
options.setRoutineInclusionRule(new ExcludeAll());
options.setSchemaInclusionRule(new RegularExpressionInclusionRule(/* some regex here*/));
options.setTableInclusionRule(new RegularExpressionExclusionRule(/*some regex here*/));
outputOptions.setCompressedOutputFile(Paths.get("./test_db_snapshot.xml"));
final String command = "serialize";
final Executable executable = new SchemaCrawlerExecutable(command);
executable.setSchemaCrawlerOptions(options);
executable.setOutputOptions(outputOptions);
executable.execute(getConnection());
Not sure how to connect to it though.
You need to use the schemacrawler.tools.offline.OfflineSnapshotExecutable along with an schemacrawler.tools.offline.jdbc.OfflineConnection to "connect" to your database snapshoot.
Please take a look at the following code:
OfflineSnapshotTest.offlineSnapshotExecutable()
And #ZidaneT, to load an offline snapshot, use code like that in LoadSnapshotTest.java
Sualeh Fatehi, SchemaCrawler

Set Scanner to Read Only QR Code and Ignore other type of BarCodes

I am using this library to scan QR Codes. This library is very simple but I am having a hard time trying to figure out on making it to responds only to QR Codes.
It uses ZXing behind it.
CamView
//MARK - scannerLiveView
ZXDecoder decoder=new ZXDecoder();
decoder.setScanAreaPercent(0.5);
ScannerLiveView scannerLiveView = (ScannerLiveView) findViewById(R.id.scannerLiveView);
scannerLiveView.setDecoder(decoder);
Here is how I did it. But the problem is that it responds to all kind of bar codes. I would like to have it responds on QR Codes only.
Any thoughts??
The problem is that ZXDecoder is hardcoded to scan all possible formats. https://github.com/LivotovLabs/CamView/blob/53e3112592980754628bab2b770ed16900b9c407/CAMView/src/main/java/eu/livotov/labs/android/camview/scanner/decoder/zxing/ZXDecoder.java. You could create a new class QRDecoder which should look pretty much the same as ZXDecoder but instead of creating MultiFormatReader it should create QRCodeReader

Programatically embed a video in a slideshow using Apache Open Office API

I want to create a plugin that adds a video on the current slide in an open instance of Open Office Impress by specifying the location of the video automatically. I have successfully added shapes to the slide. But I cannot find a way to embed a video.
Using the .uno:InsertAVMedia I can take user input to choose a file and it works. How do I want to specify the location of the file programmatically?
CONCLUSION:
This is not supported by the API. Images and audio can be inserted without user intervention but videos cannot be done this way. Hope this feature is released in subsequent versions.
You requested information about an extension, even though the code you are using is quite different, using a file stream reader and POI.
If you really do want to develop an extension, then start with one of the Java samples. An example that uses Impress is https://wiki.openoffice.org/wiki/File:SDraw.zip.
Inserting videos into an Impress presentation can be difficult. First be sure you can get it to work manually. The most obvious way to do that seems to be Insert -> Media -> Audio or Video. However many people use links to files instead of actually embedding the file. See also https://ask.libreoffice.org/en/question/1898/how-to-embed-video-into-impress-presentation/.
If embedding is working for your needs and you want to automate the embedding by using an extension (which seems to be what your question is asking), then there is a dispatcher method called InsertAVMedia that does this.
I do not know offhand what the parameters are for the call. See https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=61127 for how to look up parameters for dispatcher calls.
EDIT
Here is some Basic code that inserts a video.
sub insert_video
dim document as object
dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:InsertAVMedia", "", 0, Array())
end sub
From looking at InsertAVMedia in sfx.sdi, it seems that this call does not take any parameters.
EDIT 2
Sorry but InsertVideo and InsertImage do not take parameters either. From svx.sdi it looks like the following calls take parameters of some sort: InsertGalleryPic, InsertGraphic, InsertObject, InsertPlugin, AVMediaToolBox.
However according to https://wiki.openoffice.org/wiki/Documentation/OOoAuthors_User_Manual/Getting_Started/Sometimes_the_macro_recorder_fails, it is not possible to specify a file for InsertObject. That documentation also mentions that you never know what will work until you try it.
InsertGraphic takes a FileName parameter, so I would think that should work.
It is possible to add an XPlayer on the current slide. It looks like this will allow you to play a video, and you can specify the file's URL automatically.
Here is an example using createPlayer: https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=57699.
EDIT:
This Basic code works on my system. To play the video, simply call the routine.
sub play_video
If Video_flag = 0 Then
video =converttoURL( _
"C:\Users\JimStandard\Downloads\H264_test1_Talkinghead_avi_480x360.avi")
Video_flag = 1
'for windows:
oManager = CreateUnoService("com.sun.star.media.Manager_DirectX")
' for Linux
' oManager = CreateUnoService("com.sun.star.media.Manager_GStreamer")
oPlayer = oManager.createPlayer( video )
' oPlayer.CreatePlayerwindow(array()) ' crashes?
'oPlayer.setRate(1.1)
oPlayer.setPlaybackLoop(False)
oPlayer.setMediaTime(0.0)
oPlayer.setVolumeDB(GetSoundVolume())
oPlayer.start() ' Lecture
Player_flag = 1
Else
oPlayer.start() ' Lecture
Player_flag = 1
End If
End Sub

Open Filesystem Raster Dataset in ArcGIS using ArcObjects 10.2 in Java

SOLVED: see my answer below
I am trying to open .tif, .img, and .dat Raster files to a new layer in ArcMap.
I have tried all the methods I have found in the documentation and a few implementations on StackOverflow.
This is the current code:
File file = new File(output);
IWorkspaceFactory wsFactory = (IWorkspaceFactory)new RasterWorkspaceFactory();
IRasterWorkspace2 rasterWS = (IRasterWorkspace2)wsFactory.openFromFile(file.getParentFile().getAbsolutePath(),0);
IRasterDataset rds = rasterWS.openRasterDataset(output);
IRasterLayer rasterLayer = new RasterLayer();
rasterLayer.createFromDataset(rds);
IActiveView activeView = mxDocument.getActiveView();
IMap _map = activeView.getFocusMap();
_map.addLayer(rasterLayer);
This code throws no error messages, but it does not open the layer. Previous implementations that I took from sample programs and documentation for arcObjects 10.2 throw exceptions on this line:
RasterDataset rasterDataset = (RasterDataset) rasterWorkspace.openRasterDataset(file.getAbsolutePath());
The only lead I have right now is the ControlsAddDataCommand class to possibly call the command for opening the files and give the filepath as input. Build a custom command to open the file?
Note: The files open fine by clicking the addData option on the Layer menu.
SOLVED
IRasterLayer rasterLayer = new RasterLayer();
rasterLayer.createFromFilePath(output);
mxDocument.addLayer(rasterLayer);
Found this code by browsing the JavaDoc Tooltips in Eclipse.
Just type in the object and a "." Eclipse will show all the options available.
I'm amazed this code snippet wasn't listed anywhere online (that I found in about 8 hours of searching). Anyways, that's the simple 3 line solution!

Categories

Resources