Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where or how can I run ./imgscoutclient -h #1

Open
Luxcium opened this issue Feb 1, 2022 · 11 comments
Open

Where or how can I run ./imgscoutclient -h #1

Luxcium opened this issue Feb 1, 2022 · 11 comments

Comments

@Luxcium
Copy link

Luxcium commented Feb 1, 2022

I do not know how to do that... Maybe some steps are missing or should be implied (by me but I don't know)...

 Use the imgscoutclient utility to add or query the image files in a given directory. Run ./imgscoutclient -h for all the options. After adding files, be sure to run ./imgscoutclient --cmd sync --key mykey to add the recent additions to the index structure.

@Luxcium
Copy link
Author

Luxcium commented Feb 1, 2022

I must admit that I probably am missing the required background knowledge but I have the impression the documentation makes assumptions on my knowledge that are not described... To be fair I am maybe guilty of having myself some assumptions about the documentation... Where or How can I get help... I am able to run the code in the container and I understand most of the commands but not enough to use the module in development or in discovery mode [Testing the functionalities]...

@Luxcium
Copy link
Author

Luxcium commented Feb 1, 2022

I am also unable to build it outside of the container because those error messages:

When (cmake . && make && make install) >|out.txt 2>&1 in bmbhash.cpp « BMBHash » is not declared.

@starkdg
Copy link
Owner

starkdg commented Feb 3, 2022

Hi,

The imgscoutclient program depends on the phash library phash to create image fingerprints of the images. I'm sorry, I guess I forgot to list that in the README.md.

When you run the redis server, it's easiest to just run it in a docker container. Then build the client program with cmake.

Hope this helps. Let me know if there's any other issues.

Correction: cmake will automatically download the phash from github. You just need the following:

Boost v1.67
libpng-dev
libtiff-dev
libjpeg-dev

Be sure those are the dev packages, as they will contain the header files necessary for compilation.

@Luxcium
Copy link
Author

Luxcium commented Feb 4, 2022

I'm sorry, I guess I forgot to list that in the README.md.

That part is well explained in the README I am using the docker container and it is working but I do not know how to use it I am reading about MVP and I still do not know how to use the « database » (or dataset)...

I will not try to use the «Client Demo Program» as I do not know what is missing to make it compile outside of the Docker...

I have:

Name Version
 Boost.x86_64   v1.75.0-4.fc34
 libpng-devel.x86_64   v2:1.6.37-10.fc34
 libtiff-devel.x86_64   v4.2.0-1.fc34
 libtiff-devel.x86_64   v4.2.0-1.fc34

@Luxcium
Copy link
Author

Luxcium commented Feb 4, 2022

Also, I am unable to understand how to use imgscout.query key target-hash radius
I get my hashes for each image then I (am not sure) ... I need to imgscout.add key hashvalue title [id] so I understand what is the hash I am unsure what is the key (the same key for all the hashes and the title is to know that image it is related to? I am pretty confused I have been trying different scenarios and I am unable to understand...

@starkdg
Copy link
Owner

starkdg commented Feb 4, 2022

The key is just the redis key to the native data strucdture that stores the hashvalues for the images. Just pick one, like "images". It will be the same for all commands, assuming you don't want to have separate index structures. But, for now, all your images will be under that one key.

To use without imgscout client program, you need to calculate the image hash separately. It uses the dct image hash, which is a 64-bit hash integer value (uint64_t). Just add it to redis like this:

imgscout.add images hashvalue title-string

(Replace hashvalue with the your dct hash and with a name for the image, like file path. The [id] on the end is optional. If left off, it will automatically generate an id value. )

Same for query:

imgscout.query images target-hashvalue radius

(Replace target-hashvalue with the dct hashvalue for you target image and radius with your tolerance, like 10)

However, it's really rather cumbersome to insert images by hand like that, since you won't be able to fully test it. (I just explained it to give you a better sense of how it works.)

The imgscout client program can iterate through all the image files in a directory and submit each one for you. Just run imgscout -h to find out about the options to pass in. You can also submit queries using the images in a directory as target images.

It looks like you have all the dependencies, so it should compile. I noticed you are storing everything in your HOME directory in
~/.local so it probably can't find the libraries. Did you try installing it in your regular system libraries instead? You can also try setting your LD_LIBRARY_PATH environment variable to the locations of those libraries.

@Luxcium
Copy link
Author

Luxcium commented Feb 5, 2022

Ha ok the id optimal as is it not "required to be provided" but is not optional in the sense that no id will then exist... That was one of the confusing things in my attempt to figure out the puzzle...

Ok I am already generating my hashes and I have learned yesterday about that « Cosine thing » which apparently is something that everyone should be aware of but haha I wish I could go back to university...

So I have a key which is for all the images of that MVP universe and I am generating a string of 64 zeros or ones and I have a tag 🏷 to know what it relates to then the optional id is provided by an unspecified magic 🪄 so that is probably half of the process which was already working I am just learning now.

Any radius I have chosen gives me a similar output so I will need to make sure I understand all what you explained me (which quite honestly is already exactly what I was doing so I am unsure what exactly I need to understand)...

I am already iterating my folder and I am using JavaScript (for the better or the worse)... using await in a for loop was such a drag and instead I am now awaiting at the end it gives me a little more parallelism (in a general manner of speaking) and gave me the same indexing from 2 minutes down to 26 seconds... for 2800 files (I assume I can't outperform pure C but it's for the moment what it is)... I am doing it to learn not to perform and I will probably need to find some rust implementation as I am unable to write C++ code so sadly...

@Luxcium
Copy link
Author

Luxcium commented Feb 5, 2022

I am unable to set the output in English (cmake/make error messages) no matter what I am trying to do

    LANG=en_CA.UTF-8 
    LC_CTYPE="en_CA.UTF-8" 
    LC_NUMERIC="en_CA.UTF-8"
    LC_TIME="en_CA.UTF-8" 
    LC_COLLATE="en_CA.UTF-8" 
    LC_MONETARY="en_CA.UTF-8" 
    LC_MESSAGES="en_CA.UTF-8" 
    LC_ALL=

is there a way you could figure out what the error messages are talking about or should I try harder to find a solution to get the output in English (googling the word language in that context is not of any help even if using locale) ???

@Luxcium
Copy link
Author

Luxcium commented Feb 5, 2022

Error: « BMBHash » not declared in this scope

@starkdg
Copy link
Owner

starkdg commented Feb 5, 2022

I see you're trying to do a lot here. Let me take it one at a time here:

  • the id is optional. If you don't provide it on the command line, it will automatically assign an id. If the server successfully inserts the new hashes, it will return the id. You should see it on the command line. Id values are not sequential, but somewhat random.

  • For the dct image hash, use a radius of around 10. If all the images you indexed are unique images, you probably won't get too interesting results. However, you should get back the original images if you query that image. The reason is that dct image hash retains a very rough notion of "similarity". It will find duplicates and a few distortions, but not much more than that. You need to insert a few distorted images and re-insert them into the index. Then try querying the original image and you should get back the id's of the distortions. Distortions like blurr, noise, etc.

-Not really sure what you are doing with javascript. Are you able to call the phash library from javascript? That's a good sign, because at least we know the phash library is built and you are able to call it. When you send the hashes to the redis server, does it return an id number for each image?

Error: « BMBHash » not declared in this scope

-It doesn't use the BMBHash, but this indicates the phash library is not getting compiled. (I assume you were able to compile phash library separately, since you were able to call it from javascript.) What system are you using? I'm on Debian/Linux.

There's clearly a lot going on here. What messaging services are you on? You can find me on telegram @starkdg or on keybase (user: starkdg). We can probably communicate better over there.

@Luxcium
Copy link
Author

Luxcium commented Feb 7, 2022

after doing:

sudo dnf install 'boost-*'
sudo dnf reinstall '*boost*'

and after doing a cd into the phash src and doing cmake/make in that folder first...

The new error message is now:

❯ make
[  4%] Performing update step for 'phash'
HEAD est maintenant sur 1386cec change CMakelists.txt file to install headers from build directory
Déjà à jour.
[  9%] No patch step for 'phash'
[ 13%] Performing configure step for 'phash'
-- Using Image Hash
-- phash library sources: src/pHash.cppsrc/bmbhash.cpp
-- phash library deps: /usr/lib64/libpng.so/usr/lib64/libjpeg.so/usr/lib64/libtiff.so
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/src/Redis-ImageScout/phash/src/phash
[ 18%] Performing build step for 'phash'
Consolidate compiler generated dependencies of target pHash
[  7%] Building CXX object CMakeFiles/pHash.dir/src/bmbhash.cpp.o
[ 15%] Linking CXX shared library libpHash.so
[ 23%] Built target pHash
[ 30%] Building CXX object CMakeFiles/Testrh.dir/tests/radial-imagehash-test.cpp.o
[ 38%] Linking CXX executable Testrh
/usr/bin/ld : CMakeFiles/Testrh.dir/tests/radial-imagehash-test.cpp.o : dans la fonction « main » :
/usr/src/Redis-ImageScout/phash/src/phash/tests/radial-imagehash-test.cpp:22 : référence indéfinie vers « ph_image_digest »
/usr/bin/ld : /usr/src/Redis-ImageScout/phash/src/phash/tests/radial-imagehash-test.cpp:26 : référence indéfinie vers « ph_image_digest »
/usr/bin/ld : /usr/src/Redis-ImageScout/phash/src/phash/tests/radial-imagehash-test.cpp:30 : référence indéfinie vers « ph_peakcrosscorr »
/usr/bin/ld : libpHash.so.1.0.0 : référence indéfinie vers « ph_hammingdistance2 »
collect2: erreur: ld a retourné le statut de sortie 1
make[5]: *** [CMakeFiles/Testrh.dir/build.make:101 : Testrh] Erreur 1
make[4]: *** [CMakeFiles/Makefile2:93 : CMakeFiles/Testrh.dir/all] Erreur 2
make[3]: *** [Makefile:146 : all] Erreur 2
make[2]: *** [CMakeFiles/phash.dir/build.make:86 : phash/src/phash-stamp/phash-build] Erreur 2
make[1]: *** [CMakeFiles/Makefile2:142 : CMakeFiles/phash.dir/all] Erreur 2
make: *** [Makefile:136 : all] Erreur 2

CMakeFiles/Testrh.dir/tests/radial-imagehash-test.cpp.o : In the fonction « main » :
In file: /usr/src/Redis-ImageScout/phash/src/phash/tests/radial-imagehash-test.cpp

Indefinite reference to:
« ph_image_digest »
« ph_image_digest »
« ph_peakcrosscorr »

In: libpHash.so.1.0.0

Indefinite reference to:
« ph_hammingdistance2 »

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants