{"id":6875,"date":"2015-03-01T18:27:58","date_gmt":"2015-03-01T23:27:58","guid":{"rendered":"httpss:\/\/www.powenko.com\/wordpress\/?p=6875"},"modified":"2015-03-02T11:38:22","modified_gmt":"2015-03-02T16:38:22","slug":"09-%e9%80%8f%e9%81%8e-opengl-%e9%a1%af%e7%a4%baopencv-%e5%8a%a0%e5%bf%ab%e9%a1%af%e7%a4%ba%e9%80%9f%e5%ba%a6%ef%bc%8c%e4%b8%a6%e5%8a%a0%e4%b8%8a%e8%ad%89%e5%88%b8%e9%a1%8f%e8%89%b2%e6%9d%90%e8%b3%aa","status":"publish","type":"post","link":"https:\/\/www.powenko.com\/wordpress\/?p=6875","title":{"rendered":"09 \u900f\u904e OPENGL \u986f\u793aOPENCV \u52a0\u5feb\u986f\u793a\u901f\u5ea6\uff0c\u00a0\u5728\u7403\u9ad4\u4e0a\u986f\u793a\u6b63\u78ba\u984f\u8272\u6750\u8cea\u8cbc\u5716"},"content":{"rendered":"<h1>\u76ee\u7684\uff1a<\/h1>\n<pre>\u900f\u904e OPENGL \u986f\u793aOPENCV \u52a0\u5feb\u986f\u793a\u901f\u5ea6\uff0c\u4e26\u52a0\u4e0a\u8b49\u5238\u984f\u8272\u6750\u8cea\u8cbc\u5716\uff0c\u986f\u793a\u5728\u7403\u4e0a<\/pre>\n<h2>\u51fd\u6578\u4ecb\u7d39\uff1a<\/h2>\n<pre><\/pre>\n<h2>\u53c3\u6578\u503c\uff1a<\/h2>\n<h2>\u4f7f\u7528\u7bc4\u4f8b\uff1a<\/h2>\n<p>sample14-2_OpenGL-\u8cbc\u5716RGB<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\/* www.powenko.com\r\n Author: Powen Ko\r\n\r\n $ g++   main.cpp -o main -I\/opt\/local\/include -L\/opt\/local\/lib -lopencv_core.2.4.10 -lopencv_highgui.2.4.10 -framework GLUT -framework OpenGL -Wno-deprecated-declarations `pkg-config --cflags --libs opencv`\r\n\r\n *\/\r\n#include &lt;opencv2\/core\/core.hpp&gt;\r\n#include &lt;opencv2\/highgui\/highgui.hpp&gt;\r\n#include &lt;opencv2\/opencv.hpp&gt;\r\n#include &lt;iostream&gt;\r\n#include &lt;string.h&gt;\r\n#include &lt;fstream&gt;\r\n\r\n#include &lt;stdio.h&gt;\r\n#include &lt;opencv\/highgui.h&gt;\r\n#ifdef __APPLE__\r\n#include &lt;GLUT\/glut.h&gt;\r\n\r\n#else\r\n#include &lt;GL\/glut.h&gt;\r\n#endif\r\n\r\nusing namespace cv;\r\nGLuint id&#x5B;100];\r\n\r\nGLUquadric * quadric;\r\nvoid display()\r\n{\r\n    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);\r\n    glPushMatrix();\r\n   \/\/ glutSolidTeapot(0.5);\r\n    gluSphere(quadric,0.8,30,30);\r\n    glPopMatrix();\r\n    glFlush();\r\n}\r\nvoid init_texture(IplImage * img)\r\n{\r\n    glEnable(GL_TEXTURE_2D);\r\n    glGenTextures(10, id);\r\n    glBindTexture(GL_TEXTURE_2D, id&#x5B;0]);\r\n\r\n    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_LINEAR);\r\n    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_LINEAR);\r\n    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r\n    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r\n\r\n    glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,img-&gt;width,img-&gt;height,0,\r\n                 GL_RGB,GL_UNSIGNED_BYTE,img-&gt;imageData);\r\n}\r\n\r\nint main(int argc,char* argv&#x5B;])\r\n{\r\n\r\n    IplImage * image=cvLoadImage(&quot;1.jpg&quot;);\r\n\r\n    cvCvtColor(image, image, CV_BGR2RGB);\r\n\r\n    glutInit(&amp;argc,argv);\r\n    glutCreateWindow(&quot;Hello World&quot;);\r\n    glutDisplayFunc(display);\r\n\r\n    quadric=gluNewQuadric();\r\n    gluQuadricTexture(quadric,1);\r\n\r\n    init_texture(image);\r\n    glutMainLoop();\r\n}\r\n\r\n<\/pre>\n<h2>\u7d50\u679c\uff1a<\/h2>\n<p><a href=\"httpss:\/\/www.powenko.com\/wordpress\/?attachment_id=6873\" rel=\"attachment wp-att-6873\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6873\" src=\"httpss:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2015\/03\/Screen-Shot-2015-03-01-at-3.24.25-PM1.jpg\" alt=\"Screen Shot 2015-03-01 at 3.24.25 PM\" width=\"301\" height=\"322\" srcset=\"https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2015\/03\/Screen-Shot-2015-03-01-at-3.24.25-PM1.jpg 301w, https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2015\/03\/Screen-Shot-2015-03-01-at-3.24.25-PM1-300x321.jpg 300w, https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2015\/03\/Screen-Shot-2015-03-01-at-3.24.25-PM1-120x128.jpg 120w, https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2015\/03\/Screen-Shot-2015-03-01-at-3.24.25-PM1-210x225.jpg 210w, https:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2015\/03\/Screen-Shot-2015-03-01-at-3.24.25-PM1-140x150.jpg 140w\" sizes=\"(max-width: 301px) 100vw, 301px\" \/><\/a><\/p>\n<h2>\u88dc\u5145\u8cc7\u6599\uff1a<\/h2>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u7684\uff1a \u900f\u904e OPENGL \u986f\u793aOPENCV \u52a0\u5feb\u986f\u793a\u901f\u5ea6\uff0c\u4e26\u52a0\u4e0a\u8b49\u5238\u984f\u8272\u6750\u8cea\u8cbc\u5716\uff0c\u986f\u793a\u5728\u7403\u4e0a \u51fd\u6578\u4ecb\u7d39\uff1a \u53c3 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6872,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[248],"tags":[],"class_list":["post-6875","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ch02-opencv-api"],"_links":{"self":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6875"}],"collection":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6875"}],"version-history":[{"count":2,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6875\/revisions"}],"predecessor-version":[{"id":6881,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6875\/revisions\/6881"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/media\/6872"}],"wp:attachment":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6875"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6875"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6875"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}