How to enable the Barcode recognization in Abbyy Fine Reader Engine 12? - java

Barcode recognition is disabled by default in Abbyy Fine Reader Engine 12.
In order to enable it, I need to set the DetectBarcodes property of the PageAnalysisParams Object to TRUE.
Can anyone please help me, how can I set this property true in my java code sdk?
This is the property which we have to set:
public native void setDetectBarcodes(boolean arg0);
How can we call the native function from the java code?
Because calling directly with the object it is giving error.
Error: The local variable pageAnalysisParams may not have been initializedJava(536870963)

To get/initalize an instance of IPageAnalysisParams you can:
IPageAnalysisParams pageAnalysisParams = engine.CreatePageAnalysisParams();
You can also obtain an instance from "document processing params", like:
IDocumentProcessingParams documentparams = engine.CreateDocumentProcessingParams();
IPageAnalysisParams pageAnalysisParams = documentparams.getPageProcessingParams().getPageAnalysisParams();
source: https://github.com/search?q=IPageAnalysisParams&type=code
Looking at the public code samples, you should:
Obtain an instance of IDocumentProcessingParams (dpParams).
Tune that object (and sub-objects(page analysis params)).
And pass that to: document.Process(dpParams);

As #xerx593 suggested, programatically tuning document processing params is a perfectly valid answer.
Another valid answer is to use a configuration file, for example custom_barcode_profile.ini, and fill it according to your needs. This allows you to have better control and readibility over your profiles:
...
[PageAnalysisParams]
DetectBarcodes = TRUE
...
Use your ABBYY SDK documentation and/or ABBYY java wrapper classes to fine tune other parameters, then instead of using document.Process(dpParams);, instantiate an engine object and pass your custom_barcode_profile.ini file to it:
IEngine engine = Engine.InitializeEngine(<your sdk & license params>);
engine.LoadProfile("custom_barcode_profile.ini");
IFRDocument document = engine.CreateFRDocument();
document.AddImageFile("document.png", null, null);
document.Process(null);
document.Export("result.xml", FileExportFormatEnum.FEF_XML, null);
You cannot programatically "mix" multiple predefined profiles into one, you need to add parameters to a custom profile or even create another one and pass it to your engine object.
To enable table detection in the profile we defined later, look for parameters that affects table detection in the documentation, such as DetectTables, and add it to your custom profile:
...
[PageAnalysisParams]
DetectBarcodes = TRUE
DetectTables = TRUE
...

Related

How to use CreateProcessWithTokenW in Java using JNA

We are using createProcessAsUser function to create a child process running in the context of logged in/Impersonated user using waffle and JNA libraries.
But we need to load the user profile after the impersonation, but the LoadUserProfile function is not available in a JNA library.
As we found that CreateProcessWithTokenW is capable of loading the user profile. But this function also not available in the JNA/Waffle library.
Could anyone help us how to load the user profile or how to use the CreateProcessWithTokenW in Java application.
To use CreateProcessWithTokenW from java with JNA you need to bind the function. JNA is just a layer, that makes it possible to call directly native library functions. For this to work JNA uses java descriptions of the native interface, which are then used to do the actual call.
The jna-platform contrib project (released together with the main project) contains a big number of already bound win32 functions and indeed in Advapi32.java there are already bindings for CreateProcessAsUser and CreateProcessWithLogonW. Based on that I would try this (UNTESTED!):
public interface Advapi32Ext extends StdCallLibrary {
Advapi32Ext INSTANCE = Native.load("Advapi32", Advapi32Ext.class, W32APIOptions.DEFAULT_OPTIONS);
boolean CreateProcessWithToken(
HANDLE hToken,
int dwLogonFlags,
String lpApplicationName,
String lpCommandLine,
int dwCreationFlags,
Pointer lpEnvironment,
String lpCurrentDirectory,
STARTUPINFO lpStartupInfo,
PROCESS_INFORMATION lpProcessInfo
);
}
This assumes that you run with the system property w32.ascii set to false or unset, which is the recommend setup. In that case the W32APIFunctionMapper.UNICODE is used, which appends the "W" suffix automatically. The then also selected W32APITypeMapper.UNICODE ensures, that java String objects are mapped to wchars or in case of a function call to LP*WSTR.

How to list Streams owned by a Project Area using Jazz RTC Java API

I am working an automation for IBM Rational Team Concert (IBM aka Jazz RTC).
How may one list all streams owned by a specific project area?
Which are the required API calls?
I could not find any getters in the IProjectArea instance, nor service or client instances with such methods. And I could not figure out how to use search criteria for this purpose.
The streams owned by a project area may be queried using IWorkspaceSearchCriteria. Because streams are, actually, workspaces of type 'stream'. The API is not quite clear how to specify the owning project area.
Get the IWorkspaceManager from the ITeamRepository, which contains the findWorkspaces method.
You don't need IProjectAreaHandle. Only the project area name.
Create a IWorkspaceSearchCriteria and set kind to IWorkspaceSearchCriteria.STREAMS and set exactOwnerName to the string containing the project area name.
Call IWorkspaceManager.findWorkspaces(...) to get a list of IWorkspaceHandles. The first parameter is the search criteria. Se second parameter is the maximum number of results (which I set to IWorkspaceManager.MAX_QUERY_SIZE, which is 512. The third parameter is the progress monitor, which may be null.
If you need to get stream name, description or other attributes, then you need to call IItemManager.fetchCompleteItems(...) fetch the full IWorkspace instances.
Here is an example in Groovy:
Lit<IComponentHandle> listComponents(String projectAreaName) {
final manager = repositoty.getClientLibrary(IWorkspaceManager) as IWorkspaceManager;
final criteria = IWorkspaceSearchCriteria.FACTORY.newInstance();
criteria.setKind(IWorkspaceSearchCriteria.STREAMS);
criteria.setExactOwnerName(projectAreaName)
final itemManager = repositoty.itemManager()
return itemManager.fetchCompleteItems(handles, IItemManager.DEFAULT, null) as List<IWorkspace>
}

Accessing SecureString SSM parameters with Scala

I'm using a Scala Script in Glue to access a third party vendor with a dependent library. You can see the template I'm working off here
This solution works well, but runs with the parameters stored in the clear. I'd like to move those to AWS SSM and store them as a SecureString. To accomplish this, I believe the function would have to pull a CMK from KMS, then pull the SecureString and use the CMK to decrypt it.
I poked around the internet trying to find code examples for something as simple as pulling an SSM parameter from within Scala, but I wasn't able to find anything. I've only just started using the language and I'm not very familiar with its structure, is the expectation that aws-java libraries would also work in Scala for these kinds of operation? I've tried this but am getting compilation errors in Glue. Just for example
import software.amazon.awscdk.services.ssm.StringParameter;
object SfdcExtractData {
def main(sysArgs: Array[String]) {
print("starting")
String secureStringToken = StringParameter.valueForSecureStringParameter(this, "my-secure-parameter-name", 1); // must specify version
Gives a compilation error, although aws glue doesn't good job of telling me what the issue is.
Thank you for your time! If you have any code examples, insight, or resources please let me know. My job is running Scala 2 on Spark 2.4
was able to do this with the following code snippet
import com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagementClient
import com.amazonaws.services.simplesystemsmanagement.model.GetParameterRequest
import com.amazonaws.services.simplesystemsmanagement.model.GetParameterResult
// create a client AWSSimpleSystemsManagementClient object
val client = new AWSSimpleSystemsManagementClient()
// Create a GetParameterRequest object, which send the actual request
val req = new GetParameterRequest()
// set the name of the parameter in the object.
req.setName("test")
// Only needed if the parameter is a secureString encrypted with the default kms key. If you're using a CMK you need to add the glue user as a key user. To do so, navigate to KMS console --> Customer Managed Keys --> Click on KMS key used for encryption --> Under Key policies --> Key user --> Add ( Add the Glue role )
req.setWithDecryption(true)
// call the getParameter() function on the object
val param = client.getParameter(req)
Remember to give your glue role iam permissions to ssm too!

how to use "closure-compiler " inside the java

I'm using closure-compiler which is provided by Google. I have JavaScript's in the string variable. need to compress the string using closure-compiler in java
I already tried the code from the following link http://blog.bolinfest.com/2009/11/calling-closure-compiler-from-java.html
This is the code I used "source" variable has the value of the javascript
Compiler compiler = new Compiler();
CompilerOptions options = new CompilerOptions();
// Advanced mode is used here, but additional options could be set, too.
CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
compiler.compile(source, options);
return compiler.toSource();
I have error in the following line: compiler.compile(source, options);
Compiler.complier() method does not require 2 parameters but it requires 3 parameters.
Have a look at this link.
You will understand the number and kind of parameters required for the method you are calling.

JRules Studio - Display values of IN_OUT parameters while testing

I'm using JRules Studio to develop some extremely simple rules. The rules populate an IN_OUT parameter. When the test finishes, is there a way of interrogating the values in the IN_OUT object?
Initially I'd like to interrogate it in the debugger, but any other ideas would be welcomed.
I am not sure to understand the question:
Your JAVA code is like this:
IlrSessionFactory factory = new IlrJ2SESessionFactory();
IlrStatelessSession session = factory.createStatelessSession();
IlrSessionRequest sessionRequest = factory.createRequest();
sessionRequest.setRulesetPath(“/RuleAppName/rulesetName”);
sessionRequest.setTraceEnabled(true);
sessionRequest.getTraceFilter().setInfoAllFilters(true);
Map inputParameters = new HashMap ();
Report in_report = new Report(); // no-arg constructor
// ... populate the Object ...
inputParameters.put("report", in_report);
sessionRequest.setInputParameters(inputParameters);
IlrSessionResponse sessionResponse = session.execute(sessionRequest);
Report out_report = (Report)sessionResponse.getOutputParameters().get("report“);
And then you play with your "out" parameters... As you would do with any JAVA object
If you want to see them at debug time, I would say:
1/ (not tested) Have a look on the "working memory tab" in the debugger perspective
I am not sure but this is the easiest way to find them if it is visible here
2/ (tested) in the initial action of the starting point of your ruleflow, add:
context.insert(the technical name of your parameter);
Not the "business name". Anyway avoid using BAL in technical artifact such as ruleflow, IRL rules!
By doing this you force the engine to insert your parameter in the working memory.
No duplication (don't worry, it will work like a charm) but as far as I can remember this is the shortest way to make them visible in the Eclipse debugger in JRules
Hope it helps

Categories

Resources