mirror of
https://github.com/opencv/opencv.git
synced 2024-12-26 18:58:16 +08:00
d86d8ed909
PR #2968:cce2d99
8578f9c
Fixed bug which caused crash of GPU version of feature matcher in stitcher The bug caused crash of GPU version of feature matcher in stitcher when we use ORB features. PR #3236:5947519
Check sure that we're not already below required leaf false alarm rate before continuing to get negative samples. PR #3190 fix blobdetector PR #3562 (part):82bd82e
TBB updated to 4.3u2. Fix for aarch64 support. PR #3604 (part):091c7a3
OpenGL interop sample reworked not ot use cvconfig.h PR #3792:afdf319
Add -L for CUDA libs path to pkg-config Add all dirs from CUDA_LIBS_PATH as -L linker options to OPENCV_LINKER_LIBS. These will end up in opencv.pc. PR #3893:122b9f8
Turn ocv_convert_to_lib_name into a function PR #5490:ec5244a
fixed memory leak in findHomography tests PR #5491:0d5b739
delete video readers PR #5574 PR #5202
118 lines
2.4 KiB
C++
118 lines
2.4 KiB
C++
#include <iostream>
|
|
|
|
#ifdef WIN32
|
|
#define WIN32_LEAN_AND_MEAN 1
|
|
#define NOMINMAX 1
|
|
#include <windows.h>
|
|
#endif
|
|
#if defined(_WIN64)
|
|
#include <windows.h>
|
|
#endif
|
|
|
|
#if defined(__APPLE__)
|
|
#include <OpenGL/gl.h>
|
|
#include <OpenGL/glu.h>
|
|
#else
|
|
#include <GL/gl.h>
|
|
#include <GL/glu.h>
|
|
#endif
|
|
|
|
#include "opencv2/core/core.hpp"
|
|
#include "opencv2/core/opengl.hpp"
|
|
#include "opencv2/core/cuda.hpp"
|
|
#include "opencv2/highgui/highgui.hpp"
|
|
|
|
using namespace std;
|
|
using namespace cv;
|
|
using namespace cv::cuda;
|
|
|
|
const int win_width = 800;
|
|
const int win_height = 640;
|
|
|
|
struct DrawData
|
|
{
|
|
ogl::Arrays arr;
|
|
ogl::Texture2D tex;
|
|
ogl::Buffer indices;
|
|
};
|
|
|
|
void draw(void* userdata);
|
|
|
|
void draw(void* userdata)
|
|
{
|
|
DrawData* data = static_cast<DrawData*>(userdata);
|
|
|
|
glRotated(0.6, 0, 1, 0);
|
|
|
|
ogl::render(data->arr, data->indices, ogl::TRIANGLES);
|
|
}
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
string filename;
|
|
if (argc < 2)
|
|
{
|
|
cout << "Usage: " << argv[0] << " image" << endl;
|
|
filename = "../data/lena.jpg";
|
|
}
|
|
else
|
|
filename = argv[1];
|
|
|
|
Mat img = imread(filename);
|
|
if (img.empty())
|
|
{
|
|
cerr << "Can't open image " << filename << endl;
|
|
return -1;
|
|
}
|
|
|
|
namedWindow("OpenGL", WINDOW_OPENGL);
|
|
resizeWindow("OpenGL", win_width, win_height);
|
|
|
|
Mat_<Vec2f> vertex(1, 4);
|
|
vertex << Vec2f(-1, 1), Vec2f(-1, -1), Vec2f(1, -1), Vec2f(1, 1);
|
|
|
|
Mat_<Vec2f> texCoords(1, 4);
|
|
texCoords << Vec2f(0, 0), Vec2f(0, 1), Vec2f(1, 1), Vec2f(1, 0);
|
|
|
|
Mat_<int> indices(1, 6);
|
|
indices << 0, 1, 2, 2, 3, 0;
|
|
|
|
DrawData data;
|
|
|
|
data.arr.setVertexArray(vertex);
|
|
data.arr.setTexCoordArray(texCoords);
|
|
data.indices.copyFrom(indices);
|
|
data.tex.copyFrom(img);
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
glLoadIdentity();
|
|
gluPerspective(45.0, (double)win_width / win_height, 0.1, 100.0);
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
glLoadIdentity();
|
|
gluLookAt(0, 0, 3, 0, 0, 0, 0, 1, 0);
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
|
data.tex.bind();
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
setOpenGlDrawCallback("OpenGL", draw, &data);
|
|
|
|
for (;;)
|
|
{
|
|
updateWindow("OpenGL");
|
|
int key = waitKey(40);
|
|
if ((key & 0xff) == 27)
|
|
break;
|
|
}
|
|
|
|
setOpenGlDrawCallback("OpenGL", 0, 0);
|
|
destroyAllWindows();
|
|
|
|
return 0;
|
|
}
|