Forums > Java

Controlling a TWAIN scanner using MAX

August 17, 2009 | 2:12 pm

I’ve created a max external in java that allows a TWAIN scanner to be controlled through max based on the Morena java/twain code. The external takes resolution, scan frame in inches, file path, and file name. It will save a file to the location specified then it can be loaded into a jitter matrix.

I have only been able to test the program using my epson scanner. It you want to test the program with your setup it would really help me debug and improve the external. Also, I haven’t tried this with a windows pc, would be interested to here if it worked for anyone.

You must download Morena at (http://www.gnome.sk/Twain/jtp_try&buy.html) and place the files in the max java classpath.

Attached are files that i wrote, which also need to be placed in the max java classpath for the below patch to run.

Example Batch

{
"boxes" : [ {
"box" : {
"maxclass" : "comment",
"text" : "float, in inches",
"numinlets" : 1,
"id" : "obj-7",
"fontsize" : 12.0,
"numoutlets" : 0,
"patching_rect" : [ 443.0, 77.0, 150.0, 20.0 ],
"fontname" : "Arial"
}

}
, {
"box" : {
"maxclass" : "comment",
"text" : "program will append .jpg",
"numinlets" : 1,
"id" : "obj-2",
"fontsize" : 12.0,
"numoutlets" : 0,
"patching_rect" : [ 408.0, 45.0, 150.0, 20.0 ],
"fontname" : "Arial"
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "print",
"numinlets" : 1,
"id" : "obj-5",
"fontsize" : 12.0,
"numoutlets" : 0,
"patching_rect" : [ 239.0, 225.0, 34.0, 20.0 ],
"fontname" : "Arial"
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "mxj maxScan2",
"numinlets" : 1,
"id" : "obj-4",
"fontsize" : 12.0,
"numoutlets" : 2,
"outlettype" : [ "", "" ],
"patching_rect" : [ 239.0, 195.0, 89.0, 20.0 ],
"fontname" : "Arial"
}

}
, {
"box" : {
"maxclass" : "button",
"numinlets" : 1,
"id" : "obj-1",
"numoutlets" : 1,
"outlettype" : [ "bang" ],
"patching_rect" : [ 299.0, 165.0, 20.0, 20.0 ]
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "mxj quickie maxScan2",
"numinlets" : 1,
"id" : "obj-16",
"fontsize" : 12.0,
"numoutlets" : 2,
"color" : [ 1.0, 1.0, 1.0, 1.0 ],
"outlettype" : [ "", "" ],
"patching_rect" : [ 30.0, 15.0, 130.0, 20.0 ],
"fontname" : "Arial"
}

}
, {
"box" : {
"maxclass" : "message",
"text" : "getfilename",
"numinlets" : 2,
"id" : "obj-15",
"fontsize" : 12.0,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 299.0, 135.0, 73.0, 18.0 ],
"fontname" : "Arial"
}

}
, {
"box" : {
"maxclass" : "message",
"text" : "setres 250",
"numinlets" : 2,
"id" : "obj-14",
"fontsize" : 12.0,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 299.0, 105.0, 67.0, 18.0 ],
"fontname" : "Arial"
}

}
, {
"box" : {
"maxclass" : "message",
"text" : "setpath /Users/….",
"numinlets" : 2,
"id" : "obj-13",
"fontsize" : 12.0,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 299.0, 15.0, 105.0, 18.0 ],
"fontname" : "Arial"
}

}
, {
"box" : {
"maxclass" : "comment",
"text" : "setpath stringnsetname stringnsetres intnsetframe x1, y1, x2, y2ngetfilename-post filename + .jpgnbang to scan",
"linecount" : 6,
"numinlets" : 1,
"id" : "obj-12",
"fontsize" : 12.0,
"numoutlets" : 0,
"patching_rect" : [ 30.0, 45.0, 195.0, 89.0 ],
"fontname" : "Arial"
}

}
, {
"box" : {
"maxclass" : "message",
"text" : "setname scan",
"numinlets" : 2,
"id" : "obj-8",
"fontsize" : 12.0,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 299.0, 45.0, 85.0, 18.0 ],
"fontname" : "Arial"
}

}
, {
"box" : {
"maxclass" : "message",
"text" : "scanframe 3. 6. 10. 10.",
"numinlets" : 2,
"id" : "obj-3",
"fontsize" : 12.0,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 299.0, 75.0, 133.0, 18.0 ],
"fontname" : "Arial"
}

}
],
"lines" : [ {
"patchline" : {
"source" : [ "obj-4", 0 ],
"destination" : [ "obj-5", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-1", 0 ],
"destination" : [ "obj-4", 0 ],
"hidden" : 0,
"midpoints" : [ 308.5, 187.0, 248.5, 187.0 ]
}

}
, {
"patchline" : {
"source" : [ "obj-15", 0 ],
"destination" : [ "obj-4", 0 ],
"hidden" : 0,
"midpoints" : [ 308.5, 153.0, 248.5, 153.0 ]
}

}
, {
"patchline" : {
"source" : [ "obj-14", 0 ],
"destination" : [ "obj-4", 0 ],
"hidden" : 0,
"midpoints" : [ 308.5, 123.0, 248.5, 123.0 ]
}

}
, {
"patchline" : {
"source" : [ "obj-3", 0 ],
"destination" : [ "obj-4", 0 ],
"hidden" : 0,
"midpoints" : [ 308.5, 93.0, 248.5, 93.0 ]
}

}
, {
"patchline" : {
"source" : [ "obj-8", 0 ],
"destination" : [ "obj-4", 0 ],
"hidden" : 0,
"midpoints" : [ 308.5, 63.0, 248.5, 63.0 ]
}

}
, {
"patchline" : {
"source" : [ "obj-13", 0 ],
"destination" : [ "obj-4", 0 ],
"hidden" : 0,
"midpoints" : [ 308.5, 33.0, 248.5, 33.0 ]
}

}
]
}


December 10, 2009 | 7:14 pm

I use canon FB636U to try, but it doesn’t work. I put the java file of "morena" into cycling74/java/lib, and follow your step. but…but… How can I do !


July 9, 2013 | 1:17 pm

Old topic but interesting.

I hope your still on the forum, a few questions:

# Can you resend the attached files needed to run the above patch?
They aren’t anymore in this post. I have the Morena files installed in the java class path.
# Can you resend the patch?
I know how to work in Max text files, but i can’t get the patch properly loaded in Max.

Thanks for reply!


Viewing 3 posts - 1 through 3 (of 3 total)