Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find duplicate pictures
#1
How can I find duplicate pictures like http://www.gotdupes.com/index.cfm?page= ... me=d%60peg in QM?
#2
I have a function to compare equal icons. Used it to remove duplicated icons extracted from all files in PC. Can create for bmp, gif and jpg, if you need, when will have time. With other formats can be problems.
#3
It would be fantastic.

I was also thinking of removing duplicated files.
#4
My algorithm would be:

Get list of files (foreach...FE_Dir),
load each (_s.getfile),
get CRC (Crc32),
store CRC/path pairs into an array or map,
find all equal CRC.

It would find any identical files.
#5
I was looking for something like http://www.autoitscript.com/forum/index ... opic=66545
#6
Not sure but it looks like scan in QM.
#7
How can I find BMP in another BMP using QM?
#8
Display bitmap1 in dialog.
Load bitmap2 using LoadPictureFile. Don't forget to DeleteObject later.
Use scan to find bitmap2 (handle) in the dialog.

Dialog is needed because scan can take bitmap1 from screen but cannot take from file or memory.
#9
Is possible to modify scan to works from file or memory?
#10
Possible.
#11
Is possible in a new QM version?
#12
Forgot it, sorry. Will add in QM 2.3.2.
#13
Do you have an estimated time?
#14
Don't have. But I reviewed scan code and decided to not add this feature. Would need more work than I thought, and would be rarely used.
#15
Then can you convert this function: http://www.codeproject.com/KB/graphics/ ... ector.aspx to use with QM?
#16
You can download free Visual Studio Express edition and try to create COM dll from the codeproject code. Then use the dll in QM.

How to export and use C# functions in QM?
#17
Thanks.

Is not possible transform the code:?

Code:
Copy      Help
private Rectangle searchBitmap(Bitmap smallBmp, Bitmap bigBmp, double tolerance)
{
    BitmapData smallData =
      smallBmp.LockBits(new Rectangle(0, 0, smallBmp.Width, smallBmp.Height),
               System.Drawing.Imaging.ImageLockMode.ReadOnly,
               System.Drawing.Imaging.PixelFormat.Format24bppRgb);
    BitmapData bigData =
      bigBmp.LockBits(new Rectangle(0, 0, bigBmp.Width, bigBmp.Height),
               System.Drawing.Imaging.ImageLockMode.ReadOnly,
               System.Drawing.Imaging.PixelFormat.Format24bppRgb);

    int smallStride = smallData.Stride;
    int bigStride = bigData.Stride;

    int bigWidth = bigBmp.Width;
    int bigHeight = bigBmp.Height;
    int smallWidth = smallBmp.Width * 3;
    int smallHeight = smallBmp.Height;

    Rectangle location = Rectangle.Empty;
    int margin = Convert.ToInt32(255.0 * tolerance);

    unsafe
    {
        byte* pSmall = (byte*)(void*)smallData.Scan0;
        byte* pBig = (byte*)(void*)bigData.Scan0;

        int smallOffset = smallStride - smallBmp.Width * 3;
        int bigOffset = bigStride - bigBmp.Width * 3;

        bool matchFound = true;

        for (int y = 0; y < bigHeight; y++)
        {
            for (int x = 0; x < bigWidth; x++)
            {
                byte* pBigBackup = pBig;
                byte* pSmallBackup = pSmall;

                //Look for the small picture.
                for (int i = 0; i < smallHeight; i++)
                {
                    int j = 0;
                    matchFound = true;
                    for (j = 0; j < smallWidth; j++)
                    {
                        //With tolerance: pSmall value should be between margins.
                        int inf = pBig[0] - margin;
                        int sup = pBig[0] + margin;
                        if (sup < pSmall[0] || inf > pSmall[0])
                        {
                            matchFound = false;
                            break;
                        }

                        pBig++;
                        pSmall++;
                    }

                    if (!matchFound) break;

                    //We restore the pointers.
                    pSmall = pSmallBackup;
                    pBig = pBigBackup;

                    //Next rows of the small and big pictures.
                    pSmall += (smallWidth + smallOffset) * (1 + i);
                    pBig += (bigWidth * 3 + bigOffset) * (1 + i);
                }

                //If match found, we return.
                if (matchFound)
                {
                    location.X = x;
                    location.Y = y;
                    location.Width = smallBmp.Width;
                    location.Height = smallBmp.Height;
                    break;
                }
                //If no match found, we restore the pointers and continue.
                else
                {
                    pBig = pBigBackup;
                    pSmall = pSmallBackup;
                    pBig += 3;
                }
            }

            if (matchFound) break;

            pBig += bigOffset;
        }
    }

    bigBmp.UnlockBits(bigData);
    smallBmp.UnlockBits(smallData);

    return location;
}
#18
Not possible. Also, in QM it would be too slow.
#19
Why in QM it would be too slow?
#20
QM code runs much slower than native code.
#21
Thanks again. I thought that like scan is so quick...
#22
I tried

Macro Macro7
Code:
Copy      Help
RegisterNetComComponent "$Desktop$\BitmapDetector.dll"
IDispatch d._create("BitmapDetector.BitmapDetectorForm")
double c=0
BITMAP a b
RECT r=d.searchBitmap(a b c)

but

Error in Macro7: unsupported argument type.

What's wrong, how load image in BITMAP variable?
#23
Give the dll file paths. Let dll itself create Bitmap variables and load the files.
#24
Can you show me an example?
#25
Maybe in codeproject (in the same article) is a demo program with source code. I don't work with C# and don't know what Bitmap method loads a file.
#26
Is possible add this function (find BMP in another BMP) with the features of new QM?
#27
If you'll find C source code for it, compile it with __Tcc class.
Now I'm working with scan. Need to make it work better with icons on Win7 etc. Maybe also add searching in background windows and memory bitmaps.
#28
Will you add it in the next version of QM?
#29
Already added. Wait for QM 2.3.2.2.
#30
Thank you.


Forum Jump:


Users browsing this thread: 2 Guest(s)