div 정가운데 아이콘 배치

이미지
위 그림처럼 정 가운데 아이콘 배치하는 html + css 1. 방법 1 (html) <div class='wrapper'>   <i class='icon'></i> </div> (css) .wrapper{   position: relative;   width: 100%;   height: 100%;   display: inline-flex; } .icon {   margin: auto; }

Python + PIL + pyzbar로 바코드(CODE128)/QR코드 인식

0. 테스트환경 [앱] - React 16 - React native 0.55 - React native camera 현재기준최신 - 갤럭시 S8 [서버] - Ubuntu 16 - Python 3.6 - Flask 현재기준최신 (코드를 세로로 길게 배치하고 -> 앱에서 사진을 찍어 서버로 전송 -> 서버에서 코드를 인식해서 위에서부터 순서대로 decode해서 리턴함) 1. pyzbar https://pypi.org/project/pyzbar/ 에 나와있는대로 설치한다. 인식 자체는 zbar라는 c로 작성된 라이브러리를 사용한다. pyzbar는 zbar를 Python에서 사용할 수 있게 해주고 추가로 이미지 내 코드 위치를 제공한다. 2. Python image library(PIL) https://pillow.readthedocs.io/en/3.1.x/installation.html 에 나와있는대로 설치한다. 단순 인식이라면 이미지 처리를 할 필요는 없다. 한 파일 내에 raw data가 같은 바코드가 여러개 있으면 첫 번째(위)만 인식돼서 파일을 가로로 n개로 잘라서 사용하기로 했다. 3. 바코드/QR코드 인식 QR코드는 한 이미지 내에서 중복 인식하지만 전체적인 인식률이 낮고, 바코드는 중복 인식이 안되지만 인식률이 높은 것 같다. 아래는 이미지를 불러와 n등분하고 흑백이미지로 만들고 크기를 반으로 줄인 각각의 이미지에서 바코드/QR코드를 찾는 코드이다. from pyzbar.pyzbar import decode, ZBarSymbol from PIL import Image img = Image.open(파일이름) width, height = img.size n = (몇 등분 할것인지) unit = int(height/n) result = [] for i in range(n): cropped = img.crop((0, i*unit, width -1, i*unit...

Blockly 블럭 만들고 연결하기

1. 새 블럭 만들기 var childBlock = workspace.newBlock('BLOCKNAME') (workspace는 알아서 만들자) 2. 연결할 블럭 찾아오기 1) ID로 찾아오기 var parentBlock = workspace.getBlockById('ID') 2) index로 찾아오기 workspace.getAllBlocks()는 Block array를 리턴하므로 반복문으로 찾으면 된다. 3. 연결 1) 단순 연결 (A; B;) var childBlock = workspace.newBlock('BLOCKNAME') childBlock.initSvg() childBlock.render() parentBlock.nextConnecion.connect(childBlock.previousConnection) 2) 내부 연결(A { B;}) var childBlock  = workspace.newBlock('BLOCKNAME') childBlock.initSvg() childBlock.render() parentBlock.getInput('INPUTNAME').connection.connect(childBlock.previousConnection) INPUTNAME은 custom block을 만들 경우 직접 설정할 수 있고 Blockly demo 기준으로 DO0인 것 같다. block.inputList로 inpupt 목록을 가져올 수 있고 정확한 name을 확인해서 가져오면 된다.

React native camera + google vision barcode detection (android)

0. 테스트 스펙 - React 16.3.0 - React native 0.55.4 - Android studio 3.2.1 - Galaxy S8 + SDK 26 - Gradle 3.1.3 1. React native camera https://github.com/react-native-community/react-native-camera 이 페이지에 상세히 나와있으니 설치하면 된다. 2. 기본 바코드 읽기(onBarcodeReaded) React native camera에서 자체적으로 지원하는 바코드 읽기 기능. { data: ...,  rawData: ..., type: ..., bounds: ... } 형식의 object로 결과가 리턴된다. https://github.com/react-native-community/react-native-camera/blob/master/docs/RNCamera.md 상세는 이 페이지 참조. 리턴되는 bounds가 문서와 좀 다른 것 같다. 3. Google vision 사용한 바코드 읽기(onGoogleVisionBarcodesDetected) Google mobile vision을 사용한 바코드 읽기 기능. 읽어오는 바코드는 https://developers.google.com/android/reference/com/google/android/gms/vision/barcode/Barcode 이 페이지 참조. 기본 기능보다 빠르고 정확하지만 위치정보(이미지 내에서)를 알려주지 않는다. 그래서 위치정보를 숫자 배열로 받아오도록 수정. 1) node_modules\react-native-camera\android\src\main\java\org\reactnative\camera\BarcodesDetectedEvent.java의 serializeEventData method가 이벤트 발생 시 callback으로 리턴하는 데이터를 serialize하는 것 같다. ...

React-native 0.54 + OpenCV 3.4.3 + Android studio 3.2.1

1. 테스트 스펙 - Windows 10 - React-native 0.54 - OpenCV 3.4.3 - Android studio 3.2.1 - 갤럭시 S8(실기기) 2. React-native-opencv https://github.com/brainhubeu/react-native-opencv-tutorial 에서 소스를 clone 혹은 다운로드. 3. 2.의 페이지에서 시키는대로 한다. + openCVLibrary341을 openCVLibrary343으로. 다른 버전이라면 버전에 맞게 변경. + android\gradle\wrapper\gradle-wrapper.properties의 distributionUrl을 https\://services.gradle.org/distributions/gradle-4.4-all.zip 정도로 바꿔준다. + android\build.gradle > dependencies > classpath를 'com.android.tools.build:gradle:3.1.3' 정도로 바꿔준다. 4. 안된다. * react-native command가 없다. - npm install -g react-native-cli * google()이 없다.  - android\build.gradle의 buildscript > repositories, allprojects > repositories,에 google() 추가. google()이 jcenter() 보다 위에 와야한다는 말이 있다. * android.support.v4 has different version for the compile (에러 메시지 정확하지 않음)  - android\app\build.gradle > dependencies > implementation 'com.android.support:appcompat-v7:27.1.0' 정도로 수정 * Mod...

jsp:attribute must be the subelement of a standard or custom action 문제

이번 경우 <tag:base>   <c:set ......./>   <jsp:attribute><.jsp:attribute>   <jsp:attribute><.jsp:attribute>   <jsp:attribute><.jsp:attribute> </tag:base> 구조로 되어있어서 발생했다.(tag는 custom tag file) 아마 <jsp:attribute> 와 같은 레벨에 다른 태그가 있으면 안되는 듯 하다?   <c:set ......./>을 <jsp:attribute> 안으로 옮기니 해결되었다.

Linux screen 명령어 정리

1. screen -list : screen 목록 2. screen -S [name] : screen 생성. 중복된 이름도 가능하다. 그럴 경우 -list로 정확한 이름을 확인하고 접속 3. screen -x [name] : screen 접속(다중접속 가능). 다중 접속 중이면 보이는 크기가 작아진다. 이유는 모르겠음 4. screen -r [name] : screen 접속(다중접속 불가) 5. screen -X -S [name] quit : screen 삭제 6. (접속중) ctrl + a + d : 현재 screen 나오기 7. (접속중) ctrl + a, shift +f : 현재 screen 전체 화면으로 보기 8. (접속중) ctrl + a + [ : copy mode