전체 글 191

아나콘다 가상환경 클론하기

stackoverflow.com/questions/40700039/how-can-you-clone-a-conda-environment-into-the-root-environment How can you "clone" a conda environment into the root environment? I'd like the root environment of conda to copy all of the packages in another environment. How can this be done? stackoverflow.com 만약 한 가상환경을 다른 컴퓨터의 가상환경으로 옮기고 싶다면 어떻게 해야 될까요? 위 스택오버플로우에 의하면 세 가지 방법이 있다고 합니다. root라는 환경을 클론하고 싶다고 ..

환경설정 2021.03.23

FFmpeg를 사용해서 동영상 이어붙이기

물론 다른 툴을 사용할 수도 있겠지만, FFMPEG를 사용해서 동영상을 이어붙이는 방법에 대해 알아보도록 하겠습니다. 출처 : stackoverflow.com/questions/7333232/how-to-concatenate-two-mp4-files-using-ffmpeg $ cat mylist.txt file '/path/to/file1' file '/path/to/file2' file '/path/to/file3' $ ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4 이 방법으로 하니깐 잘 되는 것을 볼 수 있었습니다. 출처에 다른 방법으로 붙이는 법도 있긴 하지만, 가장 일반적인 방법이 위의 방법이라고 합니다.

Video Processing 2021.03.19

Gitignore에서 파일 제거하기

gitignore를 쓰기 전에 만약 커밋을 하게 되면, 곤란한 경우가 나옵니다. 한 번 커밋에 올라간 파일은, 계속해서 트래킹이 되기 때문이죠. 그럴 때 쓰이는 게 이 코드입니다. # To create a new .gitignore file touch .gitignore # To untrack the unnecessary tracked files in your gitignore which removes everything from its index. Specific filenames can also be used instead of dot(.). git rm -r --cached . git add . git commit -m "gitignore fixed untracked files" 출처 : towar..

Utils/Git 2021.03.15

(opencv) 두 이미지의 차이를 박스로 나타내기

저번 포스트에서 walkaroundthedevelop.tistory.com/56 어떻게 하면 두 이미지의 차이를 알 수 있는지에 대해서 알아보았습니다. 그럼 두 개의 이미지를 이용해서 차이를 표시해낼 수 있을까요? 일단 두 개의 이미지를 사용해서 얻어낸 diff를 디스플레이 해 봅시다. 두 개의 이미지에다가 diff를 구하면, 이렇게 됩니다. 이 diff를 보면, 포스트잇을 붙인 곳이 검은색으로 된 것을 볼 수 있습니다. # 이전 포스트에서 diff 가져옴! thresh = cv2.threshold(diff, 100, 255, cv2.THRESH_BINARY_INV)[1] # get contours cnts = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, c..

OpenCV를 이용해서 두 개의 이미지 비교하기 (SSIM)

레퍼런스 : ourcodeworld.com/articles/read/991/how-to-calculate-the-structural-similarity-index-ssim-between-two-images-with-python opencv를 이용해서 두 개의 이미지를 비교하는 방법에 대해서 알아보겠습니다. # Usage: # # python3 script.py -f original.png -s modified.png # Based on: https://github.com/mostafaGwely/Structural-Similarity-Index-SSIM- # 1. Import the necessary packages #from skimage.measure import compare_ssim as ssim ..

list 에서 Queue로 옮기기

이 이슈를 접한 것은, 제가 쓰던 프로그램에서 os.listdir을 사용하였기 때문입니다. os.listdir을 사용했을 때 deque를 사용하는 방법은 다음과 같습니다. from collections import deque dq = deque(os.listdir('.')) 하지만 멀티 쓰레드 애플리케이션의 경우에는 deque보다는 queue.Queue를 사용하는게 좋다고 말했습니다. 하지만 queue.Queue(os.listdir('.')) 는 통용되지 않습니다. 그럼 직접 옮겨야 되는데, 다음 참고할 만한 레퍼런스가 있습니다. stackoverflow.com/questions/21639888/is-it-possible-to-convert-list-to-queue-in-python/41581928 im..

Python 2021.03.09

Cv2 를 이용해서 multiple 이미지 crop하고 나머지 mask 하기

저번시간의 심화 입니다. 만약 crop하고 싶은 roi가 한 개가 아니면 어떡할까요? import numpy as np import cv2 image = cv2.imread('download.jpg') mask = np.zeros((image.shape[0], image.shape[1])) # roi 정리 시작 roi = "0,0,300,0,300,300,0,300_300,300,600,300,600,600,300,600" roi_list = roi.split("_") print(roi_list) croplist = [] for r in roi_list: crop = [] cl = r.split(",") for i in range(0, len(cl), 2): crop.append([int(cl[i]), ..

Cv2 를 이용해서 이미지 crop하고 나머지 mask 하기

이미지 프로세싱을 하다보면 cropping을 할 때가 종종 있습니다. cropping이란, 잘라내는 걸 뜻합니다. 그럼 큰 사이즈의 이미지가 작은 사이즈가 되는, 잘라지기가 시행됩니다. import numpy as np import cv2 image = cv2.imread('download.jpg') y=0 x=0 h=500 w=500 crop = image[y:y+h, x:x+w] cv2.imshow('Image', crop) cv2.waitKey(0) ~ 하지만 이걸 사이즈를 그대로 유지한 채, 그 부분의 이미지만 보이고, 나머지 부분은 mask, 즉, 검은색으로 칠하는 건 어떻게 할 수 있을까요? 이런 식의 cropping은 특정한 부위에서만 이미지 프로세싱이 필요할 때 필요합니다 import nu..