Wednesday, 15 June 2011

java - OpenCV Reading Image for Template Matching -



java - OpenCV Reading Image for Template Matching -

im using opencv in java, developing eclipse , images read way template matching.

string infile = "c:/image.png"; mat img = highgui.imread(infile);

this nice images not in local computer. should compare 2000 images on server in mysql database. saving 2000 images computer , reading them not create sense.

so need highgui.imread(infile) reads image: highgui.imread(image inimage) or maybe highgui.imread(file infile) , couldnt find java source edit/modify. need someway convert images coming mysql database mat type comparison(template matching) ...

more info: have mysql table columns: id, name, description, image1, image2. type of image1 , 2 columns "mediumblob" , when right click column image1 or image2 in "mysql workbench" take "open value in editor" there 3 tabs; binary, text, image, @ image image displayed perfectly. type of images png. in end want compare image1 image2. image2 infile , image1 templatefile.

i'm sorry thought question clear. seek rephrase it. have local computer , server. images stored in mysql database on server. want run application local computer retrieves/accesses 2 images on server , compares them via opencv template matching. afaik can't access column of mysql /server/home/user/mysql/image_table/mypicture.png , i'm writing because of "guneykayim" 's suggestion. how im planning retrieve images, havent tried yet plan :

blob imageblob = resultset.getblob(yourblobcolumnindex); inputstream binarystream = imageblob.getbinarystream(0, imageblob.length());

or

inputstream binarystream = resultset.getbinarystream(yourblobcolumnindex);

or

try{ class.forname(drivername); con = drivermanager.getconnection(url+dbname,username,password); statement stmt = con.createstatement(); resultset rs = stmt.executequery("select image image"); int = 0; while (rs.next()) { inputstream in = rs.getbinarystream(1); outputstream f = new fileoutputstream(new file("test"+i+".jpg")); i++; int c = 0; while ((c = in.read()) > -1) { f.write(c); } f.close(); in.close(); } }catch(exception ex){ system.out.println(ex.getmessage()); }

my question: want compare 2 images, retrieved mysql database.

highgui.imread();

this method expects string want give inputstream or outputstream file... said don't want save 2000 images on local computer. i'm open alternative ways well.

final simplest rephrasing : how can utilize template matching of java opencv on 2 images stored on mysql database.

in other words how can convert inputstream object mat object?

thanks reading.

i found reply here kudos guy, hero :) works perfectly, if want images in original color , not in grayscale should alter highgui.imread_grayscale highgui.imread_unchanged more info check

java mysql image opencv image-processing

No comments:

Post a Comment