liuliu / ccv

C-based/Cached/Core Computer Vision Library, A Modern Computer Vision Library
http://libccv.org
Other
7.06k stars 1.72k forks source link

Strange behavior: different results using http api between linux / mac #137

Open benjamin79 opened 9 years ago

benjamin79 commented 9 years ago
var request = require('request');
     var formData = {
             source: fs.createReadStream( dir + filename),
             model: 'face'
           };

           request.post({
               url:'http://localhost:3350/scd/detect.objects',
               formData: formData
             }, function (err, httpResponse, body) {
               if (err) {
                 return console.error('failed:', err);
               } ...

Mac + api on localhost -> works, correct results Mac + api on ec2 server (ubuntu) -> works, but different results. I can see the right one, but an white area gets a higher confidence score. (not specific to an image)

ubuntu ec2 + api on localhost -> same result as above.

The strange thing is, if i use the terminal and use the api directly with curl i get the correct results on both machines.

Can the results somehow differ with a different cpu?

Any idea?

liuliu commented 9 years ago

I wouldn't entertain the idea that these differences due to CPU. Can you share your full script to call the service, as well as a test image so that I can investigate more.

benjamin79 commented 9 years ago

I have sent an email to i@liului.me . Is this the right one?

liuliu commented 9 years ago

I received your email. One thing to note is that libpng has different versions on Mac and Ubuntu, and will produce different decoded images as the result. That could affect the result. libjpeg from my experience is consistent in producing decoded images cross platforms.

benjamin79 commented 9 years ago

I´ve change to jpg. But still, i get different / wrong results with the online version. I even change to exec the scddetect directly - same.

The wrong one detects over 100 matches in an image like the one i sent you. Mostly just white (real white) or some small letters.

I´m far away from the knowledge you have to debug this. Can i do anything more to help you?

benjamin79 commented 9 years ago

I understand if you have other things to do, but please tell me if you will look into this. So i know how to proceed.

thank you.

liuliu commented 9 years ago

Will let you know if I don't have time to reprod tonight. Was pretty occupied these days.

liuliu commented 9 years ago

I cannot reprod your problem on my Mac Mini / Ubuntu, here is the output:

liu@liu-sz77:~/Dropbox/workspace/ccv/bin$ ./scddetect ~/input2.png ../samples/face.sqlite3
369 145 192 192 5.001075
total : 1 in time 344ms

Liu-Lius-Mac-mini:bin liuliu$ ./scddetect ~/input2.png ../samples/face.sqlite3
369 145 192 192 5.001075
total : 1 in time 977ms

Do note that I rescaled your original file to 800x566 because original is too big to generate meaningful output (too much false negatives). If you continue encounter this issue, please note following:

1) Make sure your libpng is installed correctly, an easy way to confirm that is to run cd test/ && make test

2) You may try to rescale the input to something more reasonable with Imagemagick, libccv's HTTP interface rescales input to maximum 800x800 (respect aspect ratio), the rescale method may be platform dependent.

Let me know if you have further questions.