본문 바로가기

OpenCV3

Base64 string -> cv2 이미지 변환 base64로 인코딩된 이미지를 cv2이 읽을 수 있는 형식으로 변환해서 화면에 출력할 일이 있었다. input은 base64형식으로 인코딩된 문자열(str)이다. ex. "image/jpeg;base64,/9j/4AAQSkZJ...." 변환 파이프라인은 이렇다. base64 str -> binary data -> numpy array -> cv2 array @staticmethod def base64_to_nparr(base64str): bin_buffer = base64.b64decode(base64str.split(',')[1])# base64 string -> binary data np_arr = np.frombuffer(bin_buffer, dtype=np.uint8)# binary data -.. 2022. 9. 3.
OpenCV로 영상 녹화 테스트 버전은 OpenCV 4.4.0. 입니다. #include #include using namespace std; using namespace cv; int main(void) { VideoCapture cap;// get frames from camera VideoWriter writer;// write video with frames Mat frame; cap.open(0);// connect to camera cap >> frame;// get a frame in advance to set width n height int codec = VideoWriter::fourcc('M', 'J', 'P', 'G');// codec for avi double fps = 30.0; string v_name.. 2022. 8. 8.
Window - 환경변수 설정 없이 Visual Studio에서 OpenCV 사용하기 Visual Studio에서 OpenCV를 사용하려고 인터넷을 찾아보면 대부분 PC의 환경변수를 설정해야 한다고 나온다. 그럼 그 프로젝트를 건네받는 사람은 무조건 환경변수를 설정해야 프로그램을 컴파일할 수 있다. 그래서 환경변수 설정 없이 Visual Studio에서 OpenCV를 사용하는 법을 알아봤다. **여기서는 하는 방법만 보여주기 때문에 opencv경로를 그냥 다운받은 자리 그대로 두었는데, opencv가 안깔려 있는 다른 기기에서도 작업하려고 하시는 분은 opencv 설치 경로를 프로젝트 내부에 두시면 됩니다. 0. https://opencv.org/releases/에서 OpenCV 원하는 버전을 다운 받는다. 이때 Sources 로 받지 말고 Windows로 받으셔야 합니다. Sources.. 2022. 8. 4.