python(3)
-
PyQt와 OpenCV로 카메라 스트리밍 토글하기
그냥 반복에 반복하며 쓰고 있는 코드라서 정리할 겸 작성해봄. 목표 및 설계 연결된 카메라를 이용한 스트리밍을 토글할 수 있는 GUI 카메라 쓰레드는 파일을 따로 생성 cam_id로 특정 카메라 불러오기 (보통 0 또는 1) width, height, fps 설정할 수 있도록.. 1. 설치 pip install pyqt5 pip install opencv-python 2. 코딩 # main.py import sys from camera import CameraThread from PyQt5.QtGui import QPixmap from PyQt5.QtWidgets import ( QApplication, QMainWindow, QWidget, QVBoxLayout, QLabel, QPushButton, ..
2023.08.02 -
Dictionary 클래스 python 및 dart 구현
Problem) 아래 테스트 코드를 패스할 Dictionary 클래스를 만들기! from class_dict import Dictionary def test_dictionary(): # Create a new instance of Dictionary dictionary = Dictionary() # Test add and get methods dictionary.add('apple', 'A fruit that grows on trees.') assert dictionary.get('apple') == 'A fruit that grows on trees.' # Test showAll and count methods dictionary.add('banana', 'A long curved fruit.') di..
2023.07.15 -
Dart 시작하기 1. 변수 (Variables)
파이썬부터 시작한 나로서는 "void main() {}"구문이 꼭 있어야 코드를 실행할 수 있어야 한다는 점이 낯설었다. 굳이 파이썬에서 비슷한 구문을 찾으라면 "if __name__ == '__main__':"일 것이지만, 사실 파이썬에서는 이 구문 안써도 코드가 실행된다. 그리고 유의할 점은 코드마다 ';'(세미콜론)을 안쓰면 에러 뜬다. 주석을 쓰려면 Dart는 '//'를 쓰고, Python은 '#'을 쓴다. # Dart void main() { print('hello'); } # Python if __name__ == '__main__': print('hello') 본격적으로 Dart로 변수를 선언해보자. 파이썬과 다르게 변수명만으로 선언되지 않는다. 자료형(type)을 앞에 선언해줘야 하는데, ..
2023.02.04