Morena 7 Scanner completely ignores settings - java

I'm trying to setup Morena 7 in my java application, but i can't configure my scanner from my code, it ignores the settings i set.
Even though my scanner works with the example projects they provide with every supported setting.
I have searched the web for explanations but i have found very little to none documentation.
This the code i use to scan, it is identical to sample given in the tutorial document :
public void scan() throws Exception {
Manager manager = Manager.getInstance();
List devices = manager.listDevices();
if(devices.isEmpty()) {
System.out.println("No scanners detected");
return;
}
Device device = (Device) devices.get(0);
if (device instanceof Scanner) {
Scanner scanner = (Scanner) device;
scanner.setMode(Scanner.RGB_8);
scanner.setResolution(75);
scanner.setFrame(100, 100, 500, 500);
BufferedImage bimage = SynchronousHelper.scanImage(scanner);
// Do the necessary processes with bimage
manager.close();
}
else {
System.out.println("Please Connect A Scanner");
}
}
When i run this code, i get back an image but with default values from the printer, every setting like color, resolution and scan area (frame) are ignored.

First I think one reason can be the problem that Morena 7 always spools the scanner data into a file. You cannot access this scanner data before written to a file (unfortunately). So in case you want to scan bilevel images you will get a jpg image with greylevels. Morena saves scannerdata as jpg on Mac OSX and as a bmp on Windows.
You should check the temp file Morena 7 creates. Assuming you use the class SynchronousHelper from the Moran example you can edit the scanImage method which just loads the temp file using ImageIO.
If I check this temp file (on Mac OSX) all the set values as resolution and colormode are considered. Probably your scanner does not support some things? Or Morena does something wrong while saving the image.
And check the system error output. Should look something like the following where you can see that I set the resolution to 400dpi and the colormode to bilevel (ICScannerPixelDataTypeBW and bitDepth 1).
Functional unit: ICScannerFunctionalUnitFlatbed <0x7fefe850f4e0>:
pixelDataType : ICScannerPixelDataTypeBW
supportedBitDepths : <NSMutableIndexSet: 0x7fefe850f4b0>[number of indexes: 2 (in 2 ranges), indexes: (1 8)]
bitDepth : 1
supportedDocumentTypes : <NSMutableIndexSet: 0x7fefede9a9f0>[number of indexes: 6 (in 2 ranges), indexes: (1-5 10)]
documentType : 1
physicalSize : [width = 8.50 inches, height = 14.00 inches]
measurementUnit : 0
supportedResolutions : <NSMutableIndexSet: 0x7fefedee4390>[number of indexes: 7 (in 7 ranges), indexes: (100 150 200 300 400 600 1200)]
preferredResolutions : <NSMutableIndexSet: 0x7fefedee4390>[number of indexes: 7 (in 7 ranges), indexes: (100 150 200 300 400 600 1200)]
resolution : 400
overviewResolution : 150
supportedScaleFactors : <NSMutableIndexSet: 0x7fefedec3dd0>[number of indexes: 1 (in 1 ranges), indexes: (100)]
preferredScaleFactors : <NSMutableIndexSet: 0x7fefedec3dd0>[number of indexes: 1 (in 1 ranges), indexes: (100)]
scaleFactor : 100
acceptsThresholdForBlackAndWhiteScanning : NO
usesThresholdForBlackAndWhiteScanning : NO
thresholdForBlackAndWhiteScanning : 0
templates : (null)
vendorFeatures : (null)
state : 0x00000001

Related

Weka Experimenter mod : Problem creating experiment copy to run

In the experimenter mod in weka I have this configuration :
Results destination : Ex1_1.arff
Experiment type : cross-validation | number of folds : 10 | Classification
Dataset : soybean.arff.gz
Iteration Control : Number of repetitions : 10 | Data sets first
Algorithms : J48 -C 0.25 -M 2
This experience is saved as Ex1_1.xml (saving with .exp give the following error : Couldn't save experiment file : Ex1_1.exp Reason : java.awt.Component$AccessibleAWTComponent$AccessibleAWTComponentHandler)
And when I try to run this experience I have the following error : Problem creating experiment copy to run: java.awt.Component$AccessibleAWTComponent$AccessibleAWTComponentHandler
So it seem I have a problem with something like AWT in java... Do somebody have an idea ?
Thank you !

Why Build.VERSION.SDK_INT showing incorrect number?

I'm developing an android application and want to support android Q Beta.
So I tried android Q beta on my pixel 1.
But, when I want to check specific SDK version, it showing incorrect number.
I have read this and for android Q, SDK_INT should be 10000 (because it will similar with constant_value CUR_DEVELOPMENT).
I tried debugging to get SDK_INT number with this code :
CustomLog.v("Build", "build int : " + Build.VERSION.SDK_INT + " | Curr Dev : " + Build.VERSION_CODES.CUR_DEVELOPMENT + " | Build baseOS: " + Build.VERSION.BASE_OS);
CustomLog.v("Build", "preview sdk int : " + Build.VERSION.PREVIEW_SDK_INT + " | Code Nanme : " + Build.VERSION.CODENAME + " | Version Q : " + Build.VERSION_CODES.Q);
I expect the output Build.VERSION.SDK_INT to be 10000, but the actual output is 28, which is constant_value for android P.
This is the log in my logcat:
and this is information the devices:
That's normal - and it is gonna be this way until Q is officially released I guess. If you want to test against Q you could use
BuildCompat#isAtLeastQ()
As point out by CommonsWare, The real value (29) should start appearing around Q Beta 4 when the APIs are supposed to be finalized.

java com.itextpdf.text.exceptions.InvalidPdfException: The document has no page root

I'm trying to read a PDF files and I got this exception
com.itextpdf.text.exceptions.InvalidPdfException: The document has no page root (meaning: it's an invalid PDF).
at com.itextpdf.text.pdf.PdfReader.readPages(PdfReader.java:1248)
at com.itextpdf.text.pdf.PdfReader.readPdf(PdfReader.java:739)
at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:181)
at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:219)
at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:207)
at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:197)
at com.mitech.med.watermark.Test2.main(Test2.java:11)
I used itext 5.5.10.
This is my code:
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
PdfReader reader = new PdfReader("C:/Users/matteo.fusi/Downloads/testPDF/1142.pdf");
} catch (Exception e) {
e.printStackTrace();
}
}
This is the link to the PDF document:
https://drive.google.com/file/d/0B2IrLGj9wefRVFZxSUhkN0o0N1k/view?usp=sharing
Thanks in advance
Regards
Matteo
I get the same issue on itext 5.5.10. I haven't taken a look yet on some new changes on the latest version. But it's working fine on itext 5.3.4. You could try on that version
The PDF in question is broken.
This is the page tree root dictionary object:
1 0 obj
<</Type /Pages /Count 1
/Kids[
4 0 R
]
/Type /Page
/MediaBox [ 0 0 595 842 ]
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
/Resources <<
/Font << /F0 6 0 R /F1 7 0 R /F2 8 0 R /F3 9 0 R /F4 10 0 R /F5 11 0 R /F6 12 0 R /F7 13 0 R /F8 14 0 R /F9 15 0 R /F10 16 0 R /F11 17 0 R /F12 18 0 R /F13 19 0 R /F14 20 0 R >>
/XObject <<
/Im0 5 0 R >>
>>
>>endobj
As you see the key Type occurs twice, once with value Pages and once with value Page. But the specification ISO 32000-1 clearly states in section 7.3.7 - Dictionary Objects:
Multiple entries in the same dictionary shall not have the same key.
(This, by the way, is a fairly obvious requirement for dictionary objects in general...)
The result of such a defect may be different in different PDF processors, the major obvious cases:
They might explicitly check for such problems and reject the file outright.
They might not check but use the first value assigned to the key.
They might not check but use the last value assigned to the key.
iText appears to be of the third kind. As far as iText is concerned, therefore, the page tree root dictionary has a Type value Page. But the specification requires the Type of a page tree node to be Pages. Thus, iText throws the observed exception.
Firstly I would try an alternative that seems to work for a lot of people :
http://pdfbox.apache.org/ <- Inspired by an older post I researchd on stack overflow
Secondly while debugging the issue I found this
rootPages == null || (!PdfName.PAGES.equals(rootPages.get(PdfName.TYPE))
&& !PdfName.PAGES.equals(rootPages.get(new PdfName("Types"))))
Is not satisfied hence your problem. I believe it might be a current Bug in Itext.
DFTBA

What is the format name of this data?

Short: I'd like to know the name of this format!
I would like to know if this is a special common format or just a simple self-generated config file:
scenes : {
Scene : {
class : Scene
sources : {
Game Capture : {
render : 1
class : GraphicsCapture
data : {
window : "[duke3d]: Duke Nukem 3D Atomic Edition 1.4.3 STABLE"
windowClass : SDL_app
executable : duke3d.exe
stretchImage : 0
alphaBlend : 0
ignoreAspect : 0
captureMouse : 1
invertMouse : 0
safeHook : 0
useHotkey : 0
hotkey : 123
gamma : 100
}
cx : 1920
cy : 1080
}
}
}
}
My background is, that I would like to read multiple files like this one above. And I don't want to implement a whole new parser for this. That's why I want to fall back on java libraries which have already implemented this feature. But without being aware of such code formats, it's quite difficult to search for this libraries.
// additional info
This is a config file or a "scene file" for Open Broadcaster Software.
Filename extension is .xconfig
This appears to be a config file or a "scene file" for Open Broadcaster Software.
When used with OBS it has a extension of .xconfig
Hope this helps.
-Yang
I got some feedback from the main developer of this files.
As i thought, this is not a know format - just a simple config file.
solved!

get MPEG-TS stream media info

I'm making a player that can play an MPEG-TS stream and display all its videos at once (for monitoring purposes) in one frame using Xuggler for JAVA.
My problem is getting to determine what programs this stream holds (tv programs) and what are its streams...
for example : audio stream 1 and video stream 3 belong to program "BBC".
Now I already got it working for a .ts file by using MediaInfo http://mediaarea.net/en/MediaInfo/ like so :
MediaInfo.exe -LogFile="log.txt" "some .ts file" .... which logs a file like this :
Menu #2
ID : 1001 (0x3E9)
Menu ID : 1202 (0x4B2)
Duration : 13mn 33s
List : 2001 (0x7D1) (MPEG Video) / 3002 (0xBBA) (MPEG Audio, English)
Language : / English
Service name : NBN
Service provider : NILESAT
Service type : digital television
UTC 2006-03-28 00:00:00 : en:NBN / en:Nilesat / / / 99:00:00 / Running
and then I parsed the file in java
but I need to make this work for a live stream and when I give MediaInfo a URL instead of a file it gives this error :
Libcurl library not found
I also tried vlc commands but turns out it doesn't have this option and only available in gui (show codec information)...
the player is already working and I got an extractor too... just need this media info to work... any ideas?
EDIT : I found out FFprobe which is bundled with FFmpeg http://www.ffmpeg.org/ can do the task
but for some reason I can't read anything from the input stream.
Here's what the output looks like:
Input #0, mpegts, from 'D:\record ts\PBR_REC_20140426094852_484.ts':
Duration: N/A, start: 6164.538011, bitrate: N/A
Program 1201
Metadata:
service_name : Arabica TV
service_provider: Nilesat
Stream #0:10[0x7db]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv42
0p(tv), 720x576 [SAR 16:15 DAR 4:3], max. 2348 kb/s, 25 fps, 25 tbr, 90k tbn, 50
tbc
Stream #0:4[0xbcf]: Audio: mp2, 48000 Hz, stereo, s16p, 384 kb/s
Program 1202
I tried this in JAVA:
try {
Process process ;
Scanner sc;
ProcessBuilder processBuilder = new ProcessBuilder("C:\\Users\\vlatkozelka\\Desktop\\ffmpeg-20140623-git-ca35037-win64-static\\bin\\ffprobe.exe","-i",filename);
process=processBuilder.start();
sc=new Scanner(process.getInputStream());
process=processBuilder.start();
while(sc.hasNext()){
System.out.println(sc.nextLine());
}
} catch (IOException ex) {
Logger.getLogger(ChannelDivider.class.getName()).log(Level.SEVERE, null, ex);
}
but the sc.hasNext() just hangs like there is no input
then I tried writing to a file with cmd by using > but it gave me a blank file
however trying both methods with FFprobe -h (help command) does give output which is very much confusing me, I see output in cmd but cant read it...
I just solved this, and hope someone might make use of it:
it turns out that FFprobe was writing to stderr, not stdout,
so instead of:
getInputStream()
I used:
getErrorStream()
Now all I have to do is parse that :)

Categories

Resources