개 두마리 씻기고
세차하고
빨래개고, 설겆이하고, 밥하고, 빨래하고
팔이 아릴 정도로 고생을 한 기분..
'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글
| 지름 (0) | 2024.03.10 |
|---|---|
| 입학식 (0) | 2024.03.04 |
| 생일 파티 part 2 + 웹캠지름 (0) | 2024.03.02 |
| 생일 파티 part 1 (0) | 2024.03.01 |
| 주말이 짧다 (0) | 2024.02.25 |
개 두마리 씻기고
세차하고
빨래개고, 설겆이하고, 밥하고, 빨래하고
팔이 아릴 정도로 고생을 한 기분..
| 지름 (0) | 2024.03.10 |
|---|---|
| 입학식 (0) | 2024.03.04 |
| 생일 파티 part 2 + 웹캠지름 (0) | 2024.03.02 |
| 생일 파티 part 1 (0) | 2024.03.01 |
| 주말이 짧다 (0) | 2024.02.25 |
이제와서 하다니 흑흑
소득공제 - 인적공제, 카드, 현금영수증 (총 급여액 깍기)
세액공제 - 보험, 의료, 교육 (산출 세액 깍기)
| 지하철 연...착? (0) | 2024.04.17 |
|---|---|
| ㄹ미ㅏㄴ어리ㅏㅁㄴ어리ㅏㄴㅁ어리ㅏ (0) | 2024.03.06 |
| 소득공제? (0) | 2024.02.13 |
| 으아아아아아 (0) | 2024.01.24 |
| 개 피곤 (0) | 2024.01.12 |
| Block SCSI generic (bsg) driver (0) | 2024.04.16 |
|---|---|
| lsusb -v 로 본 장치(HID MT, mouse) (0) | 2024.03.08 |
| btrfs fsck (0) | 2024.02.13 |
| 리눅스 파일 시스템 캐싱 (0) | 2024.01.09 |
| multitail / tail (2) | 2023.10.18 |
contrib 패키지를 설치해주면 해결!
오늘자 기준으로 한 63MB 정도 된다. 꽤나 큰 편 인 듯
| $ python3 depth.py Traceback (most recent call last): File "/home/minimonk/src/DisparityMapfromStereoPair/depth.py", line 17, in <module> right_matcher = cv.ximgproc.createRightMatcher(left_matcher); AttributeError: module 'cv2' has no attribute 'ximgproc' $ pip install opencv-contrib-python |
[링크 : https://stackoverflow.com/questions/57427233/module-cv2-cv2-has-no-attribute-ximgproc]
| docker를 이용하여 python 에서 opencv 돌리기 (0) | 2024.05.08 |
|---|---|
| python thread event (0) | 2024.03.05 |
| cv2.stereoBM + WLS (0) | 2024.02.28 |
| matplotlib animation (0) | 2024.02.28 |
| pip 패키지 관리 (0) | 2024.02.27 |
matplotlib을 3d로 그려보는 것 까지 통합완료. 이제 SGBM만 해보면 될 듯
| WLS 필터 미적용 | WLS 필터 적용 |
![]() |
![]() |
|
import numpy as np
import cv2 as cv
from matplotlib import pyplot as plt
imgL = cv.imread('tsukuba_l.png', cv.IMREAD_GRAYSCALE)
imgR = cv.imread('tsukuba_r.png', cv.IMREAD_GRAYSCALE)
max_disparity=16
stereo = cv.StereoBM_create(max_disparity, blockSize=15)
disparity = stereo.compute(imgL,imgR)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# X, Y 좌표 생성
height, width = imgL.shape
x = np.arange(0, width, 1)
y = np.arange(0, height, 1)
x, y = np.meshgrid(x, y)
# 깊이 맵을 사용하여 Z 좌표 생성
z = disparity
# 3D 그래프에 표시
ax.plot_surface(x, y, z, cmap='viridis')
plt.show()
# WLS 필터 적용
right_matcher = cv.ximgproc.createRightMatcher(stereo);
left_disp = stereo.compute(imgL, imgR);
right_disp = right_matcher.compute(imgR, imgL);
# Now create DisparityWLSFilter
wls_filter = cv.ximgproc.createDisparityWLSFilter(stereo);
sigma = 1.5
lmbda = 8000.0
wls_filter.setLambda(lmbda);
wls_filter.setSigmaColor(sigma);
filtered_disp = wls_filter.filter(left_disp, imgL, disparity_map_right=right_disp);
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
z = filtered_disp
# 3D 그래프에 표시
ax.plot_surface(x, y, z, cmap='viridis')
plt.show()
|
| python thread event (0) | 2024.03.05 |
|---|---|
| cv2.ximgproc 없을 경우 (0) | 2024.02.28 |
| matplotlib animation (0) | 2024.02.28 |
| pip 패키지 관리 (0) | 2024.02.27 |
| pyhthon numpy 생략없이 출력 (0) | 2024.02.26 |
[링크 : https://matplotlib.org/stable/api/animation_api.html]
| import numpy as np import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation fig, ax = plt.subplots() xdata, ydata = [], [] ln, = plt.plot([], [], 'ro') def init(): ax.set_xlim(0, 2*np.pi) ax.set_ylim(-1, 1) return ln, def update(frame): xdata.append(frame) ydata.append(np.sin(frame)) ln.set_data(xdata, ydata) return ln, ani = FuncAnimation(fig, update, frames=np.linspace(0, 2*np.pi, 128), init_func=init, blit=True) plt.show() |
[링크 : https://pythonprogramming.net/python-matplotlib-live-updating-graphs/]
[링크 : https://stackoverflow.com/questions/11874767/how-do-i-plot-in-real-time-in-a-while-loop]
+ 2024.03.14
| import cv2 import matplotlib.pyplot as plt def grab_frame(cap): ret,frame = cap.read() return cv2.cvtColor(frame,cv2.COLOR_BGR2RGB) #Initiate the two cameras cap1 = cv2.VideoCapture(0) cap2 = cv2.VideoCapture(1) #create two subplots ax1 = plt.subplot(1,2,1) ax2 = plt.subplot(1,2,2) #create two image plots im1 = ax1.imshow(grab_frame(cap1)) im2 = ax2.imshow(grab_frame(cap2)) plt.ion() while True: im1.set_data(grab_frame(cap1)) im2.set_data(grab_frame(cap2)) plt.pause(0.2) plt.ioff() # due to infinite loop, this gets never called. plt.show() |
[링크 : https://stackoverflow.com/questions/44598124/update-frame-in-matplotlib-with-live-camera-preview]
| matplotlib.pyplot.ion()[source] Enable interactive mode. See pyplot.isinteractive for more details. See also ioff Disable interactive mode. isinteractive Whether interactive mode is enabled. show Show all figures (and maybe block). pause Show all figures, and block for a time. |
[링크 : https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.ion.html]
| cv2.ximgproc 없을 경우 (0) | 2024.02.28 |
|---|---|
| cv2.stereoBM + WLS (0) | 2024.02.28 |
| pip 패키지 관리 (0) | 2024.02.27 |
| pyhthon numpy 생략없이 출력 (0) | 2024.02.26 |
| matplotlib grayscale image to 3d graph (0) | 2024.02.22 |
pip도 아래 명령들을 이용하면 현재 패키지 버전들을 저정하고, 필요한 버전들을 설치할 수 있다.
python 프로젝트들이 나중에 버전이 꼬여서 난리나는거 보면
필수적인데 왜 다들 안쓸까..
| pip list pip freeze > requirements.txt |
[링크 : https://intelloper.tistory.com/53]
| pip install -r requirements.txt |
| cv2.stereoBM + WLS (0) | 2024.02.28 |
|---|---|
| matplotlib animation (0) | 2024.02.28 |
| pyhthon numpy 생략없이 출력 (0) | 2024.02.26 |
| matplotlib grayscale image to 3d graph (0) | 2024.02.22 |
| python tcp 서버 예제 (0) | 2024.01.22 |
Weighted Least Squares filter라는게 sgbm 예제를 찾다가 나옴
[링크 : https://docs.opencv.org/3.4/d9/d51/classcv_1_1ximgproc_1_1DisparityWLSFilter.html]
필터라는 이름 답게
왼쪽의 노이즈가 심해 보이는 깊이 정보를, 면 단위로 정렬해서 보기 쉽게 변환해준다.
![]() |
![]() |
[링크 : https://forum.opencv.org/t/bad-disparity-map-with-sgbm-algorithm/8209]
[링크 : https://stackoverflow.com/questions/62627109/how-do-you-use-opencvs-disparitywlsfilter-in-python]
[링크 : https://amroamroamro.github.io/mexopencv/opencv_contrib/disparity_filtering_demo.html]
+
BM(block match) 알고리즘에 filter 적용 예제
[링크 : https://docs.opencv.org/4.x/d3/d14/tutorial_ximgproc_disparity_filtering.html]
+
2024.02.28
WLS 필터는 별도의 패키지를 설치해야 한다
| $ pip install opencv-contrib-python |
패키지 설치 후에 처리해보면 확실히 좀 더 나은 느낌이긴 하다.
BM 에 적용해봤으니 이제 SGBM 에도 해봐야..
| WLS 필터 적용 전 | WLS 필터 적용 후 |
![]() |
![]() |
| $ cat depth.py import numpy as np import cv2 as cv from matplotlib import pyplot as plt imgL = cv.imread('tsukuba_l.png', cv.IMREAD_GRAYSCALE) imgR = cv.imread('tsukuba_r.png', cv.IMREAD_GRAYSCALE) max_disparity=16 stereo = cv.StereoBM_create(max_disparity, blockSize=15) disparity = stereo.compute(imgL,imgR) plt.imshow(disparity) plt.show() right_matcher = cv.ximgproc.createRightMatcher(stereo); left_disp = stereo.compute(imgL, imgR); right_disp = right_matcher.compute(imgR, imgL); # Now create DisparityWLSFilter wls_filter = cv.ximgproc.createDisparityWLSFilter(stereo); sigma = 1.5 lmbda = 8000.0 wls_filter.setLambda(lmbda); wls_filter.setSigmaColor(sigma); filtered_disp = wls_filter.filter(left_disp, imgL, disparity_map_right=right_disp); plt.imshow(filtered_disp) plt.show() |
| python openCV 빌드 옵션 (0) | 2025.08.04 |
|---|---|
| openCV + python + matplotlib (0) | 2024.05.23 |
| openCV stereo SBGM 예제, depth map을 imshow로 보기 (0) | 2024.02.26 |
| opencv stereo 계산 알고리즘 (0) | 2024.02.24 |
| opencv 스테레오 카메라 깊이 처리하기 (0) | 2024.02.21 |