목록프로그래밍/OpenCV - Python (6)
yongyong-e
https://stackoverflow.com/questions/48333362/opencv-assert-false-in-file-qasciikey-cpp I was wrong. You said it run fine at first... Then I search for qasciikey.cpp, find it is a Qt file. Did you compile OpenCV with flag WITH_QT=ON? Maybe change flag to WITH_QT=OFF, this is not use Qt, will work.
1) 가상환경 생성$ virturalenv env/opencv --python=python3.5 2) 가상환경 활성화$ source env/opencv/bin/activate 3) 종속성 설치$ pip3 install numpy 4) 바인딩 설정$ cd env/opencv/lib$ cp /usr/local/lib/python3.5/dist-packages/cv2.cpython-35m-x86_64-linux-gnu.so ~/env/opencv/lib/python3.5/site-packages
1) Codeimport cv2 import time CAM_ID = 0 cam = cv2.VideoCapture(CAM_ID) if cam.isOpened() == False: print('Can\'t open the CAM(%d)' % (CAM_ID)) exit() cv2.namedWindow('Cam') prevTime = 0 while (True): ret, frame = cam.read() curTime = time.time() sec = curTime - prevTime prevTime = curTime fps = 1 / (sec) str = "FPS : %0.1f" % fps str2 = "Testing . . ." cv2.putText(frame, str, (5, 20), cv2.FONT_..
1) Capture Videoimport numpy as np import cv2 # Video 캡쳐를 위해 VideoCapture() 객체생성 # VideoCapture(0)에서 0은 연결된 카메라의 인수 cap = cv2.VideoCapture(0) while(True): ret, frame = cap.read() gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) cv2.imshow('frame',gray) if cv2.waitKey(5) & 0xFF == ord('q'): break cap.release() cv2.destroyAllWindows() 2) Saving Videoimport numpy as np import cv2 cap = cv2.VideoCaptu..
1) 패키지 update 및 upgrade$ sudo apt-get update$ sudo apt-get upgrade 2) 필요한 패키지 설치$ sudo apt-get install build-essential cmake pkg-config libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev libavcodec-dev libavformat-dev libswscale-dev libxvidcore-dev libx264-dev libxine2-dev libv4l-dev v4l-utils libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libqt4-dev mesa-utils libgl1-mesa-dri libqt4-open..
1) opencv-python 설치참고 - 2017/09/19 - [리눅스/ubuntu] - (ubuntu16.04) OpenCV 3.2.0 설치 2) 이미지 다루기import cv2 import numpy as np from matplotlib import pyplot as plt img = cv2.imread('image.png') # image.png 로드 cv2.imshow('image', img) # 타이틀바 이름을 image로 하여 이미지를 띄움 img = cv2.imread('image.png', cv2.IMREAD_GRAYSCALE) # image.png를 gray컬러로 변환 img = cv2.resize(img, None, fx=1/2, fy=1/2, interpolation=cv2.IN..