묻고 답해요
164만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결[라즈베리파이] IoT 딥러닝 Computer Vision 실전 프로젝트
주차장차량세기 picamera
안녕하세요 주차장 차량세는거에 picamera를 작동시키고 싶어서 얼굴인식부분에서 파이카메라 불러오는 부분이랑 코드를 합치려고 하는데요 합치다보니 잘 안되가지고 질문 남깁니다 소스코드 import cv2 import numpy as np import time min_confidence = 0.5 margin = 30 file_name = "image/parking_03.jpg" # Load Yolo net = cv2.dnn.readNet("yolo/yolov3-tiny.weights", "yolo/yolov3-tiny.cfg") classes = [] with open("yolo/coco.names", "r") as f: classes = [line.strip() for line in f.readlines()] print(classes) layer_names = net.getLayerNames() output_layers = [layer_names[i[0] - 1] for i in net.getUnconnectedOutLayers()] # Loading image start_time = time.time() img = cv2.imread(file_name) height, width, channels = img.shape # Detecting objects blob = cv2.dnn.blobFromImage(img, 0.00392, (416, 416), (0, 0, 0), True, crop=False) net.setInput(blob) outs = net.forward(output_layers) # Showing informations on the screen confidences = [] boxes = [] for out in outs: for detection in out: scores = detection[5:] class_id = np.argmax(scores) confidence = scores[class_id] # Filter only 'car' if class_id == 2 and confidence > min_confidence: # Object detected center_x = int(detection[0] * width) center_y = int(detection[1] * height) w = int(detection[2] * width) h = int(detection[3] * height) # Rectangle coordinates x = int(center_x - w / 2) y = int(center_y - h / 2) boxes.append([x, y, w, h]) confidences.append(float(confidence)) indexes = cv2.dnn.NMSBoxes(boxes, confidences, min_confidence, 0.4) font = cv2.FONT_HERSHEY_PLAIN color = (0, 255, 0) for i in range(len(boxes)): if i in indexes: x, y, w, h = boxes[i] label = '{:,.2%}'.format(confidences[i]) print(i, label) cv2.rectangle(img, (x, y), (x + w, y + h), color, 2) cv2.putText(img, label, (x, y - 10), font, 1, color, 2) text = "Number of Car is : {} ".format(len(indexes)) cv2.putText(img, text, (margin, margin), font, 2, color, 2) cv2.imshow("Number of Car - "+file_name, img) end_time = time.time() process_time = end_time - start_time print("=== A frame took {:.3f} seconds".format(process_time)) # https://firebase.google.com/docs/admin/setup#prerequisites # https://firebase.google.com/docs/database/admin/start import firebase_admin from firebase_admin import credentials from firebase_admin import db from firebase_admin import storage # Fetch the service account key JSON file contents cred = credentials.Certificate('streetlamp-2e57a-firebase-adminsdk-gseyz-5b0121b783.json') # Initialize the app with a service account, granting admin privileges firebase_admin.initialize_app(cred, { 'databaseURL': 'https://streetlamp-2e57a-default-rtdb.firebaseio.com/', 'storageBucket': 'streetlamp-2e57a.appspot.com' }) bucket = storage.bucket() blob = bucket.blob(file_name) #blob.upload_from_filename( # file_name, # content_type='image/jpg' # ) blob.upload_from_filename(file_name) ref = db.reference('parking') box_ref = ref.child('west-coast') box_ref.update({ 'count': len(indexes), 'time': time.time(), 'image': blob.public_url }) cv2.waitKey(0) cv2.destroyAllWindows() 코드는 이렇게 합쳤는데 오류 코드는 밑과 같습니다. Traceback (most recent call last): File "/home/pi/rbp_dnn/RBP_DL21_YOLO_car.py", line 48, in <module> for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True): File "/usr/lib/python3/dist-packages/picamera/camera.py", line 1702, in capture_continuous if not encoder.wait(self.CAPTURE_TIMEOUT): File "/usr/lib/python3/dist-packages/picamera/encoders.py", line 395, in wait self.stop() File "/usr/lib/python3/dist-packages/picamera/encoders.py", line 419, in stop self._close_output() File "/usr/lib/python3/dist-packages/picamera/encoders.py", line 349, in _close_output mo.close_stream(output, opened) File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 371, in close_stream stream.flush() File "/usr/lib/python3/dist-packages/picamera/array.py", line 238, in flush self.array = bytes_to_rgb(self.getvalue(), self.size or self.camera.resolution) File "/usr/lib/python3/dist-packages/picamera/array.py", line 127, in bytes_to_rgb 'Incorrect buffer length for resolution %dx%d' % (width, height)) picamera.exc.PiCameraValueError: Incorrect buffer length for resolution 640x480 구글링해봤는데 해결이 안되서 올립니다 ㅜㅜ
-
미해결웹 게임을 만들며 배우는 React
ref 함수 부분 질문드립니다.
<input ref={(c) => { this.input = c;}} 이 부분에서 질문드릴 것이 두 가지 있습니다. 1. c가 의미하는 것이 무엇일까요? 파라미터로 아무거나 들어가도 되는 것인가요? 2. onSubmit 함수의 if 와 else의 마지막에 this.input.focus()를 한 이유가 무엇일까요..?
-
해결됨공공데이터로 파이썬 데이터 분석 시작하기
loc 함수
p = pd.pivot_table(df_last, index=["연도", "지역명"], values = "평당 분양가격") p.loc[2018] 코드에서 loc이 행을 기준으로 데이터를 보여준다고 하셨는데, print(p)인 경우 연도가 세로 열에 나옵니다. 이부분 설명 부탁드리겠습니다.
-
미해결작정하고 장고! Django로 Pinterest 따라만들기 : 바닥부터 배포까지
comment detail.html 에서 target_comment.pk 를 쓰지않는 이유는무엇인가요?
context_object_name 에서 target_comment 를 썻는데 delete.html 에서는 쓰고 detail.html 에서는 그냥 comment.pk 를 쓰셧는데 target_comment.pk 를 써도 문제가없나요?
-
미해결JIRA를 활용해 더 효과적으로 프로젝트 협업하기
릴리즈
릴리즈의 정의가 무엇인지모르겠습니다. 배포라고 이해하려니 감이잘안와서 쉽게 설명해주실수있으실까요?
-
미해결[C++과 언리얼로 만드는 MMORPG 게임 개발 시리즈] Part1: C++ 프로그래밍 입문
temp 내용 질문입니다!
저는 14:54초 쯤의 temp 메모리를 확인하는 부분에서 ccccccccccc 이외의 값들도 들어가 있는데 컴파일러마다 다른 부분인 걸까요??
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
교수님 1개 추가로 적어주셨으면합니다. (junit5사용자 한에서)
Junit4에서실습이라면 상관없지만 만약 Junit5에서 실습이라면 import org.junit.runner.RunWith; @RunWith(SpringRunner.class) 이 2개를 import org.junit.jupiter.api.extension.ExtendWith;@ExtendWith(SpringExtension.class) 이런식으로 바꾸고하니 가능했습니다.
-
미해결실전! 스프링 부트와 JPA 활용2 - API 개발과 성능 최적화
ObjectOptimisticLockingFailureException
안녕하세요. 좋은 강의 제공해주셔서 감사합니다. 지금은 강의를 바탕으로 개발을 진행하고 있는데요. 궁금한 점이 생겨서 질문을 남겨봅니다. Spring Boot에 spring-data-jpa를 사용하고 있습니다. 2개의 API가 동시에 들어와 같은 row를 삭제하는 상황입니다. 이 때, 하나의 트랜잭션에서 ObjectOptimisticLockingFailureException이 발생하는데요. select한 값에 대해서 다른 트랜잭션이 이미 delete하여 delete할 row가 없다는 에러로 확인했는데요. 보통 spring-data-jpa로 delete하실 때, jpql을 사용해서 바로 delete native query가 날라가게 하시는지, 아니면 해당 에러를 따로 처리하는 방법이 있으신지 궁금합니다.
-
해결됨스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술
안녕하세요 타임리프 질문입니다
이거 두개가 다른건가요?? 밑에껀 안되네요 ㅜㅜ 앞의 회원id 상품명 링크에서 th:href="@{/basic/items/{itemId}(itemId=${item.id})}" th:text="${item.id}"> - > th:href="@{|/basic/items/${item.id}|}" th:text="${item.itemName}"> 는 됐었는데 안되는 이유가 궁금합니다..ㅜㅜ th:onclick="|location.href='@{/basic/items/{itemId}/edit(itemId=${item.id})}'|"th:onclick="|location.href='@{/basic/items/${item.id}/edit}'|"
-
해결됨스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술
css 위치 질문입니다.
안녕하세요! thymeleaf를 사용해서 동적으로 사용할 때 <link th:href="@{/css/bootstrap.min.css}" href="../css/bootstrap.min.css" rel="stylesheet"> 이렇게 사용되고 있는데 templates/basic/items.html 에서 열어서 /css/bootstrap.min.css 라고 바뀌었을때 css의 위치는 static/css/ 에 위치하고있는데 어떻게해서 열릴수있는건가요..?
-
미해결[개정판] 딥러닝 컴퓨터 비전 완벽 가이드
MMDetection의 이해와 Faster RCNN 적용 실습 에서 No module named 'mmdet.datasetsasets'
안녕하십니까! 수업 감사히 잘 듣고 있습니다. * PC로 학습을 진행하고 있습니다. 환경은 아래와 같습니다. - GPU : GeForce GTX 105... (nvidia-smi) - cuda_11.0.3_450.51.06_linux.run 설치 - cudnn cudnn-11.0-linux-x64-v8.0.5.39.tgz 설치 - Anaconda : Anaconda3-2019.10-Linux-x86_64.sh 설치 - ananconda 가상환경 구성 - jupyter notebook 설치, 환경 설정 - 가상환경 activate -> jupyter multi kernel 설치 - pytorch 설치 : pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html - pip install mmcv-full - git clone https://github.com/open-mmlab/mmdetection.git - cd mmdetection; python setup.py install => faster-rcnn의 학습(train)을 수행하고 예측(inferencd)을 잘 구현하였습니다. 그리고 mask-rcnn을 학습(수강)하였습니다. (새로운 가상환경 생성 후 학습) => mask-rcnn을 학습하고 와서 faster-rcnn의 소스를 정리하기 위해 잘 작동하던 소스를 실행 시키보니 아래와 같은 오류가 발생하였습니다. ======================================================================= --------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) /tmp/ipykernel_1654/2266340391.py in <module> 6 import numpy as np 7 ----> 8 from mmdet.datasetsasets.builder import DATASETS 9 from mmdet.datasets.custom import CustomDataset 10 ModuleNotFoundError: No module named 'mmdet.datasetsasets' ======================================================================= - pip install mmcv-full 과 python setup.py install 을 다시 실행해도 안되네요. - 그리고 새로운 가상환경을 구축하고 이전과 동일하게 환경 잡고 해봐도 동일한 오류가 발생합니다. 답변 부탁드립니다.
-
미해결[리뉴얼] React로 NodeBird SNS 만들기
npm run dev 할 때의 오류
서버를 켜기 위해 npm run dev를 입력했는데 다음과 같은 오류가 떴습니다 ㅜ missing script: dev A complete log of this run can be found in: 이 다음으로 어떤 경로가 나옵니다 그 전에는 잘 되다가 "unable to attach to brower" 라는 에러 메세지가 뜨고 나서는 npm run dev를 입력하면 위와 같은 에러 메세지가 뜨는데 어떻게 해야 하나요...?
-
미해결따라하며 배우는 도커와 CI환경 [2023.11 업데이트]
오류 해결 방법 공유합니다.
FROM node:alpine RUN mkdir -p /usr/src/app/node_modules/.cache RUN chmod -R 777 /usr/src/app WORKDIR /usr/src/app COPY package.json ./ RUN npm install COPY ./ ./ CMD ["npm", "run", "start"] 오류 내용: EACCES: permission denied, mkdir '/usr/src/app/node_modules/.cache' 해결 방법: WORKDIR 을 설정하기 전에, 디렉토리를 만들고 접근 권한을 부여했습니다. 학습 용도기 때문에 777(모두허용)했지만, 배포 상황에서는 상황에 맞게 권한을 부여해야겠죠?
-
미해결[리뉴얼] 처음하는 MongoDB(몽고DB) 와 NoSQL(빅데이터) 데이터베이스 부트캠프 [입문부터 활용까지] (업데이트)
부분 문자열 검색 관련
안녕하세요, 항상 좋은 강의 감사합니다. 이번 강의를 듣고나니, 부분문자열을 검색할 때에 $regex 을 활용해서 검색하는 것이, text index 파일을 만들지 않아도 되고, 또 다양한 정규표현식 문법으로 검색할 수 있어 더 효율적이라고 생각이 듭니다. 근데 그럼에도 text index를 통해 부분문자열을 검색하는 이유가 무엇인지 궁금합니다. 그리고 실제 일을 할때에는 어떤 방법을 더 많이 활용하는지도 궁금합니다.
-
미해결실전! Querydsl
List 를 Map으로 변환할 수 있을까요?
List<MemberDto> 조회 결과를 Map형태로 변경해서 받을 수는 있나요??
-
미해결파이썬 무료 강의 (활용편1) - 추억의 오락실 게임 만들기 (3시간)
똑같이 따라 쳤는데 오류가 생겨요
나도코딩님처럼 똑같이 쳤는데 NameError: name 'ball_to_remove' is not defined 이런 오류가 떠여 도와주세요 ㅠㅠ import os import pygame ######################################################### # 기본 초기화 (반드시 해야 하는 것들) pygame.init() # 초기화 (반드시 필요) # 화면 크기 설정 screen_width = 640 # 가로 크기 screen_height = 480 # 세로 크기 screen = pygame.display.set_mode((screen_width, screen_height)) # 화면 타이틀 설정 pygame.display.set_caption("서준이의 게임2") #게임 이름 # FPS clock = pygame.time.Clock() ######################################################### # 1. 사용자 게임 초기화 (배경 화면, 게임 이미지, 좌표, 속도, 폰트 등) current_path = os.path.dirname(__file__) # 현재 파일의 위치 반환 image_path = os.path.join(current_path, "images") # images 폴더 위치 반환 # 배경 만들기 background = pygame.image.load(os.path.join(image_path, "background.png")) # 스테이지 만들기 stage = pygame.image.load(os.path.join(image_path, "stage.png")) stage_size = stage.get_rect().size stage_height = stage_size[1] # 스테이지의 높이 위에 캐릭터를 두기 위해 사용 # 캐릭터 만들기 character = pygame.image.load(os.path.join(image_path, "character.png")) character_size = character.get_rect().size character_width = character_size[0] character_height = character_size[1] character_x_pos =(screen_width /2) - (character_width /2) character_y_pos = screen_height - character_height - stage_height # 캐릭터 이동 방향 character_to_x = 0 # 캐릭터 이동 속도 character_speed = 5 # 무기 만들기 weapon = pygame.image.load(os.path.join(image_path, "weapon.png")) weapon_size = weapon.get_rect().size weapon_width = weapon_size[0] # 무기는 한 번에 여러 발 발사 가능 weapons = [] # 무기 이동 속도 weapon_speed = 10 # 공 만들기 (4개 크기에 대해 따로 처리) ball_images = [ pygame.image.load(os.path.join(image_path, "balloon1.png")), pygame.image.load(os.path.join(image_path, "balloon2.png")), pygame.image.load(os.path.join(image_path, "balloon3.png")), pygame.image.load(os.path.join(image_path, "balloon4.png"))] # 공 크기에 따른 최초 스피드 ball_speed_y = [-18, -15, -12, -9] # index 0, 1, 2, 3 에 해당하는 값 # 공들 balls= [] # 최초 발생하는 큰 공 추가 balls.append({ "pos_x" : 50, # 공의 x 좌표 "pos_y" : 50, # 공의 y 좌표 "img_idx" : 0, # 공의 이미지 인덱스 "to_x": 3, # x축 이동방향, -3 이면 왼쪽으로, 3 이면 오른쪽으로 "to_y": -6, # y축 이동방향, "init_spd_y": ball_speed_y[0]})# y 최초 속도 # 사라질 무기, 공 정보 저장 변수 weapon_to_remove = -1 ball_to_remvoe = -1 running = True while running: dt = clock.tick(60) # 2. 이벤트 처리 (키보드, 마우스 등) for event in pygame.event.get(): if event.type == pygame.QUIT: running = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT: # 캐릭터를 왼쪽으로 character_to_x -= character_speed elif event.key == pygame.K_RIGHT: # 캐릭터를 오른쪽으로 character_to_x += character_speed elif event.key == pygame.K_SPACE: # 무기 발사 weapon_x_pos = character_x_pos + (character_width / 2) - (weapon_width / 2) weapon_y_pos = character_y_pos weapons.append([weapon_x_pos, weapon_y_pos]) if event.type == pygame.KEYUP: if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT: character_to_x = 0 # 3. 게임 캐릭터 위치 정의 character_x_pos += character_to_x if character_x_pos < 0: character_x_pos = 0 elif character_x_pos > screen_width - character_width: character_x_pos = screen_width - character_width # 무기 위치 조정 # 100, 200 -> 180, 160, 140, ... # 500, 200 -> 180, 160, 140, ... weapons = [ [w[0], w[1] - weapon_speed] for w in weapons] # 무기 위치를 위로 # 천장에 닿은 무기 없애기 weapons = [ [w[0], w[1]] for w in weapons if w[1] > 0] # 공 위치 정의 for ball_idx, ball_val in enumerate(balls): ball_pos_x = ball_val["pos_x"] ball_pos_y = ball_val["pos_y"] ball_img_idx = ball_val["img_idx"] ball_size = ball_images[ball_img_idx].get_rect().size ball_width = ball_size[0] ball_height = ball_size[1] # 가로벽에 닿았을 때 공 이동 위치 변경 (튕겨 나오는 효과) if ball_pos_x < 0 or ball_pos_x > screen_width - ball_width: ball_val["to_x"] = ball_val["to_x"] * -1 # 세로 위치 # 스테이지에 튕겨서 올라가는 처리 if ball_pos_y >= screen_height - stage_height - ball_height: ball_val["to_y"] = ball_val["init_spd_y"] else: # 그 외의 모든 경우에는 속도를 증가 ball_val["to_y"] += 0.5 ball_val["pos_x"] += ball_val["to_x"] ball_val["pos_y"] += ball_val["to_y"] # 4. 충돌 처리 # 캐릭터 rect 정보 업데이트 character_rect = character.get_rect() character_rect.left = character_x_pos character_rect.top = character_y_pos for ball_idx, ball_val in enumerate(balls): ball_pos_x = ball_val["pos_x"] ball_pos_y = ball_val["pos_y"] ball_img_idx = ball_val["img_idx"] # 공 rect 정보 업데이트 ball_rect = ball_images[ball_img_idx].get_rect() ball_rect.left = ball_pos_x ball_rect.top = ball_pos_y # 공과 캐릭터 충돌 처리 if character_rect.colliderect(ball_rect): running = False break # 공과 무기들 충돌 처리 for weapon_idx, weapon_val in enumerate(weapons): weapon_pos_x = weapon_val[0] weapon_pos_y = weapon_val[1] # 무기 rect 정보 업데이트 weapon_rect = weapon.get_rect() weapon_rect.left = weapon_pos_x weapon_rect.top = weapon_pos_y # 충돌 체크 if weapon_rect.colliderect(ball_rect): weapon_to_remove = weapon_idx # 해당 무기 없애기 위한 값 설정 ball_to_remove = ball_idx # 해당 공 없애기 위한 값 설정 break # 충돌된 공 or 무기 없애기 if ball_to_remove > -1: del balls[ball_to_remove] ball_to_remove = -1 if weapon_to_remove > -1: del weapons[weapon_to_remove] weapon_to_remove = -1 # 5. 화면에 그리기 screen.blit(background, (0, 0)) for weapon_x_pos, weapon_y_pos in weapons: screen.blit(weapon, (weapon_x_pos, weapon_y_pos)) for idx,val in enumerate(balls): ball_pos_x = val["pos_x"] ball_pos_y = val["pos_y"] ball_img_idx = val["img_idx"] screen.blit(ball_images[ball_img_idx], (ball_pos_x, ball_pos_y)) screen.blit(stage, (0, screen_height - stage_height)) screen.blit(character, (character_x_pos, character_y_pos)) pygame.display.update() pygame.quit()
-
미해결자바 ORM 표준 JPA 프로그래밍 - 기본편
mappeby 질문있습니다.
mappeby = "team" 에서 규칙이 외래키를 가지고 있는 연관관계 주인에서 (member)에서 외래키를 가지고 있는 필드명 을(team)을 mappeby 뒤에 적어주면 되는것인가요???
-
미해결모든 개발자를 위한 HTTP 웹 기본 지식
delete, patch에 대해서
안녕하세요 영한님 좋은 강의 해주셔서 감사합니다! 만약, 사이트 내에 member가 탈퇴했을 때 실제 db에서 member를 지우지는 말고 member 테이블의 delete_type 칼럼을 1로 바꿔주세요 라는 요구사항이 들어왔다면 이 경우에는 요청 api를 URI : members/{id} METHOD : DELETE 로 하는게 맞을까요? 아니면 URI : members/{id} METHOD : PATCH 로 해야 하는게 맞을까요?
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
build 에러
안녕하세요. 빌드시 에러가 나는데 내용은 다음과 같습니다. testcase를 작성한게 없는데 test에서 에러가 난다니.. 우선은 test를 제외하고 build하니 빌드가 되긴 했는데 왜 그런지 이유를 모르겠습니다.. > Task :test FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':test'. > There were failing tests. See the report at: file:///D:/★spring%20공부/study/hello-spring-again/hello-spring-again/build/reports/tests/test/index.html
-
해결됨탄탄한 백엔드 NestJS, 기초부터 심화까지
TypeORM내용도 해당 강좌에 포함되었으면 합니다!
기존 자바,스프링 개발 하다가 해당 강의 약 절반정도 진행 하였는데 TypeORM에 대한 내용은 빠진 것 같아서, 해당 내용도 강좌에 포함되었으면 합니다~! 실무에서는 주로 Nest.JS를 어떤 조합으로 사용하는지도 궁금합니다. :]