Radzhab / tesseractdotnet

Automatically exported from code.google.com/p/tesseractdotnet
0 stars 0 forks source link

DLL in Release Configuration #11

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?
To be able to build the .dll in Release mode.

What version of the product are you using? On what operating system?
r48; Win7 64-bit

Please provide any additional information below.
The .dll is built fine in Debug mode; however, when the Solution/Project is 
switched to Release mode, no .dll is generated.

Original issue reported on code.google.com by nguyen...@gmail.com on 17 Jul 2011 at 1:31

GoogleCodeExporter commented 8 years ago
There are two project configurations you have to focus:

- configure to _BUILASDLL (preprocessor) in ccmain project => enables to load 
tessdata

- check the output in linker to find out output assembly in tesseract project. 
If you succeed to compile, you should find out it.

Additions:
Here are three functions I have just added to PixConverter class if you intend 
to load image from buffer directly:

class PixConverter
{
public:
    static Pix* CreateBinaryPix(unsigned char* binData, int width, int height)
    {
        Pix* pix = NULL;
        try
        {       
            pix = pixCreate(width, height, 1);

            l_uint32* pixData = pixGetData(pix);
            int wpl = pixGetWpl(pix);
            l_uint32 wtmp = 0;
            int index = 0;
            for (int y=0; y<height; y++)
            {
                wtmp = 0;
                int startLineWIndex = y * wpl;

                int bitIndex = 0;
                for (int x = 0; x < width; x++, index++)
                {
                    if (bitIndex == 32)
                    {
                        pixData[startLineWIndex + ((x - 1) >> 5)] = wtmp;
                        bitIndex = 0;
                        wtmp = 0;
                    }

                    wtmp = wtmp | (binData[index] << (31 - bitIndex));

                    bitIndex++;
                }

                if (bitIndex > 0)
                {
                    pixData[startLineWIndex + (width - 1) >> 5] = wtmp;
                }
            }
        }
        catch (Exception* exp)
        {
            throw exp;
        }
        __finally
        {           
        }

        return pix;
    }

    static Pix* CreateGreyPix(unsigned char* greyData, int width, int height)
    {
        Pix* pix = NULL;
        try
        {       
            pix = pixCreate(width, height, 8);

            l_uint32* pixData = pixGetData(pix);
            int wpl = pixGetWpl(pix);
            l_uint32 wtmp = 0;
            int index = 0;
            for (int y=0; y<height; y++)
            {
                unsigned char* line = (unsigned char*)(pixData + y * wpl);
                for (int x = 0; x < width; x++, index++)
                {
                    line[x] = greyData[index];
                }
            }
        }
        catch (Exception* exp)
        {
            throw exp;
        }
        __finally
        {           
        }

        return pix;
    }

    static Pix* CreateGreyPix(ushort* greyData, int width, int height)
    {
        Pix* pix = NULL;
        try
        {       
            pix = pixCreate(width, height, 8);

            l_uint32* pixData = pixGetData(pix);
            int wpl = pixGetWpl(pix);
            l_uint32 wtmp = 0;
            int index = 0;
            for (int y=0; y<height; y++)
            {
                unsigned char* line = (unsigned char*)(pixData + y * wpl);
                for (int x = 0; x < width; x++, index++)
                {
                    line[x] = (unsigned char)greyData[index];
                }
            }
        }
        catch (Exception* exp)
        {
            throw exp;
        }
        __finally
        {           
        }

        return pix;
    }

    static Pix* PixFromImage(System::Drawing::Image* image)
    {
        Pix* pix = NULL;

        MemoryStream* mmsTmp = NULL;
        unsigned char srcTmp __gc[] = NULL;
        unsigned char* dstTmp = NULL;

        try
        {       
            /**
            Use memeory stream is easy solution, but poor effective.
            **/
            mmsTmp = new MemoryStream();
            image->Save(mmsTmp, System::Drawing::Imaging::ImageFormat::Tiff);

            int length = mmsTmp->Length;

            srcTmp = mmsTmp->GetBuffer();
            dstTmp = new unsigned char[length];
            System::Runtime::InteropServices::Marshal::Copy(srcTmp, 0, dstTmp, length);

            pix = pixReadMem(dstTmp, length);       
        }
        catch (Exception* exp)
        {
            throw exp;
        }
        __finally
        {
            if (mmsTmp != NULL)
            {
                mmsTmp->Close();
                mmsTmp = NULL;
            }

            if (srcTmp != NULL)
            {
                delete srcTmp;
                srcTmp = NULL;
            }

            if (dstTmp != NULL)
            {
                delete dstTmp;
                dstTmp = NULL;
            }
        }

        return pix;
    }
};

Original comment by congnguy...@gmail.com on 18 Jul 2011 at 1:31

GoogleCodeExporter commented 8 years ago
Thanks. It'd be great if the source in SVN is updated with all this useful 
information.

Original comment by nguyen...@gmail.com on 22 Jul 2011 at 12:48