묻고 답해요
164만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결쉽고 빠르게 끝내는 GO언어 프로그래밍 핵심 기초 입문 과정
[재 질문2]구조체가 참조형 인가요
구조체가 참조형이라는게 알려주신 소스를 보고는 파악이 안됩니다. 슬라이스나 맵을 함수에 인자로 전달 하면 무조건 메모리 주소가 전달 되니 참조형 이라는 건 알겠는데 구조체는 변수나 배열처럼 값으로도 참조형으로도 전달 할 수 있으니 참조형도 가능하고 데이타 형도 가능하다고 해야 하지 않나 생각을 합니다만 제가 잘 못 이해하고 있는건가요 바쁘신 중에 죄송합니다만 답변 부탁 드립니다.
-
미해결자바 ORM 표준 JPA 프로그래밍 - 기본편
연관관계 편의메소드 관련 질문이 있습니다.
Member를 Team을 추가 할 때 public void setTeam (Team team){ this.team = team team.getMembers().add(this) } 위와 같이 연관관계 편의 메서드를 만드셨는데, 제거 할 때도 위와 같이 양쪽에서 동시에 제거하는 메소드를 만드시는지 궁금합니다. 제가 실습중인 코드에서는 delete : /team/{team_id}/member/{member_id} 로 api를 호출하면 아래 메소드가 호출됩니다. public void removeMember (Long team_id, Long member_id){ Team team = validateTeam(team_id); //team 이 실제로 있는지 확인 Member member = validateMember(member_id); //member 가 실제로 있는지 확인 if(team.equals(member.getTeam())){ //의문점 team.getTeam().remove(member); memberRepository.deleteById(member.getId) } } Team에 Member를 추가 할 때와 같이 Member를 제거 할 때도 양쪽에서 같이 제거해야하는지 그리고 entity에서 remove관련 편의메소드를 만들어야하는지 궁금합니다.
-
미해결Vue.js 완벽 가이드 - 실습과 리팩토링으로 배우는 실전 개념
클론 어떻게 성공하긴 했는데 궁금한 점이 있습니다.
레포 찾을 수 없는 경우의 해결방안에 ssh키 등록이 있길래, 혹시나 해서 등록해보고, git clone git@github.com:joshua1988/vue-advanced.git 이렇게 쳐서 클론 성공했어요ㅠㅠㅠㅠㅠ 근데 ssh키와 클론 가능여부가 상관이 있나요? 그리고 ssh키 등록하고도 그냥 선생님의 깃헙 주소를 복사했을 때는 안됐는데요. 다른 분들과 다르게, 그대로 복사하면 안되고 git@github.com:joshua1988/vue-advanced.git 이 주소를 쳐야 가능했던 이유가 무엇일까요?? 해결은 했지만 잘 이해가 안됩니다ㅜㅜ
-
미해결쉽고 빠르게 끝내는 GO언어 프로그래밍 핵심 기초 입문 과정
[재 질문]구조체가 참조형 인가요
알려주신 링크를 봐도 제가 잘 이해를 못하는건지 구조체 자체가 참조형이라는 정확한 설명이 없는거 같습니다만..혹시 mutable개체 라는게 참조형이라는 건지요? 강의 중에 구조체를 %v로 출력 해 보면 &가 붙어서 출력이 되기에 구조체 라고 들었습니다만...잘 이해가 안되는데 강사님의 생각을 알려주시면 감사하겠습니다.
-
미해결[개정판] 파이썬 머신러닝 완벽 가이드
loc 슬라이싱
loc 인덱싱시에 명칭기반 해석시, 1:2에서 앞의수는 포함 뒤에수는 미포함 아닌가요? 왜 2개가 나오는지 궁금합니다. ix 인덱싱시에는 같은 명칭기반으로 1:2가 1포함, 2 미포함으로 해석이 된것같아서 헷갈립니다.. ㅜㅜ
-
미해결워드프레스 제대로 개발하기 - 어드민 편
네임스페이스 중복을 회피하신다고 한부분이 궁금합니다.
(function () { }()); 이거 쓰면서 언급하신 부분이 궁금하네요. 정확히 왜 쓰는건지요?
-
미해결Vue.js 중급 강좌 - 웹앱 제작으로 배워보는 Vue.js, ES6, Vuex
git 권한 요청합니다.
id : jtyang0227@gmail.com
-
미해결OpenCV 를 활용한 명함인식 기능 구현 강좌
강의 마지막 예제에서 다음과 같은 에러가 발생합니다.
images/scannedImage.png only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices코드는 아래와 같습니다.# (참고) OpenCV - 이미지에서 텍스트 영역만 찾아내기 # 출처: http://www.danvk.org/2015/01/07/finding-blocks-of-text-in-an-image-using-python-opencv-and-numpy.html import glob import os import random import sys import random import math import json from collections import defaultdict import cv2 from PIL import Image, ImageDraw import numpy as np from scipy.ndimage.filters import rank_filter def dilate(ary, N, iterations): """Dilate using an NxN '+' sign shape. ary is np.uint8.""" kernel = np.zeros((N,N), dtype=np.uint8) kernel[(N-1)/2,:] = 1 dilated_image = cv2.dilate(ary / 255, kernel, iterations=iterations) kernel = np.zeros((N,N), dtype=np.uint8) kernel[:,(N-1)/2] = 1 dilated_image = cv2.dilate(dilated_image, kernel, iterations=iterations) dilated_image = cv2.convertScaleAbs(dilated_image) return dilated_image def props_for_contours(contours, ary): """Calculate bounding box & the number of set pixels for each contour.""" c_info = [] for c in contours: x,y,w,h = cv2.boundingRect(c) c_im = np.zeros(ary.shape) cv2.drawContours(c_im, [c], 0, 255, -1) c_info.append({ 'x1': x, 'y1': y, 'x2': x + w - 1, 'y2': y + h - 1, 'sum': np.sum(ary * (c_im > 0))/255 }) return c_info def union_crops(crop1, crop2): """Union two (x1, y1, x2, y2) rects.""" x11, y11, x21, y21 = crop1 x12, y12, x22, y22 = crop2 return min(x11, x12), min(y11, y12), max(x21, x22), max(y21, y22) def intersect_crops(crop1, crop2): x11, y11, x21, y21 = crop1 x12, y12, x22, y22 = crop2 return max(x11, x12), max(y11, y12), min(x21, x22), min(y21, y22) def crop_area(crop): x1, y1, x2, y2 = crop return max(0, x2 - x1) * max(0, y2 - y1) def find_border_components(contours, ary): borders = [] area = ary.shape[0] * ary.shape[1] for i, c in enumerate(contours): x,y,w,h = cv2.boundingRect(c) if w * h > 0.5 * area: borders.append((i, x, y, x + w - 1, y + h - 1)) return borders def angle_from_right(deg): return min(deg % 90, 90 - (deg % 90)) def remove_border(contour, ary): """Remove everything outside a border contour.""" # Use a rotated rectangle (should be a good approximation of a border). # If it's far from a right angle, it's probably two sides of a border and # we should use the bounding box instead. c_im = np.zeros(ary.shape) r = cv2.minAreaRect(contour) degs = r[2] if angle_from_right(degs) <= 10: box = cv2.boxPoints(r) box = np.int0(box) cv2.drawContours(c_im, [box], 0, 255, -1) cv2.drawContours(c_im, [box], 0, 0, 4) else: x1, y1, x2, y2 = cv2.boundingRect(contour) cv2.rectangle(c_im, (x1, y1), (x2, y2), 255, -1) cv2.rectangle(c_im, (x1, y1), (x2, y2), 0, 4) return np.minimum(c_im, ary) def find_components(edges, max_components=16): """Dilate the image until there are just a few connected components. Returns contours for these components.""" # Perform increasingly aggressive dilation until there are just a few # connected components. count = 21 dilation = 5 n = 1 while count > 16: n += 1 dilated_image = dilate(edges, N=3, iterations=n) #_, contours, hierarchy = cv2.findContours(dilated_image, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) contours, hierarchy = cv2.findContours(dilated_image, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) count = len(contours) #print dilation #Image.fromarray(edges).show() #Image.fromarray(255 * dilated_image).show() return contours def find_optimal_components_subset(contours, edges): """Find a crop which strikes a good balance of coverage/compactness. Returns an (x1, y1, x2, y2) tuple. """ c_info = props_for_contours(contours, edges) c_info.sort(key=lambda x: -x['sum']) total = np.sum(edges) / 255 area = edges.shape[0] * edges.shape[1] c = c_info[0] del c_info[0] this_crop = c['x1'], c['y1'], c['x2'], c['y2'] crop = this_crop covered_sum = c['sum'] while covered_sum < total: changed = False recall = 1 * covered_sum / total prec = 1 - 1 * crop_area(crop) / area f1 = 2 * (prec * recall / (prec + recall)) #print '----' for i, c in enumerate(c_info): this_crop = c['x1'], c['y1'], c['x2'], c['y2'] new_crop = union_crops(crop, this_crop) new_sum = covered_sum + c['sum'] new_recall = 1 * new_sum / total new_prec = 1 - 1 * crop_area(new_crop) / area new_f1 = 2 * new_prec * new_recall / (new_prec + new_recall) # Add this crop if it improves f1 score, # _or_ it adds 25% of the remaining pixels for <15% crop expansion. # ^^^ very ad-hoc! make this smoother remaining_frac = c['sum'] / (total - covered_sum) new_area_frac = 1 * crop_area(new_crop) / crop_area(crop) - 1 if new_f1 > f1 or ( remaining_frac > 0.25 and new_area_frac < 0.15): print('%d %s -> %s / %s (%s), %s -> %s / %s (%s), %s -> %s' % ( i, covered_sum, new_sum, total, remaining_frac, crop_area(crop), crop_area(new_crop), area, new_area_frac, f1, new_f1)) crop = new_crop covered_sum = new_sum del c_info[i] changed = True break if not changed: break return crop def pad_crop(crop, contours, edges, border_contour, pad_px=15): """Slightly expand the crop to get full contours. This will expand to include any contours it currently intersects, but will not expand past a border. """ bx1, by1, bx2, by2 = 0, 0, edges.shape[0], edges.shape[1] if border_contour is not None and len(border_contour) > 0: c = props_for_contours([border_contour], edges)[0] bx1, by1, bx2, by2 = c['x1'] + 5, c['y1'] + 5, c['x2'] - 5, c['y2'] - 5 def crop_in_border(crop): x1, y1, x2, y2 = crop x1 = max(x1 - pad_px, bx1) y1 = max(y1 - pad_px, by1) x2 = min(x2 + pad_px, bx2) y2 = min(y2 + pad_px, by2) return crop crop = crop_in_border(crop) c_info = props_for_contours(contours, edges) changed = False for c in c_info: this_crop = c['x1'], c['y1'], c['x2'], c['y2'] this_area = crop_area(this_crop) int_area = crop_area(intersect_crops(crop, this_crop)) new_crop = crop_in_border(union_crops(crop, this_crop)) if 0 < int_area < this_area and crop != new_crop: print('%s -> %s' % (str(crop), str(new_crop))) changed = True crop = new_crop if changed: return pad_crop(crop, contours, edges, border_contour, pad_px) else: return crop def downscale_image(im, max_dim=2048): """Shrink im until its longest dimension is <= max_dim. Returns new_image, scale (where scale <= 1). """ a = im.shape[0] b = im.shape[1] if max(a, b) <= max_dim: return 1, im scale = 1 * max_dim / max(a, b) dim = (int(a * scale), int(b * scale)) new_im = cv2.resize(im, dim, interpolation = cv2.INTER_AREA) return scale, new_im def process_image(path, out_path): orig_im = Image.open(path) im = cv2.imread(path, cv2.IMREAD_GRAYSCALE) scale, im = downscale_image(im) edges = cv2.Canny(im, 100, 200) # TODO: dilate image _before_ finding a border. This is crazy sensitive! #_, contours, hierarchy = cv2.findContours(edges, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) contours, hierarchy = cv2.findContours(edges, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) borders = find_border_components(contours, edges) borders.sort(key=lambda i_x1_y1_x2_y2: (i_x1_y1_x2_y2[3] - i_x1_y1_x2_y2[1]) * (i_x1_y1_x2_y2[4] - i_x1_y1_x2_y2[2])) border_contour = None if len(borders): border_contour = contours[borders[0][0]] edges = remove_border(border_contour, edges) edges = 255 * (edges > 0).astype(np.uint8) # Remove ~1px borders using a rank filter. maxed_rows = rank_filter(edges, -5, size=(1, 20)) maxed_cols = rank_filter(edges, -5, size=(20, 1)) debordered = np.minimum(np.minimum(edges, maxed_rows), maxed_cols) edges = debordered contours = find_components(edges) if len(contours) == 0: print('%s -> (no text!)' % path) return crop = find_optimal_components_subset(contours, edges) crop = pad_crop(crop, contours, edges, border_contour) crop = [int(x / scale) for x in crop] # upscale to the original image size. # draw and show cropped rectangle area in the original image rgb_im = orig_im.convert('RGB') draw = ImageDraw.Draw(rgb_im) draw.rectangle(crop, outline='red') rgb_im.show() text_im = orig_im.crop(crop) text_im.show() text_im.save(out_path) print('%s -> %s' % (path, out_path)) if __name__ == '__main__': # path = 'images/text.jpg' path = 'images/scannedImage.png' out_path = 'croppedImage.png' try: process_image(path, out_path) except Exception as e: print('%s %s' % (path, e))
-
미해결[개정판] 파이썬 머신러닝 완벽 가이드
cross_val_score, GridSearchCV에서 cv 값
안녕하세요. 위 함수/모듈에서 cv값을 정하게 되면 train, test를 나누는 방법은 KFold인건지요? 만약 그렇다면, StratifiedKFold로 하려면 다른 방법이 있을까요?
-
미해결취미로 해킹#1(OverTheWire - Bandit)
밴딧 초반 ssh 접속문제
현재 칼리사용하고 있으며 ssh접속시도를 하면 저렇게 세션이 끊기듯이 보이는데 인터넷에서 찾아보고 해결을 해보려고 해도 안되네요 (xshell도 동일한 현상) 혹 다른 해결방안은 있나요?
-
미해결리눅스 커맨드라인 툴
다른 강좌는 생각 없으신가요??
선생님 혹시 커널쪽으로 강좌를 해주실 생각은 없으신가요 시스템프로그래밍까지 하니 커널도 건드려 보고 싶은데 어려워서요 ㅠㅜ
-
미해결React로 NodeBird SNS 만들기
next를 사용하면,
next를 사용하면 기본적으로는 서버사이드 렌더링을 하는 것이 맞는지 궁금합니다. 기본 리액트 앱의 소스보기를 누르면 소스 보기에 내용 부분에 아무것도 나오지 않는 반면에, next로 만든 리액트 앱은 비동기로 불러와야 할 데이터를 빼면 태그들이 다 나오는 것 때문에 궁금합니다. - next는 기본적으로 ssr을 하는데, getinitialprops으로 조금 더 빨리 데이터를 붙여줄 수 있는 것인가요 - 아니면 getinitialprops을 사용함으로써 ssr을 할 수 있게 되는 것인가요?
-
해결됨Java TPC (생각하고, 표현하고, 코딩하고)
자바 설정중에 자바버젼 질문이요
안녕하세요, 꼭 자바 12로 설정해야하나요? 또는 1.8로 해도 상관 없나요?
-
미해결웹퍼블리셔가 알려주는 실무 웹사이트 따라만들기 Season1
[질문] css 임포트
안녕하세요. 따라서 하고 있는데요. 첫번째 동영상 강의에서 images 폴더까지 생성했는데, 두번째 동영상 강의 7:44 분정도에서 갑자기 css폴더가 생겨있는데, 제가 혹시 뭐 놓치고 있는건가요? css import를 하는건 알겠는데 저 파일이 갑자기 어디서 튀어나왔는지 모르겠어요..
-
미해결Klaytn 클레이튼 블록체인 어플리케이션 만들기 - NFT
[참고] Npm run dev 오류
Npm run dev 실행시 다음같은 오류가 발생할 경우 internal/modules/cjs/loader.js:638 throw err; Error: Cannot find module "acorn" 제 경운 acron 설치로 해결 됐습니다. 이외 방법 있으시면 공유 바랍니다 npm install -- save acorn
-
미해결프로그래밍 시작하기 : 파이썬 입문 (Inflearn Original)
자릿수 질문 입니다
print('%06.2f' % (3.1415926535))를 실행하면 003.14가 나온다고 하셨는데요, 여기서 06.2f에서 6은 자릿수를 나타 내는 것인가요. 그렇다면 003.14에서 '.'도 자릿수에 포함되는 것으로 치는 것인가요?
-
미해결직접 만드는 노션 템플릿 BEST 7선
꿀팁 모음 강의는 재생이 안되는데 오류일까요?
꿀팁 모음 강의는 재생이 안되는데 오류일까요?
-
미해결디자인 패턴 with JAVA (GoF)
TestPattern2 질문
TestPattern2 실행시 [8번째 8번째 7번째 2번째 9번째 10번째 8번째 8번째 4번째 4번째] 이런식으로 console에 출력됩니다 .
-
미해결Vue.js 완벽 가이드 - 실습과 리팩토링으로 배우는 실전 개념
gist 로그인 되어있는데 여전히 clone이 안됩니다ㅜㅜ
깃헙 로그인이 되어있는데도 안되는 이유를 모르겠어요..ㅜㅜ
-
미해결Illustrator CC - 일러스트레이터 입문부터 실전까지 한번에 마스터하기
예제파일이 안 열리는데 어떻게 해야하나요?
오류가 계속 뜨네요ㅠ