준비사항
1. USB 웹캠 라이브러리
https://kr.mathworks.com/matlabcentral/fileexchange/45182-matlab-support-package-for-usb-webcams
MATLAB에서 웹캠 기능을 쓰려면 위 라이브러리 패키지를 다운받은 후 설치하면 된다.
2. Computer Vision Toolbox
https://kr.mathworks.com/products/computer-vision.html
이 글에서는 툴박스 라이센스가 있어서 바로 사용했고, 만약 라이센스 없거나 octave인 경우에는 OpenCV로 대체 가능할 듯하다.
웹캠에서 이미지 얻기
https://kr.mathworks.com/help/supportpkg/usbwebcams/ug/acquire-images-from-webcams.html
Acquire Images from Webcams - MATLAB & Simulink - MathWorks 한국
아래 MATLAB 명령에 해당하는 링크를 클릭하셨습니다. 이 명령을 MATLAB 명령 창에 입력해 실행하십시오. 웹 브라우저에서는 MATLAB 명령을 지원하지 않습니다.
kr.mathworks.com
간단 설명
preview(cam) : 실시간 웹캠이미지
snapshot(cam) : 사진찍기(결과물은 xres, yres, rgb의 dimension으로 return. 예) 720x1280x3 )
그 외에도 cam.Focus 등을 조절하면 된다.
인식이 잘 안될때 이미지 전처리 및 인식결과 필터링
Recognize Text Using Optical Character Recognition (OCR) - MATLAB & Simulink - MathWorks 한국
A modified version of this example exists on your system. Do you want to open this version instead? (ko_KR)
kr.mathworks.com
위 페이지에서는 imtophat을 사용해서 흰색 글씨를 잘 인식되게 했는데, 흰 바탕에 검은 글씨를 인식하고 싶으면 imbothat을 쓰면 된다.
결과물
코드
https://github.com/ProjectEli/MATLAB_webcam_OCR
부록: 딥러닝(AlexNet) 사용 예제
https://kr.mathworks.com/content/dam/mathworks/ebook/gated/KR_Deep_Learning_ebook.pdf
'프로그래밍' 카테고리의 다른 글
오디오 파일 읽어서 SoundCloud Waveform처럼 만들기 관련 자료 (0) | 2022.02.21 |
---|---|
manifest v3 Chrome extension에서 service worker와 indexedDB를 올바르게 사용하기 (0) | 2022.02.16 |
MATLAB으로 머신러닝 입문(?) (0) | 2019.12.13 |
GitLab 설정 (0) | 2018.04.07 |
BMS구동기 v0.4 (4) | 2016.02.13 |