'잡동사니'에 해당되는 글 13670건

  1. 2024.01.16 MTM + webcam
  2. 2024.01.16 opencv cv2.imshow() error
  3. 2024.01.15 원격 데스크톱 포트 변경하기
  4. 2024.01.15 NMS, soft-NMS
  5. 2024.01.15 opencv를 이용한 다중 템플릿 추적
  6. 2024.01.14 장보기
  7. 2024.01.13 피곤피곤 오늘도 피곤
  8. 2024.01.12 개 피곤
  9. 2024.01.11 VGG-16 / VGG-19
  10. 2024.01.11 MobileNetV2 SSD FPN-Lite
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 구차니
Microsoft/Windows2024. 1. 15. 14:10

공유기 쓰면 간단(?)하겠지만 귀찮으니(!) 자체적으로 서비스 포트변경하는 법 찾아봄

 

레지스트리를 변경하고 리부팅 해줘야 적용이라니 -_-

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp

[링크 : https://learn.microsoft.com/ko-kr/windows-server/remote/remote-desktop-services/clients/change-listening-port]

[링크 : https://learn.microsoft.com/en-us/windows-server/remote/remote-desktop-services/clients/change-listening-port]

[링크 : https://v2cloud.com/tutorials/change-rdp-port]

'Microsoft > Windows' 카테고리의 다른 글

3d 그림판 보다는 3d builder  (0) 2024.02.19
ms 인증(bios) 키 확인 - rw everything  (0) 2024.01.31
mstsc 제한된 계정  (0) 2023.12.18
nvidia 채굴 그래픽 카드 hybrid mode  (0) 2023.07.12
win11 notepad 별루야!  (0) 2023.04.10
Posted by 구차니

NMS는 하나로 억제하기 때문에

겹칠 경우 하나의 객체를 인식하지 못하게 되므로 이를 개선한 것이 soft-NMS 라고 

 

[링크 : https://hongl.tistory.com/180]

[링크 : https://ctkim.tistory.com/entry/Non-maximum-Suppression-NMS]

 

'프로그램 사용 > yolo_tensorflow' 카테고리의 다른 글

내장 그래픽으로 ROCm?  (0) 2025.09.05
ai 모델들 조사  (0) 2025.09.04
VGG-16 / VGG-19  (0) 2024.01.11
MobileNetV2 SSD FPN-Lite  (0) 2024.01.11
mobilenet v2 ssd  (0) 2024.01.11
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 구차니

설이 다가와서 이것저것 살게 많아진다.

아내친구랑 같이 장보러 가서 술을 잔뜩 샀는데

10만원 넘으면 신원확인해야 한다고.. 아니 그런게 있었어?

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

병원  (0) 2024.01.20
TOP FRUIT 망고젤리 맛이 다르다?!  (4) 2024.01.18
피곤피곤 오늘도 피곤  (0) 2024.01.13
lilgadget 헤드폰 단돈 21.95$  (0) 2024.01.09
집 도착 콜밴  (0) 2024.01.08
Posted by 구차니

장보고 와서는 완전 피곤해서 한 3시간 넘게 기절했던 것 같다.

원래 자전거 좀 손보고 타려고 했는데 끄응..

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

TOP FRUIT 망고젤리 맛이 다르다?!  (4) 2024.01.18
장보기  (0) 2024.01.14
lilgadget 헤드폰 단돈 21.95$  (0) 2024.01.09
집 도착 콜밴  (0) 2024.01.08
바나힐 테마파크  (0) 2024.01.07
Posted by 구차니

운전하면서사도 꾸벅꾸벅.

외근 다녀왔더니 줄서서 기다리는 진기한 풍경 -_ㅠ

'개소리 왈왈 > 직딩의 비애' 카테고리의 다른 글

소득공제?  (0) 2024.02.13
으아아아아아  (0) 2024.01.24
일이 안풀린다  (0) 2023.11.23
리듬깨짐  (0) 2023.11.05
누가 외근이란걸 발명한거야?  (0) 2023.10.06
Posted by 구차니

Visual Geometry Group

VGG 뒤의 숫자는 CNN 레이어의 갯수

CNN(Convolutional Neural network) - 나선형의/복잡한 신경망으로 해석이 되나?

 

[링크 : https://wikidocs.net/164796]

 

탐지도 되긴 하나본데...

[링크 : https://github.com/zubairsamo/Object-Detection-With-Tensorflow-Using-VGG16]

 

keras에 있는 VGG16을 그냥 바로 써서 간단하게 되네..

게다가 save load도 되는데 왜 난 안될까.. ㅠㅠ

# lets import pre trained VGG16 Which is already Builtin for computer vision
from tensorflow.keras.applications import VGG16
from tensorflow.keras.layers import Input
     

# Imagenet is a competition every year held and VGG16 is winner of between  2013-14
# so here we just want limited layers so thats why we false included_top 
vgg=VGG16(weights='imagenet',include_top=False,input_tensor=Input(shape=(224,224,3)))


# lets save model 
model.save('detect_Planes.h5')     

from tensorflow.keras.models import load_model
model=load_model('/content/detect_Planes.h5')

[링크 : https://github.com/zubairsamo/Object-Detection-With-Tensorflow-Using-VGG16/blob/main/Object_Detection_Using_VGG16_With_Tensorflow.ipynb]

'프로그램 사용 > yolo_tensorflow' 카테고리의 다른 글

ai 모델들 조사  (0) 2025.09.04
NMS, soft-NMS  (0) 2024.01.15
MobileNetV2 SSD FPN-Lite  (0) 2024.01.11
mobilenet v2 ssd  (0) 2024.01.11
ssd-mobilenetv2 on jupyter notebook  (2) 2024.01.10
Posted by 구차니

모델 zoo 에서 보다보면 먼가 주르르륵 붙는데

솔찍히 mobilenet v2가 무엇인지, ssd는 또 무엇인지 몰라서 헷갈려서 조사

근데.. FPN은 전에 검색해둔 기억이 있는데 가물가물하네..

 

base network (MobileNetV2)

- 신경망(neural network)로 구성되어 있으며 분류(classification)나 탐지(detection)에 사용이 가능함

- 네트워크의 마지막에 softmax 레이어가 있으면 분류로 작동

 

detection network (Single Shot Detector or SSD)

- SSD(Single ShotDetection)나 RPN(Regional Proposal Network / R-CNN)를 이용하여

- 이미지 내의 여러 물체를 감지하고, 지역을 제안(ROI)함.

- R-CNN : Regions with Convolutional Neural Networks

[링크 : https://kr.mathworks.com/help/vision/ug/getting-started-with-r-cnn-fast-r-cnn-and-faster-r-cnn.html]

 

feature extractor (FPN-Lite)

SSD의 경우 너무 가깝거나(즉 너무 크거나, 일부만 확대되어 보일 경우) 작은경우(멀거나, 원래 작거나) 탐지를 못하는 경우가 있어

피라미드 모양으로 쌓은 FPN(Feature Pyramid Network)를 통해 특징을 추출하여 다양한 규모의 물체를 감지

 

SSD 에서는 Pyramid Feature Hierachy 라는 방식을 이용하여, 서로 다른 스케일의 특징 맵을 이용하여 멀티 스케일 특징을 추출

FPN 모델은 Region Proposeal Network (RPN) 와 Fast R-CNN을 기반으로 한다.

[링크 : https://eehoeskrap.tistory.com/300]

 

근데 내용만 봐서는 SSD + mobilenet v2 + FPN이 조합이 가능한건지 모르겠다?

 

In the MobileNetV2 SSD FPN-Lite, we have a base network (MobileNetV2), a detection network (Single Shot Detector or SSD) and a feature extractor (FPN-Lite).

Base network:
MobileNet, like VGG-Net, LeNet, AlexNet, and all others, are based on neural networks. The base network provides high-level features for classification or detection. If you use a fully connected layer and a softmax layer at the end of these networks, you have a classification.


 
Example of a network composed of many convolutional layers. Filters are applied to each training image at different resolutions, and the output of each convolved image is used as input to the next layer (source Mathworks)
But you can remove the fully connected and the softmax layers, and replace it with detection networks, like SSD, Faster R-CNN, and others to perform object detection.

Detection network:
The most common detection networks are SSD (Single Shot Detection) and RPN (Regional Proposal Network).
When using SSD, we only need to take one single shot to detect multiple objects within the image. On the other hand, regional proposal networks (RPN) based approaches, such as R-CNN series, need two shots, one for generating region proposals, one for detecting the object of each proposal.
As a consequence, SSD is much faster compared with RPN-based approaches but often trades accuracy with real-time processing speed. They also tend to have issues in detecting objects that are too close or too small.

Feature Pyramid Network:
Detecting objects in different scales is challenging in particular for small objects. Feature Pyramid Network (FPN) is a feature extractor designed with feature pyramid concept to improve accuracy and speed.

[링크 : https://docs.edgeimpulse.com/docs/edge-impulse-studio/learning-blocks/object-detection/mobilenetv2-ssd-fpn]

'프로그램 사용 > yolo_tensorflow' 카테고리의 다른 글

NMS, soft-NMS  (0) 2024.01.15
VGG-16 / VGG-19  (0) 2024.01.11
mobilenet v2 ssd  (0) 2024.01.11
ssd-mobilenetv2 on jupyter notebook  (2) 2024.01.10
텐서플로우 v1 을 v2로 마이그레이션은 실패 -_-  (0) 2024.01.10
Posted by 구차니