Help : linking imgSeek sourcecode to Python lib

2 views
Skip to first unread message

louis.levy

unread,
Feb 15, 2008, 5:42:10 AM2/15/08
to imgseek_dev
Hello,

I have been trying desperately to compile and run the source code of
ImgSeek on MSVC using the following :
- Visual C++ 2005
- Microsoft Platform SDK for Windows Server 2003
- Image Magick 6.3.8-Q8
- Python 2.5, Python 2.4 and even Python 2.2 (prior to the release of
ImgSeek source code)
- Windows XP SP2

I did the following connections within the includes files :
- PythonXX\include
- ImageMagick-6.3.8-Q8\include
- Microsoft Platform SDK for Windows Server 2003 R2\Include

and libraries files :
- PythonXX\Lib
- Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib
- Program Files\ImageMagick-6.3.8-Q8\lib

Whatever the version of Python I use, imgdb.cpp is compiled but during
the linking I get the following error :
LINK : fatal error LNK1104: cannot open file 'pythonXX_d.lib'

I have been looking towards some softwares like Boost.build but it did
not work either. What should I do ? I am a complete beginner in C++/
Python so please use words I can understand and extensive explanations
so that I can apply them.

Thank you in advance for your help !

Louis

Ricardo Niederberger Cabral

unread,
Feb 15, 2008, 6:48:23 AM2/15/08
to imgse...@googlegroups.com
Try building with the Release configuration of the MSVC project,
instead of the Debug one.

You may need to redo your path configurations (which seem correct to
me) for this profile.

Best regards,
--
Ricardo Niederberger Cabral
http://www.imgseek.net/
ricardo.cabral at imgseek.net
skype: rnc000

louis.levy

unread,
Feb 16, 2008, 12:00:02 AM2/16/08
to imgseek_dev
Thank you for your quick reply.
I now have a dozen of these error messages :
imgdb.obj : error LNK2001: unresolved external symbol
__imp__FunctionName
with Function Name = DestroyImage, BlobToImage etc.

I have reinstalled ImageMagick using this time the 6.3.5-5-Q8 version
(instead of the 6.3.8-Q8) but it did not do any good.
What should I do next ? Thank you in advance for your help.

Regards,
Louis

On Feb 15, 8:48 pm, Ricardo Niederberger Cabral
<ricardo.cab...@imgseek.net> wrote:
> Try building with the Release configuration of the MSVC project,
> instead of the Debug one.
>
> You may need to redo your path configurations (which seem correct to
> me) for this profile.
>
> Best regards,
> --
> Ricardo Niederberger Cabralhttp://www.imgseek.net/

Ricardo Niederberger Cabral

unread,
Feb 16, 2008, 5:32:10 PM2/16/08
to imgse...@googlegroups.com
Those missing symbols belong to ImageMagick. Please make sure you have
correctly set up the include and library directories for the debug
build profile so it points to the correct imagemagick location.

Also dont forget to include a reference on the linker preferences to
the imagemagick (something like "magick") object library (.lib) and to
python. Open the original MSVC solution from the source release (or
svn) and look at the release link and compiler configurations.

--
Ricardo Niederberger Cabral


http://www.imgseek.net/
ricardo.cabral at imgseek.net
skype: rnc000

louis.levy

unread,
Feb 18, 2008, 1:59:44 AM2/18/08
to imgseek_dev
Thank you for your advice.
Building the project goes just fine, but running it is kind of a
problem.

I get a prompt that follows like this:

Engine - Executable for Debugging Session
Please specify the name of the executable file to be used for the
debug session.

Executable file name:
(gives me some options then a Browse... option)

URL where the project can be accessed (ATL server only):
(input prompt)

I also have a OK, or CANCEL.

What should I do next ?

On Feb 17, 7:32 am, Ricardo Niederberger Cabral
<ricardo.cab...@imgseek.net> wrote:
> Those missing symbols belong to ImageMagick. Please make sure you have
> correctly set up the include and library directories for the debug
> build profile so it points to the correct imagemagick location.
>
> Also dont forget to include a reference on the linker preferences to
> the imagemagick (something like "magick") object library (.lib) and to
> python. Open the original MSVC solution from the source release (or
> svn) and look at the release link and compiler configurations.
>
> --

louis.levy

unread,
Feb 18, 2008, 5:43:18 AM2/18/08
to imgseek_dev
I have created a new project with a main(), which I called Executable.
After running and compiling it, MSVC created a .exe file in the
release folder of the project. I have used this .exe file to link with
imgdb core.
Does it mean that from now on I can call any function from imgdb core
inside Executable and build Executable without rebuilding imgdb core ?

Ricardo Niederberger Cabral

unread,
Feb 18, 2008, 7:27:46 AM2/18/08
to imgse...@googlegroups.com
The C++ code available at the imgdb source module is supposed to be
compiled into a python extension module (.pyd file on Windows or .so
on Unix, just like a dynamic link library) and used through a python
"import" statement.

The MSVC solution file that comes with this module compiles into
imgdb.pyd, which can be used on python programs with a statement like
"import imgdb" (see the source of isk-daemon.py for its usage).
--
Ricardo Niederberger Cabral


http://www.imgseek.net/
ricardo.cabral at imgseek.net
skype: rnc000

Louis LEVY

unread,
Feb 18, 2008, 10:00:34 AM2/18/08
to imgse...@googlegroups.com
How do you compile the imgdb source module into a .pyd file (I am using Windows) ? By using python.exe instead of creating an executable file as I did ?

I am aiming at adding some new functionalities to the imgdb core. I dont have any knowledge of python and I was rather thinking of using C++ for that. What are the advantages of using Python rather than C++ ? Is Python used primarily for the integration of imgdb on a website's server or for something else ?

Can I still use C++ without missing any main functions of the imgdb source module ? For example, will I still be able to import my image database and work easily on it with MSVC ?

Thank you in advance for your answers.

Louis

2008/2/18, Ricardo Niederberger Cabral <ricardo...@imgseek.net>:

Ricardo Niederberger Cabral

unread,
Feb 18, 2008, 8:58:22 PM2/18/08
to imgse...@googlegroups.com
The solution and MSVC project that is versioned on the imgdb source module does exactly that. The build output is a static library that is linked against python and imagemagick development libraries.

Python is mostly used for exposing the image database and content-based image algorithms through the network.

You can still add functionality to the C++ core and load it as a python extension module.

If you want to use the similarity C++ code as a standalone C++ console program, you'd need to write a main() function that, for example, accepts command line options and passes them to other functions, for adding images to a database, performing queries etc.

-- 
Ricardo Niederberger Cabral
ricardo.cabral at imgseek.net
skype: rnc000

Louis LEVY

unread,
Mar 12, 2008, 4:04:31 AM3/12/08
to imgse...@googlegroups.com
I have finally decided to use Python. But I dont understand how I can import the imgdb core module into Python. So far, I have inserted the "imgdb Object File Library" I have obtained through compiling the imgdb source code with MSVC directly into Python's libraries.
Then I have tried the command line "import imgdb" : without any success.

Besides, I cant see where the function "query for similar image" found in Image Seek is defined in the source code.  The closest I have found was in imgdb.cpp : double calcAvglDiff(const int dbId, long int id1, long int id2).
Since this function involves the comparison of only two images, it does not seem right. I would expect the signature of the function I am looking for look like :
- input : an image database and the image to be compared with
- output : a list of images belonging to the input image database and a corresponding list of values (% of similarity).

Thank you in advance for helping me out.

Louis

2008/2/19, Ricardo Niederberger Cabral <ricardo...@imgseek.net>:

Ricardo Niederberger Cabral

unread,
Mar 12, 2008, 10:19:43 PM3/12/08
to imgse...@googlegroups.com

--
Ricardo Niederberger Cabral
http://www.imgseek.net/
ricardo.cabral at imgseek.net
skype: rnc000

On 12/03/2008, at 05:04, Louis LEVY wrote:

> I have finally decided to use Python. But I dont understand how I
> can import
> the imgdb core module into Python. So far, I have inserted the
> "imgdb Object
> File Library" I have obtained through compiling the imgdb source
> code with
> MSVC directly into Python's libraries.
> Then I have tried the command line "import imgdb" : without any
> success.

imgdb.pyd (MSVC build output) should be on the same path where
imgdb.py (provided on the source distribution) is.

Place both of these on python global module path or on the same
directory of the python program doing an "import imgdb".

>
>
> Besides, I cant see where the function "query for similar image"
> found in
> Image Seek is defined in the source code. The closest I have found
> was in
> imgdb.cpp : double calcAvglDiff(const int dbId, long int id1, long
> int id2).

if you're talking about the c++ imgdb module found on the "classic"
desktop imgseek, try one of these

extern void queryImgID(long ,int );
extern int queryImgFile(char *,int ,int );

and these for retrieving query results:

extern int getNumResults();
extern long getResultID();
extern double getResultScore();

Louis LEVY

unread,
Mar 13, 2008, 4:20:51 AM3/13/08
to imgse...@googlegroups.com
Thank you for your mail.

If I take it correctly, there are two different imgdb modules :
 
- The "classic" desktop imgseek, let's refer to it as Desktop module, located in https://imgseek.svn.sourceforge.net/svnroot/imgseek/trunk/imgseek-python/imgSeekLib/

- Another one, let's refer to it as Server module, located in
https://imgseek.svn.sourceforge.net/svnroot/imgseek/trunk/net.imgseek.imgdb/src/net/imgseek/imgdb/core/

While the Server module does not include the main queryImg function I am loooking for, the Desktop module does. Is that right ?

Thanks to your help, I have finally managed to import the Server module in Python. However, how am I suppoded to import the Desktop module ? Here is what I have tried so far : I have directly used the imgdb.pyd available in

https://imgseek.svn.sourceforge.net/svnroot/imgseek/trunk/imgseek-python/imgSeekLib/.

Since I could not find the corresponding imgdb.py in the same location, I have tried to use the imgdb.py available in

https://imgseek.svn.sourceforge.net/svnroot/imgseek/trunk/net.imgseek.imgdb/src/net/imgseek/imgdb/core/.

It did not work.

I have therefore two questions :

 1)  Can I directly use this imgdb.pyd without building the Desktop imgdb C++ code against Python ? I have tried to build it anyway by using the following files :

- imgdb.cpp, imgdb.h, haar.cpp, haar.h, imgdb_wrap.cxx located in https://imgseek.svn.sourceforge.net/svnroot/imgseek/trunk/imgseek-python/imgSeekLib/

- imgdb_wrap.h (by the way I added #include <imgdb_warp.h> inside imgdb_wrap.cxx since I could not find any preprocessor command line for any header file in it), bloom_filter.cpp, bloom_filter.h located in https://imgseek.svn.sourceforge.net/svnroot/imgseek/trunk/net.imgseek.imgdb/src/net/imgseek/imgdb/core/

It did not work. I had to install Platform SDK (to get the windows.h header). Eventually, I had the following errors :

-------------------------------------------------------------------------------------------------------------------------------------------------------------------

c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(641) : error C2146: syntax error : missing ';' before identifier 'queryImgDataForThres'
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(641) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(641) : error C2065: 'sigMap' : undeclared identifier
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(641) : error C2059: syntax error : ','
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(642) : error C2146: syntax error : missing ';' before identifier 'queryImgDataForThresFast'
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(642) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(642) : error C2059: syntax error : ','
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(643) : error C2146: syntax error : missing ';' before identifier 'clusterSim'
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(643) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(643) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(644) : error C2059: syntax error : ')'
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(645) : error C2059: syntax error : ')'
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(646) : error C2059: syntax error : ')'
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(647) : error C2146: syntax error : missing ';' before identifier 'popLong2List'
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(647) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(647) : error C2059: syntax error : ')'
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(803) : error C2065: 'arg1' : undeclared identifier
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(810) : error C2146: syntax error : missing ';' before identifier 'result'
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(810) : error C2065: 'result' : undeclared identifier
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(823) : error C3861: 'queryImgDataForThres': identifier not found
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(826) : error C2065: 'resultptr' : undeclared identifier
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(827) : error C2061: syntax error : identifier 'long_list'
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(840) : error C2146: syntax error : missing ';' before identifier 'result'
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(847) : error C3861: 'queryImgDataForThresFast': identifier not found
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(851) : error C2061: syntax error : identifier 'long_list'
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(862) : error C2146: syntax error : missing ';' before identifier 'result'
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(869) : error C2061: syntax error : identifier 'long_list_2'
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(884) : error C3861: 'getLongListSize': identifier not found
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(899) : error C3861: 'popLongList': identifier not found
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(914) : error C3861: 'getLongList2Size': identifier not found
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(924) : error C2146: syntax error : missing ';' before identifier 'result'
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(929) : error C3861: 'popLong2List': identifier not found
c:\documents and settings\louis.yamaguti-6lnefl\my documents\visual studio 2005\projects\imgseek\imgseek\imgdb_wrap.cxx(933) : error C2061: syntax error : identifier 'long_list'

------------------------------------------------------------------------------------------------------------------------------------------------------

2) Where can I find the Desktop module's corresponding imgdb.py ?


Thank you in advance for your answers.

Regards,

Louis

2008/3/13, Ricardo Niederberger Cabral <ricardo...@imgseek.net>:

Ricardo Niederberger Cabral

unread,
Mar 13, 2008, 7:30:14 AM3/13/08
to imgse...@googlegroups.com
On 13/03/2008, at 05:20, Louis LEVY wrote:

Thank you for your mail.

If I take it correctly, there are two different imgdb modules :

correct


 
- The "classic" desktop imgseek, let's refer to it as Desktop module, located in https://imgseek.svn.sourceforge.net/svnroot/imgseek/trunk/imgseek-python/imgSeekLib/

- Another one, let's refer to it as Server module, located in
https://imgseek.svn.sourceforge.net/svnroot/imgseek/trunk/net.imgseek.imgdb/src/net/imgseek/imgdb/core/

correct



While the Server module does not include the main queryImg function I am loooking for, the Desktop module does. Is that right ?

no. The server module has the same core functionalities as the Desktop module, plus some others. Including an easier to work with query function:

std::vector<double> queryImgID(const int dbId, long int id, int numres);

which returns an array of results [result_id1,score_1,result_id2,score_2] (or something like that, see iskdaemon.py on the isk-daemon source code) instead of having to use 3 other functions to return results.



Thanks to your help, I have finally managed to import the Server module in Python. However, how am I suppoded to import the Desktop module ? Here is what I have tried so far : I have directly used the imgdb.pyd available in

Do you have a specific need for importing the Desktop module? My advice is on compiling from source the server module and using it on your app.




https://imgseek.svn.sourceforge.net/svnroot/imgseek/trunk/imgseek-python/imgSeekLib/.

Since I could not find the corresponding imgdb.py in the same location, I have tried to use the imgdb.py available in

https://imgseek.svn.sourceforge.net/svnroot/imgseek/trunk/net.imgseek.imgdb/src/net/imgseek/imgdb/core/.

It did not work.

yes, they don't have the exact same functions and signatures



I have therefore two questions :

 1)  Can I directly use this imgdb.pyd without building the Desktop imgdb C++ code against Python ? I have tried to build it anyway by using the following files :

i think so.



- imgdb.cpp, imgdb.h, haar.cpp, haar.h, imgdb_wrap.cxx located in https://imgseek.svn.sourceforge.net/svnroot/imgseek/trunk/imgseek-python/imgSeekLib/

- imgdb_wrap.h (by the way I added #include <imgdb_warp.h> inside imgdb_wrap.cxx since I could not find any preprocessor command line for any header file in it), bloom_filter.cpp, bloom_filter.h located in https://imgseek.svn.sourceforge.net/svnroot/imgseek/trunk/net.imgseek.imgdb/src/net/imgseek/imgdb/core/

It did not work. I had to install Platform SDK (to get the windows.h header). Eventually, I had the following errors :

make sure the compiler is on C++ mode and that you're also including python.h (on the python install dir) and imagemagick/include on the include path and linking against python and imagemagick static libraries. 

------------------------------------------------------------------------------------------------------------------------------------------------------

2) Where can I find the Desktop module's corresponding imgdb.py ?



if you insist on using the Desktop module, you can generate it with swig, running something like

swig -c++ -python -module imgdb imgdb.cpp

Louis LEVY

unread,
Mar 16, 2008, 9:45:15 AM3/16/08
to imgse...@googlegroups.com
Hello Ricardo,

Thank you for your last answer. I am now using the Server module.

I have first tried to use the classes and functions defined in iskdaemon.py. While I succeeded in creating an ImgDB instance, I could not understand the use of the parameter settings in __init__(self, settings). I input a random int value. I was then able to create a DB using createdb, save it, load it etc. However, I was unable to add any image using addImage(self, dbId, fname,newid = None)

Here are my command lines:

import iskdaemon
Database = iskdaemon.ImgDB(999)
Database.createdb(1)
Database.savedbas(1,"C:\\Python25\\ImgDB\\Img.txt")
Database.loaddb(1,"C:\\Python25\\ImgDB\\Img.txt")
Database.addImage(1,"C:\\Python25\\ImgDB\\test.jpg")

Here is my debug output :

ImageDB     : DEBUG    createdb(dbId=1)
ImageDB     : DEBUG    New dbSpace requires init: 1
ImageDB     : DEBUG    resetdb(dbId=1)
ImageDB     : DEBUG    resetdb() ok
ImageDB     : DEBUG    savedbas(dbId=1, fname='C:\\Python25\\ImgDB\\Img.txt')
ImageDB     : INFO     Database saved:DPSpace ; addCount=0 ; addMinCount=0 ; addMinCur=0 ; addSinceLastSave=0 ; fileName=C:\Python25\ImgDB\Img.txt ; id=1 ; lastAddPerMin=0 ; lastId=1 ; lastQueryPerMin=0 ; lastSaveTime=1205674088.14 ; queryCount=0 ; queryMinCount=0 ; queryMinCur=0 ;  to C:\Python25\ImgDB\Img.txt
ImageDB     : DEBUG    loaddb(dbId=1, fname='C:\\Python25\\ImgDB\\Img.txt')
ImageDB     : WARNING  Load is replacing existing database id:1
ImageDB     : INFO     Database loaded: DPSpace ; addCount=0 ; addMinCount=0 ; addMinCur=0 ; addSinceLastSave=0 ; fileName=C:\Python25\ImgDB\Img.txt ; id=1 ; lastAddPerMin=0 ; lastId=1 ; lastQueryPerMin=0 ; lastSaveTime=0 ; queryCount=0 ; queryMinCount=0 ; queryMinCur=0 ;

Traceback (most recent call last):
  File "C:\Python25\test.py", line 23, in <module>
    Database.addImage(1,"C:\\Python25\\ImgDB\\test.jpg")
  File "C:\Python25\imgSeekLib\utils.py", line 81, in checkFunc
    return func(*args, **kwargs)
  File "C:\Python25\imgSeekLib\ImageDB.py", line 237, in addImage
    if self._settings.automaticSave and \
AttributeError: 'int' object has no attribute 'automaticSave'

I then tried to use upstream the imgdb module's functions. This time, I was able to create DBs, save, load DB, add images, use the functions double calcDiff(const int dbId, long int id1, long int id2), and  std::vector<double> queryImgIDKeywords(const int dbId, long int id, int numres, int kwJoinType, int_vector keywords).

Here are my command lines:

from imgdb import *
initDbase(1)
addImage(1,1,"C:\\Python25\\ImgDB\\test.jpg")
addImage(1,2,"C:\\Python25\\ImgDB\\test2.jpg")
savedb(1,"C:\\Python25\\ImgDB\\Img.txt")
print calcDiff(1,1,2)
print queryImgID(1,1,10)

Both images test and test2 are identical.
I obtained two surprising results :
- To calcDiff, the output was -35.8500005752. Since the images are identical, I would have expected the result to be 0. What is the meaning of this result ?
- To queryImg, the output was ( ). I take it that an error occurred somewhere, which would explain this blank result (I have checked beforehand that both images were indeed loaded inside the DB). Could you help me figure it out ?

Thank you in advance for your help !

Louis




2008/3/13, Ricardo Niederberger Cabral <ricardo...@imgseek.net>:
On 13/03/2008, at 05:20, Louis LEVY wrote:

Louis LEVY

unread,
Mar 18, 2008, 11:46:22 AM3/18/08
to imgse...@googlegroups.com
Hello Ricardo,

I figure you might be busy these days. I am growing desperate : I have been stuck for a couple of days now as I was not able to solve on my own the problem I sent you last time. I would be extremely grateful if you could help me out !
Thank you in advance for your answer.

Louis

2008/3/16, Louis LEVY <louis...@gmail.com>:

Ricardo Niederberger Cabral

unread,
Mar 18, 2008, 10:47:41 PM3/18/08
to imgse...@googlegroups.com
Sorry for taking this long. Been busy indeed.

`


On 16/03/2008, at 10:45, Louis LEVY wrote:

> Hello Ricardo,
>
> Thank you for your last answer. I am now using the Server module.
>
> I have first tried to use the classes and functions defined in
> iskdaemon.py. While I succeeded in creating an ImgDB instance, I
> could not understand the use of the parameter settings in
> __init__(self, settings). I input a random int value. I was then
> able to create a DB using createdb, save it, load it etc. However, I
> was unable to add any image using addImage(self, dbId, fname,newid =
> None)

The ImgDB constructor may be buggy. Try using the simpler (and more
declarative) API as exemplified on the unit tests and sample clients
distributed with the source code. Which is what you mentioned as using
the imgdb module functions directly.

> I then tried to use upstream the imgdb module's functions. This
> time, I was able to create DBs, save, load DB, add images, use the
> functions double calcDiff(const int dbId, long int id1, long int
> id2), and std::vector<double> queryImgIDKeywords(const int dbId,
> long int id, int numres, int kwJoinType, int_vector keywords).
>
> Here are my command lines:
>
> from imgdb import *
> initDbase(1)
> addImage(1,1,"C:\\Python25\\ImgDB\\test.jpg")
> addImage(1,2,"C:\\Python25\\ImgDB\\test2.jpg")
> savedb(1,"C:\\Python25\\ImgDB\\Img.txt")

sounds right

>
> print calcDiff(1,1,2)
> print queryImgID(1,1,10)
>
> Both images test and test2 are identical.
> I obtained two surprising results :
> - To calcDiff, the output was -35.8500005752. Since the images are
> identical, I would have expected the result to be 0. What is the
> meaning of this result ?


The [0,1] scale (as calculated by the python wrapper) is artificial.
Internally, the similarity ratio for a given image, given as a result
of running the querying algorithm described on the paper is a float
number with no absolute meaning (this similarity result of -35... that
you mentioned). It should be considered only relatively to other
images. So if sim(x,y) > sim(x,z) then x is more similar to y than it
is to z. That's the only kind of conclusion you should get at.
Internally imgSeek will normalize the output score calculated for each
indexed candidate image by considering the max similarity as being the
average similarity achieved by running several similar tests as you
did and adding a marging of error so we don't run the risk of getting
a result greater than 1. Furthermore, I'm not entirely sure that
score(x,x) > score(x,y) for each images x and y.

>
> - To queryImg, the output was ( ). I take it that an error occurred
> somewhere, which would explain this blank result (I have checked
> beforehand that both images were indeed loaded inside the DB). Could
> you help me figure it out ?

Are those the only two images in the database? It may return an empty
result list if you request for more result images (on your example:
10) than there is on the database. Try adding more images.

Louis LEVY

unread,
Mar 19, 2008, 12:23:43 AM3/19/08
to imgse...@googlegroups.com
Hello Ricardo,

Thank you for taking the time to answer my questions !
I added a couple of few images as you advised me and indeed it worked !
I obtained results like the kind below :

print queryImgID(1,5,9)
(9.0, 0.070145299138105521, 4.0, -5.9702660339192128, 7.0, -6.8460502249184003, 8.0, -6.8523225166971358, 6.0, -7.3811261267682884, 1.0, -8.1248547762653516, 3.0, -9.7831398425691418, 2.0, -11.96115838770644, 5.0, -38.91000035405159)

print queryImgID(1,7,9)
(6.0, -4.0120659777273113, 5.0, -6.8460502249184003, 1.0, -7.5921484994136454, 9.0, -8.6838044103783858, 2.0, -9.3101353053709026, 3.0, -9.5282856254401516, 8.0, -9.8236064434255965, 4.0, -9.8542157684696541, 7.0, -36.700000464916229)

Using relative comparisons, the conclusions I can draw are :
- As sim(9,5)>sim(4,5)>sim(7,5)>sim(8,5)>etc,  img9 is more similar to img5 than img4 is, img4 is in turn more similar to img5  than img7 etc.
- Similarly sim(6,7)>sim(5,7)>sim(1,7)>sim(9,7)>etc., img6 is more similar to img7 than img5 is, img5 is in turn more similar to img7 than img1 is etc.

However, can I make aboslute comparisons as well :
- Since sim(9,5)>sim(6,7), is img9 more similar to img5 than img6 is similar to img7 ?
- More generally does sim(x,y)>sim(z,t) imply that x more similar to y than z is similar to t ?
Following this idea of absolute comparison, I have noticed that sim(x,y) can take positive values (ike sim(9,5)). What is the range of sim(x,y) ?

It seems that sim(x,y) has been defined so that sim(x,y)>sim(x,x) for each images x and y. However, we dont have sim(x,x) = sim(y,y) for each images x and y - for instance sim(7,7)>sim(5,5). That is why I am not so sure that I can make aboslute comparisons like the one above.

Thank you again for your help !

Louis



2008/3/19, Ricardo Niederberger Cabral <ricardo...@imgseek.net>:

Louis LEVY

unread,
Mar 19, 2008, 1:04:31 AM3/19/08
to imgse...@googlegroups.com
I am also wondering:
Since sim(x,y)>sim(x,x) for each images x and y, would not that mean that sim(x,y)>sim(x,z) implies z is more similar to x than y is similar to x. It would therefore be the other way around of what you wrote to me. I am bit confused...

2008/3/19, Louis LEVY <louis...@gmail.com>:

Louis LEVY

unread,
Mar 21, 2008, 3:19:35 AM3/21/08
to imgse...@googlegroups.com
Hello Ricardo,

I guess you are still pretty busy. I apologize for the disturbance, however I am once again growing desperate : I really need the answers to my last questions to fully understand how to interpret the return results to sim(x,y). I would be extremely grateful if you could rapidly answer me !
Thank you in advance for your help !

Louis



2008/3/19, Louis LEVY <louis...@gmail.com>:

Ricardo Niederberger Cabral

unread,
Mar 25, 2008, 9:01:08 PM3/25/08
to imgse...@googlegroups.com
On 19/03/2008, at 02:04, Louis LEVY wrote:
I am also wondering:
Since sim(x,y)>sim(x,x) for each images x and y, would not that mean that sim(x,y)>sim(x,z) implies z is more similar to x than y is similar to x. It would therefore be the other way around of what you wrote to me. I am bit confused...

2008/3/19, Louis LEVY <louis...@gmail.com>:
I added a couple of few images as you advised me and indeed it worked !

I obtained results like the kind below :

print queryImgID(1,5,9)
(9.0, 0.070145299138105521, 4.0, -5.9702660339192128, 7.0, -6.8460502249184003, 8.0, -6.8523225166971358, 6.0, -7.3811261267682884, 1.0, -8.1248547762653516, 3.0, -9.7831398425691418, 2.0, -11.96115838770644, 5.0, -38.91000035405159)

print queryImgID(1,7,9)
(6.0, -4.0120659777273113, 5.0, -6.8460502249184003, 1.0, -7.5921484994136454, 9.0, -8.6838044103783858, 2.0, -9.3101353053709026, 3.0, -9.5282856254401516, 8.0, -9.8236064434255965, 4.0, -9.8542157684696541, 7.0, -36.700000464916229)

Using relative comparisons, the conclusions I can draw are :
- As sim(9,5)>sim(4,5)>sim(7,5)>sim(8,5)>etc,  img9 is more similar to img5 than img4 is, img4 is in turn more similar to img5  than img7 etc.
- Similarly sim(6,7)>sim(5,7)>sim(1,7)>sim(9,7)>etc., img6 is more similar to img7 than img5 is, img5 is in turn more similar to img7 than img1 is etc.

However, can I make aboslute comparisons as well :
- Since sim(9,5)>sim(6,7), is img9 more similar to img5 than img6 is similar to img7 ?

- More generally does sim(x,y)>sim(z,t) imply that x more similar to y than z is similar to t ?

I don't think so.


Following this idea of absolute comparison, I have noticed that sim(x,y) can take positive values (ike sim(9,5)). What is the range of sim(x,y) ?

You could derive the range either empirically, or by looking at equation 3 on the original paper.



It seems that sim(x,y) has been defined so that sim(x,y)>sim(x,x) for each images x and y. However, we dont have sim(x,x) = sim(y,y) for each images x and y - for instance sim(7,7)>sim(5,5). That is why I am not so sure that I can make aboslute comparisons like the one above.

Thank you again for your help !

Louis


Reply all
Reply to author
Forward
0 new messages