12/09/2018

Table(grid) detector


Table(grid) detector source code.
The code find table row & col lines in document image.

Output




Table(Grid) Detector
buy : https://www.cvlecture.marearts.com/product-page/table-grid-detector
test : http://www.marearts.com/webapp/dtable/
github : https://github.com/MareArts/DTable

Usage source code
#include "DTable.h"

//for local computer
void main()
{

    CDTable cDT;

    //test image
    char str[255];
    for (int i = 0; i < 10; ++i)
    {
        
        //make file string
        sprintf_s(str, "%d.jpg", i + 1);
        printf("%s open \n", str);

        //read
        Mat oimg = imread(str);

        //check
        if (oimg.empty())
            continue;

        //get rect vector
        vector< GridV> vRect;
        //dtable
        if (cDT.FindGrid(oimg, vRect, 0, 0) == false)
        {
            printf("Couldn't Find \n");
            break;
        }


        //show table
        namedWindow("oimg", 0);
        int idx = 0;
        for (auto it : vRect)
        {

            printf("%d grid :  (x:%d, y:%d, width:%d, height:%d \n", idx, it.rect.x, it.rect.y, it.rect.width, it.rect.height);

            if (it.pure)
                cv::rectangle(oimg, it.rect, CV_RGB(0, 255, 0), 2);
            else
                cv::rectangle(oimg, it.rect, CV_RGB(255, 0, 0), 2);

            idx++;
        }

        vRect.clear();

        //exit
        imshow("oimg", oimg);
        if (waitKey(0) == 'q')
        {
            break;
        }
    }

    destroyAllWindows();
    
}

No comments:

Post a Comment