{"id":3909,"date":"2020-08-07T07:43:29","date_gmt":"2020-08-06T22:43:29","guid":{"rendered":"https:\/\/now0930.pe.kr\/wordpress\/?p=3909"},"modified":"2020-08-08T11:55:26","modified_gmt":"2020-08-08T02:55:26","slug":"opencv-%ec%8b%9c%ec%9e%91%ed%95%98%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/now0930.pe.kr\/wordpress\/opencv-%ec%8b%9c%ec%9e%91%ed%95%98%ea%b8%b0\/","title":{"rendered":"opencv \uc2dc\uc791\ud558\uae30"},"content":{"rendered":"\n<p>\uc720\uba85\ud55c opencv\ub97c \uc2dc\uc791\ud588\ub2e4. docker python \uc774\ubbf8\uc9c0\ub97c \ucc3e\uc544 \uc27d\uac8c \uc2dc\uc791\ud588\ub2e4. python 3.7, opencv4\ub97c \uc124\uce58\ud55c \uc774\ubbf8\uc9c0\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker pull jjanzic\/docker-python3-opencv<\/pre>\n\n\n\n<p>\uba87 \ubc88 \uc2dc\ud589\ucc29\uc624\ub97c \uac70\ucce4\uc73c\ub098 \uc5ec\ub7ec \uc0ac\uc774\ud2b8\ub97c \ucc38\uc870\ud558\uc5ec \uacb0\uacfc\ub9cc \ub0a8\uae34\ub2e4. \uba3c\uc800 docker \ub0b4\uc6a9\uc744 host\uc5d0  \ub118\uae30\uae30 \uc704\ud574 xhost +\ub97c \uc2e4\ud589\ud588\ub2e4. \uadf8 \ub4a4 sudo \uba85\ub839\uc5b4\ub85c docker\ub97c \uc2e4\ud589\ud588\ub2e4. <a href=\"https:\/\/marcosnietoblog.wordpress.com\/2017\/04\/30\/docker-image-with-opencv-with-x11-forwarding-for-gui\/\">\uc5ec\uae30<\/a>\uc5d0 \uc88b\uc740 \ub0b4\uc6a9\uc774 \uc788\ub2e4. docker run \uc635\uc158\uc740 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo docker run --device=\/dev\/video0:\/dev\/video0 -v \/tmp\/.X11-unix:\/tmp\/.X11-unix -e DISPLAY=$DISPLAY -p 5000:5000 -p 8888:8888 -it -v \/home\/now0930\/codeForPython3\/opencv:\/home\/code  --env QT_X11_NO_MITSHM=1 jjanzic\/docker-python3-opencv_modified \/bin\/bash<\/pre>\n\n\n\n<p>\uc911\uac04\uc5d0 &#8211;env QT_X11_NO_MITSHM=1 \ub97c \ub123\uc5b4 \uc2dc\uc791\ud558\uc9c0 \uc54a\uc73c\uba74 \ub2e4\uc74c \uc5d0\ub7ec\uac00 \ub09c\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cv2.error: OpenCV(4.1.1) \/opencv-4.1.1\/modules\/highgui\/src\/window.cpp:627: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'<\/pre>\n\n\n\n<p>\uc2dc\uc791 \ud6c4 docker \ub0b4\ubd80\uc5d0\uc11c pip\ub85c opencv-python \ubaa8\ub4c8\uc744 \uc124\uce58\ud55c\ub2e4. opencv-python\ub97c \uc124\uce58\ud558\uc9c0 \uc54a\uc73c\uba74 video\ub97c \uc0ac\uc6a9\ud558\uc5ec \uc774\ubbf8\uc9c0\ub97c \uc800\uc7a5\ud560 \uc218 \uc5c6\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">python -m pip install opencv-python<\/pre>\n\n\n\n<p>root \uad8c\ud55c\uc73c\ub85c libget2.0-dev, pkg-config\ub97c \uc124\uce58\ud588\ub294\ub370 \uc601\ud5a5\uc744 \ubaa8\ub974\uaca0\ub2e4. \uc77c\ub2e8 \ub418\ub2c8 \uace0.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">apt reinstall libgtk2.0-dev pkg-config<\/pre>\n\n\n\n<p><a href=\"https:\/\/opencv-python-tutroals.readthedocs.io\/en\/latest\/py_tutorials\/py_gui\/py_video_display\/py_video_display.html#playing-video-from-file\">\uc5ec\uae30<\/a> \ucf54\ub4dc\ub97c \uadf8\ub300\ub85c \uc0ac\uc6a9\ud558\uc5ec \uc2e4\ud589 \ub428\uc744 \ud655\uc778\ud55c\ub2e4.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1600\" height=\"900\" src=\"https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2020\/08\/\uc2a4\ud06c\ub9b0\uc0f7-2020-08-07-07-37-08.png\" alt=\"\" class=\"wp-image-3912\" srcset=\"https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2020\/08\/\uc2a4\ud06c\ub9b0\uc0f7-2020-08-07-07-37-08.png 1600w, https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2020\/08\/\uc2a4\ud06c\ub9b0\uc0f7-2020-08-07-07-37-08-768x432.png 768w, https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2020\/08\/\uc2a4\ud06c\ub9b0\uc0f7-2020-08-07-07-37-08-1536x864.png 1536w\" sizes=\"auto, (max-width: 1600px) 100vw, 1600px\" \/><\/figure>\n\n\n\n<p>sudo\ub85c docker\ub97c \uc2e4\ud589\ud558\uba74 \ubcf4\uc548 \ubb38\uc81c\uac00 \uc788\ub2e4\uace0 \ud55c\ub2e4. video\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub3c4\ub85d host\uc5d0 \uad8c\ud55c\uc744 \ud560\ub2f9\ud588\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo usermod -a -G video now0930<\/pre>\n\n\n\n<p>\ub2e4\uc74c\uc744 \uc2e4\ud589\ud558\uba74, \uc708\ub3c4\uc6b0\uac00 \ubb34\ud55c\ub300\ub85c \ub72c\ub2e4. cv2.imshow\ub97c \ud558\ub098\ub9cc \uc0ac\uc6a9\ud574\uc57c \ub41c\ub2e4. \uc5ec\ub7ec \uac1c\ub97c \uc0ac\uc6a9\ud558\uba74 \ubb34\uc5c7\uc774 \ubb38\uc81c\uc778\uc9c0 \ubaa8\ub974\uaca0\uc73c\ub098, \uc548\ub41c\ub2e4. matplot\uc73c\ub85c \ucc3d\uc744 \ub744\uc6cc\ub3c4 \ub418\ub098 \ub108\ubb34 \ub290\ub9ac\ub2e4. \ucc3e\uc544\ubcf4\uba74 \ud574\uacb0 \ubc29\ubc95\uc744 \ucc3e\uaca0\uc9c0\ub9cc, \uadf8\ub0e5 cv2.imshow\ub85c \uac00\uae30\ub85c \ud588\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import cv2\nimport numpy as np\nimport matplotlib.pyplot as plt  \ncap = cv2.VideoCapture(0)\n\n#while(1):\n#videocapture\ub85c \ub4e4\uc5b4\uc624\ub294 \uc774\ubbf8\uc9c0\ub97c matplot\uc73c\ub85c \uc2e4\uc2dc\uac04 \ud45c\uc2dc\n#plt.ion()\ncap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)\ncap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)\n\nwhile cap.isOpened():\n\n    # Take each frame\n    _, frame = cap.read()\n    # Our operations on the frame come here\n    #gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)\n\n\n    # Convert BGR to HSV\n    hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)\n    #hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)\n\n    # define range of blue color in HSV\n    lower_blue = np.array([110,50,50])\n    upper_blue = np.array([130,255,255])\n\n    # Threshold the HSV image to get only blue colors\n    mask = cv2.inRange(hsv, lower_blue, upper_blue)\n\n    # Bitwise-AND mask and original image\n    res = cv2.bitwise_and(frame,frame, mask= mask)\n\n    #cv2.imshow(\"frame\",frame)\n    #cv2.imshow(\"mask\",mask)\n    cv2.imshow(\"res\",res)\n\n\n    #plt.subplot(2,2,1),plt.imshow(frame)\n    #plt.subplot(2,2,2),plt.imshow(mask)\n    #plt.subplot(2,2,3),plt.imshow(res)\n    #plt.pause(0.001)\n    #plt.show()\n\n    if cv2.waitKey(10) &amp; 0xFF == ord('q'):\n        break\ncv2.destroyAllWindows()\n<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc720\uba85\ud55c opencv\ub97c \uc2dc\uc791\ud588\ub2e4. docker python \uc774\ubbf8\uc9c0\ub97c \ucc3e\uc544 \uc27d\uac8c \uc2dc\uc791\ud588\ub2e4. python 3.7, opencv4\ub97c \uc124\uce58\ud55c \uc774\ubbf8\uc9c0\ub2e4. \uba87 \ubc88 \uc2dc\ud589\ucc29\uc624\ub97c \uac70\ucce4\uc73c\ub098 \uc5ec\ub7ec \uc0ac\uc774\ud2b8\ub97c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[12],"tags":[555,796,110],"class_list":["post-3909","post","type-post","status-publish","format-standard","hentry","category-12","tag-docker","tag-opencv","tag-python"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts\/3909","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/comments?post=3909"}],"version-history":[{"count":5,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts\/3909\/revisions"}],"predecessor-version":[{"id":3915,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts\/3909\/revisions\/3915"}],"wp:attachment":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/media?parent=3909"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/categories?post=3909"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/tags?post=3909"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}