#define GLUT_DISABLE_ATEXIT_HACK // Needed to compile with Mingw?
#include <GL/gl.h>
    unsigned char hidingtex[64*64*4];
        glPushMatrix();
        glMultMatrixd(gl_mat);
        
        glPushAttrib(GL_ALL_ATTRIB_BITS);
        glEnable(GL_TEXTURE_2D);
        int tex=0;
        glBindTexture(GL_TEXTURE_2D, tex);
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
        glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,64,64,0,GL_RGBA,GL_UNSIGNED_BYTE,hidingtex);
        glDisable(GL_CULL_FACE);
        glDisable(GL_LIGHTING);
        glDisable(GL_DEPTH_TEST);
        glEnable(GL_ALPHA_TEST);
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glBegin(GL_QUADS);
            glTexCoord2d(0.0,0.0);
            glTexCoord2d(0.0,1.0);
            glTexCoord2d(1.0,1.0);
            glTexCoord2d(1.0,0.0);
        glEnd();
        glPopAttrib();
        glPopMatrix();
    }
};
{
    static IplImage *hide_texture;
    bool flip_image = (image->origin?true:false);
    if (flip_image) {
        cvFlip(image);
        image->origin = !image->origin;
    }
    static IplImage* bg_image = 0;
    if(!bg_image) bg_image = cvCreateImage(cvSize(512, 512), 8, 3);
    if(image->nChannels == 3)
    {
        bg_image->origin = 0;
        cvResize(image, bg_image);
    }
    if (init) {
        init = false;
            cout<<" [Ok]"<<endl;
        } else {
            cam.
SetRes(image->width, image->height);
            cout<<" [Fail]"<<endl;
        }
        double p[16];
    }
    for (
size_t i=0; i<marker_detector.
markers->size(); i++) {
         if (i >= 32) break;
    }
    for (
size_t i=0; i<marker_detector.
markers->size(); i++) {
         if (i >= 32) break;
        
        
        
        
        
        
        
        for (int ii=0; ii<64*64; ii++) {
            d[i].
hidingtex[ii*4+0] = hide_texture->imageData[ii*4+2];
            d[i].
hidingtex[ii*4+1] = hide_texture->imageData[ii*4+1];
            d[i].
hidingtex[ii*4+2] = hide_texture->imageData[ii*4+0];
            d[i].
hidingtex[ii*4+3] = hide_texture->imageData[ii*4+3];
        }
    }
    if (flip_image) {
        cvFlip(image);
        image->origin = !image->origin;
    }
}
int main(
int argc, 
char *argv[])
 {
    try {
        
        filename = filename.substr(filename.find_last_of('\\') + 1);
        std::cout << "SampleMarkerHide" << std::endl;
        std::cout << "================" << std::endl;
        std::cout << std::endl;
        std::cout << "Description:" << std::endl;
        std::cout << "  This is an example of how to detect 'MarkerData' markers, similarly" << std::endl;
        std::cout << "  to 'SampleMarkerDetector', and hide them using the 'BuildHideTexture'" << std::endl;
        std::cout << "  and 'DrawTexture' classes." << std::endl;
        std::cout << std::endl;
        std::cout << "Usage:" << std::endl;
        std::cout << "  " << filename << " [device]" << std::endl;
        std::cout << std::endl;
        std::cout << "    device    integer selecting device from enumeration list (default 0)" << std::endl;
        std::cout << "              highgui capture devices are prefered" << std::endl;
        std::cout << std::endl;
        std::cout << "Keyboard Shortcuts:" << std::endl;
        std::cout << "  q: quit" << std::endl;
        std::cout << std::endl;
        
        
        if (plugins.size() < 1) {
            std::cout << "Could not find any capture plugins." << std::endl;
            return 0;
        }
        
        std::cout << "Available Plugins: ";
        std::cout << std::endl;
        
        if (devices.size() < 1) {
            std::cout << "Could not find any capture devices." << std::endl;
            return 0;
        }
        
        if (argc > 1) {
            selectedDevice = atoi(argv[1]);
        }
        if (selectedDevice >= (int)devices.size()) {
        }
        
        
        std::cout << "Enumerated Capture Devices:" << std::endl;
        std::cout << std::endl;
        
        
        std::string uniqueName = devices[selectedDevice].uniqueName();
        
        
        if (cap) {
            std::stringstream settingsFilename;
            settingsFilename << "camera_settings_" << uniqueName << ".xml";
            
            
                std::cout << "Loading settings: " << settingsFilename.str() << std::endl;
            }
            std::stringstream title;
                std::cout << "Saving settings: " << settingsFilename.str() << std::endl;
            }
            delete cap;
        }
        }
        else {
            std::cout << "Could not initialize the selected capture backend." << std::endl;
        }
        return 0;
    }
    catch (const std::exception &e) {
        std::cout << "Exception: " << e.what() << endl;
    }
    catch (...) {
        std::cout << "Exception: unknown" << std::endl;
    }
}