블러킹 방식이지만 잘 되긴 함.

[링크 : https://1d1cblog.tistory.com/69

 

그래서 멀티쓰레드로 작동하게 해야하나? 고민중

[링크 : https://m.blog.naver.com/jkg57/222480924841]

[링크 : https://nachwon.github.io/asyncio-futures/]

 

[링크 : https://orashelter.tistory.com/47]

[링크 : https://docs.python.org/3.6/library/asyncio-protocol.html]

'Programming > python(파이썬)' 카테고리의 다른 글

matplotlib grayscale image to 3d graph  (0) 2024.02.22
python tcp 서버 예제  (0) 2024.01.22
ipython notebook -> jupyter notebook  (0) 2024.01.11
파이썬 가상환경  (0) 2024.01.09
pyplot legend picking  (0) 2023.10.05
Posted by 구차니
Programming/openCV2024. 1. 16. 11:34

MTM + webcam

pc에서는 잘도는데 arm에서 잘되려나..

 

import MTM, cv2
import numpy as np

letter_a = cv2.imread('letter_a.png', 0)
letter_b = cv2.imread('letter_b.png', 0)
letter_c = cv2.imread('letter_c.png', 0)
letter_d = cv2.imread('letter_d.png', 0)

letter_a.astype(np.uint8)
letter_b.astype(np.uint8)
letter_c.astype(np.uint8)
letter_d.astype(np.uint8)

listTemplates = [('A', letter_a),
                 ('B', letter_b),
                 ('C', letter_c),
                 ('D', letter_d)]

webcam = cv2.VideoCapture(2)
webcam.set(cv2.CAP_PROP_FRAME_WIDTH, 1024)
webcam.set(cv2.CAP_PROP_FRAME_HEIGHT, 768)

def drawBoxesOnRGB2(image, tableHit, boxThickness=2, boxColor=(255, 255, 00), showLabel=False, labelColor=(255, 255, 0), labelScale=0.5 ):
    # Convert Grayscale to RGB to be able to see the color bboxes
    if image.ndim == 2: outImage = cv2.cvtColor(image, cv2.COLOR_GRAY2RGB) # convert to RGB to be able to show detections as color box on grayscale image
    else:               outImage = image.copy()

    for _, row in tableHit.iterrows():
        x,y,w,h = row['BBox']
        score = row['Score']
        cv2.rectangle(outImage, (x, y), (x+w, y+h), color=boxColor, thickness=boxThickness)
        if showLabel: cv2.putText(outImage, text=row['TemplateName'] + "@" + str(score * 100), org=(x, y), fontFace=cv2.FONT_HERSHEY_SIMPLEX, fontScale=labelScale, color=labelColor, lineType=cv2.LINE_AA)

    return outImage

if not webcam.isOpened():
    print("Could not open webcam")
    exit()

while webcam.isOpened():
    status, image = webcam.read()
    image.astype(np.uint8)
    image_gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

    tableHit = MTM.matchTemplates(listTemplates, image_gray, score_threshold=0.8, method=cv2.TM_CCOEFF_NORMED, maxOverlap=0)
    print("Found {} letters".format(len(tableHit)))
    print(tableHit)

    Overlay = drawBoxesOnRGB2(image, tableHit, showLabel=True)

    if status:
        cv2.imshow("test", Overlay)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

webcam.release()
cv2.destroyAllWindows()

[링크 : https://medium.com/quantrium-tech/object-detection-multi-template-matching-2c9c9fc1a867]

[링크 : https://github.com/multi-template-matching/MultiTemplateMatching-Python]

 

열고 해상도 바꾸는게 안되면, 열면서 해상도 설정하면 됨.

cap = cv2.VideoCapture(1, apiPreference=cv2.CAP_ANY, params=[
    cv2.CAP_PROP_FRAME_WIDTH, 1280,
    cv2.CAP_PROP_FRAME_HEIGHT, 1024])

[링크 : https://stackoverflow.com/questions/71310212/python-cv2-videocapture-has-wrong-resolution-and-read-cropped-images]

'Programming > openCV' 카테고리의 다른 글

opencv 카메라 캡쳐 - 최신 이미지 갱신  (0) 2024.01.25
opencv webcam 수동촛점 조절  (0) 2024.01.25
opencv cv2.imshow() error  (0) 2024.01.16
opencv를 이용한 다중 템플릿 추적  (0) 2024.01.15
cv2.imshow cv2.waitKey  (0) 2022.03.14
Posted by 구차니
Programming/openCV2024. 1. 16. 10:54

잘되더니 버전이 올라가서 그런가 배를 짼다.

실행 환경은 i.mx8mp evk / wayland 환경이라 그런가..

그런데 잘되다가 pip로 이것저것 x86도 갈아 엎었더니 똑같이 문제가 발생..

 

에러는 아래와 같은데 어떤 패키지를 설치하라고 한다. libgtk 라.. wayland 되면서 들어내버린건가?

Traceback (most recent call last):
  File "/home/falinux/work/src/cv2/cam2.py", line 31, in <module>
    cv2.imshow("test", image)
cv2.error: OpenCV(4.9.0) /io/opencv/modules/highgui/src/window.cpp:1272: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'

 

아무튼 패키지 깔고, pip로 깔아주니 해결

sudo apt install libgtk2.0-dev pkg-config
pip install opencv-contrib-python

[링크 : https://stackoverflow.com/questions/42843316/how-to-include-libgtk2-0-dev-and-pkg-config-in-cmake-when-installing-opencv-on-u]

 

디자인이 먼가 바뀌었다?

'Programming > openCV' 카테고리의 다른 글

opencv webcam 수동촛점 조절  (0) 2024.01.25
MTM + webcam  (0) 2024.01.16
opencv를 이용한 다중 템플릿 추적  (0) 2024.01.15
cv2.imshow cv2.waitKey  (0) 2022.03.14
virtual mouse  (0) 2022.01.25
Posted by 구차니
Programming/openCV2024. 1. 15. 10:48

 

일반적인 템플릿 매칭은 가장 매칭되는 하나의 녀석만 찾는데

트럼프 카드와 같이 여러개의 도형이 있을 경우 여러개를 다 찾는 방법을 제공함.

[링크 : https://pyimagesearch.com/2021/03/29/multi-template-matching-with-opencv/]

 

yolo 외에도 쓸 수 있는 방법이었나?

[링크 : https://pyimagesearch.com/2014/11/17/non-maximum-suppression-object-detection-python/]

 

openCV 문서에서도 발견

minMaxLoc을 안쓰면 되다고. (응?)

    res = cv.matchTemplate(img,template,method)
    min_val, max_val, min_loc, max_loc = cv.minMaxLoc(res)
    cv.rectangle(img,top_left, bottom_right, 255, 2)
res = cv.matchTemplate(img_gray,template,cv.TM_CCOEFF_NORMED)
threshold = 0.8
loc = np.where( res >= threshold)
for pt in zip(*loc[::-1]):
    cv.rectangle(img_rgb, pt, (pt[0] + w, pt[1] + h), (0,0,255), 2)

[링크 : https://docs.opencv.org/3.4/d4/dc6/tutorial_py_template_matching.html]

 

아래 그림 하나로 설명.

원래 내가 원하던 건데.. x86이 아닌 arm에서도 되려나?

[링크 : https://medium.com/quantrium-tech/object-detection-multi-template-matching-2c9c9fc1a867]

[링크 : https://pypi.org/project/Multi-Template-Matching/]

'Programming > openCV' 카테고리의 다른 글

MTM + webcam  (0) 2024.01.16
opencv cv2.imshow() error  (0) 2024.01.16
cv2.imshow cv2.waitKey  (0) 2022.03.14
virtual mouse  (0) 2022.01.25
opencv-3.4.0 어플리케이션 빌드  (0) 2021.01.14
Posted by 구차니

interactive python 해서 ipython인가?

notebook은 ipython 꺼였는데 jupyter의 일부가 되었다고 한다.

Installing IPython

There are multiple ways of installing IPython. This page contains simplified installation instructions that should work for most users. Our official documentation contains more detailed instructions for manual installation targeted at advanced users and developers.
If you are looking for installation documentation for the notebook and/or qtconsole, those are now part of Jupyter.

[링크 : https://ipython.org/install.html]

[링크 : https://pypi.org/project/ipython/]

[링크 : https://yujuwon.tistory.com/m/entry/ipython-노트북-설치하기]

'Programming > python(파이썬)' 카테고리의 다른 글

python tcp 서버 예제  (0) 2024.01.22
파이썬 소켓 예제  (0) 2024.01.17
파이썬 가상환경  (0) 2024.01.09
pyplot legend picking  (0) 2023.10.05
matplotlib  (0) 2023.10.04
Posted by 구차니

이것저것 조사해보는데

무식하지만 가장 확실한(?) docker로 버전별로 혹은 프로젝트 별로 생성하는 것부터

python 에서 제공하는 venv

venv를 확장해서 사용하는 virtualenv

그리고 conda 정도로 정리되는 듯.

 

 

conda

[링크 : https://m.blog.naver.com/jonghong0316/221683053696]

 

virtualenv, venv

[링크 : https://jaemunbro.medium.com/python-virtualenv-venv-설정-aaf0e7c2d24e]

 

conda, venv

[링크 : https://yongeekd01.tistory.com/39]

 

venv, pipenv, conda, docker(이걸.. 가상이라고 하긴 해야 하는데.. 해줘야 하는거 맞....나?)

[링크 : https://dining-developer.tistory.com/21]

 

virtualenv, pyenv, pipenv

[링크 : https://jinwoo1990.github.io/dev-wiki/python-concept-3/]

 

+

conda - Conda provides package, dependency, and environment management for any language.

파이썬 전용이 아닌가?

[링크 : https://docs.conda.io/en/latest/]

[링크 : https://anaconda.org/]

[링크 : https://anaconda.org/anaconda/conda]

 

+

virtualenv

is slower (by not having the app-data seed method),
is not as extendable,
cannot create virtual environments for arbitrarily installed python versions (and automatically discover these),
is not upgrade-able via pip,
does not have as rich programmatic API (describe virtual environments without creating them).

[링크 : https://virtualenv.pypa.io/en/latest/]

 

+

venv

[링크 : https://docs.python.org/3/library/venv.html] 3.12.1

 

venv는 3.7 이후부터 사용이 가능한 것으로 보임. 즉, 버전별로 호환성은 없을 가능성이 있음

pyvenv 스크립트는 파이썬 3.6 에서 폐지되었고, 가상 환경이 어떤 파이썬 인터프리터를 기반으로 하는지에 대한 잠재적인 혼동을 방지하기 위해 python3 -m venv를 사용합니다.

[링크 : https://docs.python.org/ko/3.7/library/venv.html]

'Programming > python(파이썬)' 카테고리의 다른 글

파이썬 소켓 예제  (0) 2024.01.17
ipython notebook -> jupyter notebook  (0) 2024.01.11
pyplot legend picking  (0) 2023.10.05
matplotlib  (0) 2023.10.04
pyplot  (0) 2023.10.04
Posted by 구차니
Programming/C Win32 MFC2023. 12. 18. 17:49

또 이상한 에러가 보이길래 멘붕..

다리 다치면서 머리도 같이 다친건가 ㅠㅠ

 

free(): invalid next size (normal)
중지됨 (코어 덤프됨)

 

간단하게 malloc() 은 100 해놓고 101을 쓰면 glibc 에서 malloc 한것 이상으로 썼다고 free() 할 때 에러를 발생한다.

그냥.. 해당 메모리 번지에 접근할 때 에러내면 안되냐?

할당된 메모리를 넘어서 썼을 경우에, 해당 메모리를 해제 할때 발생
메모리를 overwrite 하는지 확인 할 것

[링크 : https://m.blog.naver.com/sysganda/30103851649]

'Programming > C Win32 MFC' 카테고리의 다른 글

c에서 cpp 함수 불러오기  (0) 2023.01.04
MSB / LSB 변환  (0) 2022.08.29
kore - c restful api server  (0) 2022.07.07
fopen exclusivly  (0) 2021.07.09
vs2019 sdi , mdi 프로젝트 생성하기  (0) 2021.07.08
Posted by 구차니
Programming/golang2023. 12. 8. 11:30

logo.png나 logo.svg가 읽히지 않는 이상한 문제 발생

 

확인해보니 내부적으로 skipper를 이용해 log로 시작하면 스킵하도록 해놨는데

그걸 HasPrefix() 로 구현하다 보니, logo.svg나 log.png 에서 log로 시작하니 스킵되어 발생한 해프닝(?)

/log를 /log/로 바꾸면 문제없이 logo.png도 읽어온다.

e.Use(middleware.StaticWithConfig(middleware.StaticConfig{
Root: "html",
Skipper: func(c echo.Context) bool {
return strings.HasPrefix(c.Request().RequestURI, "/log")
},
}))

'Programming > golang' 카테고리의 다른 글

golang swagger part 2  (0) 2024.01.18
golang용 swagger  (0) 2024.01.17
golang 타입 땜시 짜증  (0) 2023.11.10
golang 타입 캐스팅 제약(?)  (0) 2023.11.09
golang 배열과 슬라이스  (0) 2023.11.08
Posted by 구차니
Programming/web 관련2023. 11. 29. 15:23

exif의 orientation 정보를 이용하여

웹에서 이미지를 정상적인 방향으로 출력할 수 있을 듯?

[링크 : https://github.com/exif-js/exif-js]

 

const orientation = EXIF.getTag( fileInfo, "Orientation" );

[링크 : https://blog.naver.com/hj_kim97/222309039397]

'Programming > web 관련' 카테고리의 다른 글

bootstrap modal  (0) 2024.01.23
브라우저 언어 탐지  (0) 2024.01.18
chart.js multi y axis  (0) 2023.09.27
웹 브라우저 10080 포트 접근 차단 이유  (0) 2023.08.03
javascript 배열을파일로 저장하기  (0) 2023.08.02
Posted by 구차니
Programming/golang2023. 11. 10. 14:30

아놔.. 너무 심하게 강형 언어인거 아닌가 싶을 정도로

별별것 다 트집을 잡아서 명시적으로 형변환을 하게 만든다

time.Sleep(2 * time.Second) // 정상 작동

var update_sec int = 2
time.Sleep(update_sec * time.Second) // 에러

time.Sleep(time.Duration(update_sec) * time.Second) // 정상 작동

[링크 : https://jusths.tistory.com/71]

 

아니면 내가 너무 golang을 golang 답게 안쓰는건가?

'Programming > golang' 카테고리의 다른 글

golang용 swagger  (0) 2024.01.17
golang echo static web / logo.* 안돼?  (0) 2023.12.08
golang 타입 캐스팅 제약(?)  (0) 2023.11.09
golang 배열과 슬라이스  (0) 2023.11.08
golang ini 지원  (0) 2023.11.07
Posted by 구차니