Database connection

Asked by KBaheti

I want to do program inside java such that I will take one query image from user and search for best match for it in database
Can i use sikuli comparison algorithm for this? Can i use sikuli script.jar file to search image inside database?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

Using sikuli from java is no problem, documented on the homepage and there are some relevant answers.

It is not possible, to tell Sikuli as such to look in a database for an image match.

if it is not possible, to restrict the search to a bunch of images,
you have to make a "full file search".
you can do it this way (python and pseudo code #--):

#-- get image from user as .png and save it the way capture() does it: img contains the filename
#-- setup your db-connection and get an iterator of all relevant images
while True:
   #-- get next image from db, save it as .png: nextImg has filename
   matches = Finder(nextImg).exists(img)
   if matches.hasNext(): break # found
   matches.destroy()
#-- check matches and destroy

Since within 1 second you may process 2-3 find()'s, the overall performance depending on the number of db-images to search may not be sufficient ;-)

Since you are in Java, it may be possible to use classes/methods deeper inside Sikuli, since deep internally, Sikuli processes the image compares in memory, so you may be able to avoid the saving to disk with every db-image.

If an image you look for is exactly the same in the db, you may look at the VDict feature, but this still requires to at least once in the beginning, you have to load all images from the db into the dictionary after saving them to disk as .png.

relevant information in the docs http://sikuli.org/trac/wiki/reference-0.10

Revision history for this message
KBaheti (kbaheti) said :
#2

Sir can it be done...

1. I will connect database with java
2. I will take image(*.png) from database
3. Query image will be converted into png format
4. Query image is stored in class Screen of sikuli
5. Database image is also converted into Screen Object
5. I will compare Screen objects( images)

But for this i need to know the Class Sikuli Attributes or there is any other class for storing images
and comparing them in sikuli

Revision history for this message
RaiMan (raimund-hocke) said :
#3

The method you want to use is Screen.find(img). but this makes a screenshot in this moment (held in memory) and tries to find the image stored in the file referenced by img in this screenshot. So I think you cannot "store/convert an image in a Screen object". A Screen object is only a container for these methods mentioned before, which are inherited from class Region.

Screen objects are not comparable in the sense, that their "visual content" can be compared (no method available)

For your approach, the VDict class may be nearer to your expectations
(if you mean image comparing in the sense img1-content eq img2-content)

If you really want to use the java internals of the Sikuli classes, you have to scan the source:
http://bazaar.launchpad.net/%7Esikuli-dev/sikuli/0.10/files/head%3A/sikuli-script/src/main/java/edu/mit/csail/uid/

before that you can get an overview with:
http://sikuli.org/doc/java/

Have fun ;-)

Revision history for this message
KBaheti (kbaheti) said :
#4

Sir i think it is bit complicated to use sikuli for image comparison in database
Basically sikuli is used for automation
Nothing is impossible but you should have sufficient time to do it
In my case it is not possible
Last question: Is there any way to get inbuilt library with good algorithms for comparing images in java
Thank you for helping me. any other suggestions will be appriciated.

Revision history for this message
KBaheti (kbaheti) said :
#5

Sir i think it is bit complicated to use sikuli for image comparison in database
Basically sikuli is used for automation
Nothing is impossible but you should have sufficient time to do it
In my case it is not possible
Last question: Is there any way to get inbuilt library with good algorithms for comparing images in java
Thank you for helping me. any other suggestions will be appriciated.

Revision history for this message
Best RaiMan (raimund-hocke) said :
#6

I agree.

Since Lance Jensen https://launchpad.net/~lance-ti gave a very good answer at question https://answers.launchpad.net/sikuli/+question/126272 about image matching, I think you should set this one to solved.

Revision history for this message
KBaheti (kbaheti) said :
#7

Thanks RaiMan, that solved my question.