글

macOS Xcode에서 OpenCV 사용하기

이미지
macOS Xcode에서 OpenCV 사용하기 macOS에 OpenCV 설치 방법은 구글링을 통해 쉽게 빌드 및 설치가 가능하다. 이 포스팅에서는 간단하게 https://github.com/opencv/opencv에서 소스를 받아 빌드하고 설치하는 방법과 더불어 Xcode에서 빌드된 OpenCV 라이브러리 사용 방법을 소개한다. 1. macOS 및 iOS 플랫폼 OpenCV 빌드 및 설치 OpenCV을 GitHub에서 다운로드 받을 디렉토리로 이동해서 다음과 같이 clone 후 빌드 및 설치를 하면 된다. git과 cmake 툴은 미리 설치되어야 한다. 1.1 opencv git clone $mkdir ~/git $cd ~/git $git clone https://github.com/opencv/opencv.git $cd opencv 1.2 macOS: cmake을 이용한 라이브러리 빌드 및 설치 $mkdir build $cd build $cmake .. $sudo make install 빌드 후에는 헤더파일과 라이브러리 파일은 각각 /usr/local/include 와 /usr/local/lib 에 복사가 된다. 1.3 macOS: python을 이용한 framework 빌드 python을 이용한 빌드에서는 QT UI 라이브러리도 설치되 $python platforms/osx/build_framework.py macOS 1.4 iOS: python을 이용한 framework 빌드 iOS 빌드 방법은 다음과 같다. 빌드가 완료되면 ~/git/opencv/ios 디렉터리에  opencv2.framework 이 생성된다. $python platforms/ios/build_framework.py ios 현재 OpenCV 3.1 iOS 버전은 png 라이브러리를 사용할 때 다음과 같이 링크 에러가 발생할 수 있다. 'Undefined symbols for architecture ar...

Implementing a function that accepts only the user defined types in using the template specialization of C++.

A foo() in below source code will be accepted only the two types like myString and String2, but other types will occur an errors on compile time.

Google Protocol Buffers 소개

Binary Protocol인 Google Protocol Buffers에 대해 알아보자 1. Google Protocol Buffers 소개 Protocol Buffers는 구글에서 만든 것으로 언어 중립적, 플랫폼 중립적이면서 통신 프로토콜, 데이터 저장 또는 다른 곳에서 사용을 위한 구조화된 데이터 직렬화의 확장성 있는 방법입니다. (Protocol buffers are a language-neutral, platform-neutral, extensible way of serializing structured data for use in communications protocols, data storage, and more.) Protocol Buffers는 바이너리 프로토콜로 XML이나 JSON 처럼 사람이 직접 보고 분석할 수 없는 메모리 기반의 자료 구조를 말한다. 이런 바이너리 프로토콜은 데이터를 전달할 때 특정 포맷으로 변환할 필요가 없고, 데이터 수신시 파싱이 필요 없기 때문에 속도가 텍스트 프로토콜(XML, JSON 또는 HTTP 등)에 비해 상당히 빠르다는 장점이 있다. Protocol Buffers을 사용하기 위해서는 Protocol Buffer Language 을 사용하여 필드들을 정의하여 데이터를 구조화 후 컴파일을 통해 개발에 필요한 언어 코드을 자동 생성한다. 여기서 '구조화'라는 의미는 각 필드의 데이터들을 크기 또는 데이터 타입으로 정의하는 것을 의미하며, XML 스키마 파일을 만드는 것과 유사하다. Protocol Buffer Language 컴파일러는 모두 C++로 구현되어 있기 때문에 GitHub에서 다운로드 받아 빌드할 수 있으며, 이미 빌드된 바이너리 파일을 다운로드 받아 사용할 수 있다.( https://github.com/google/protobuf/releases ) 2. Protocol Buffer Language Google의 Protocol Buffers 소스는 G...

CRTP(Curiously recurring template pattern) 소개

CRTP(Curiously recurring template pattern) CRTP는 클래스 X가 X 자신을 템플릿 인자로 사용하여 클래스 템플릿 인스턴스화로부터 파생되게 하는 C++ 표현(Idiom, 관용구 )이다. 이 표현 이름은 1995년에 Jim Coplien에 의해 만들어 졌다. [Wikipedia 정의] The curiously recurring template pattern (CRTP) is an idiom in C++ in which a class X derives from a class template instantiation using X itself as template argument.[1] More generally it is known as F-bound polymorphism, and it is a form of F-bounded quantification. The technique was formalized in the 1980s as "F-bounded quantification."The name "CRTP" was independently coined by Jim Coplien in 1995, who had observed it in some of the earliest C++ template code as well as in code examples that Timothy Budd created in his multiparadigm language Leda. 1. 일반적 형식 // The Curiously Recurring Template Pattern (CRTP) template < class T > class Base { // methods within Base can use template to access members of Derived }; class Derived : public Base < Derived ...

Google Cloud Platform 사용하기 - Google Cloud Datalab을 개인 노트북에 설치하는 방법

이미지
Google Cloud Datalab( https://datalab.cloud.google.com/ )이 베타 버전으로 공개 되었다.   Datalab은 수집된 빅데이터을 분석하여 챠트 등 데이터를 가시화 하는데 유용하다. Datalab을 사용한 빅데이터 처리는 Twitter 이슈 빅데이터 처리 포스팅에 다룰 예정이다. (Cloud Datalab makes it easy to securely access all your data and public datasets, and use the power of Google BigQuery with SQL and Python to explore, visualize, analyze, and transform data.) 기존 버전에서는 Google Cloud Platform의 프로젝트와 연동되어 자동으로 Compute Engine(VM) 인스턴스가 하나 생성되어 처리했는데, 새로운 버전에서는 개인 노트북이나 컴퓨터에도 설치하여 사용이 가능하다. 시험적으로 옛날 버전으로 하나 생성했는데, 원하지 않게 24시간 Compute Engine이 실행되고 있어서 무료 사용기간이 아니라면 비용이 청구될 수 있을 것 같다. 따라서 지속적인 사용이 아니라면 개인 노트북이나 컴퓨터에 설치해서 사용하는 것이 비용 측면에서 좋을 것 같다. 개인 노트북이나 컴퓨터에 Datalab을 설치하기 위해서는 위 화면에서  Please use the  new version of Datalab beta . This version is now obsolete.  을 선택하면 새로운 Datalab을 어떤 방법으로 설치할 것인지 선택하는 페이지가 나온다.  Run Cloud Datalab locally Run Cloud Datalab kernels on Google Cloud Platform Run Cloud Datalab notebooks on Google Cloud P...

Google Cloud Platform 사용하기 - Comput Engine(VM) 인스턴스 만들기

이미지
최근에는 Cloud Platform이 대세다. Amazon, Microsoft, Google 등 대형 IT 업체들은 자신들의 기술과 서비스를 바탕으로 Amazon AWS, Microsoft Azure, Google Cloud Platform 서비스들을 제공하고 있다. 앱 서비스, 음성 또는 영상 인식, AI 사용 또는 IoT 같은 센서 데이터의 수집 및 분석을 위해서는 Cloud Service 사용은 필수이다. Google은 Google Cloud Platform 이름으로 여러 기능과 서비스들을 통합하여 Compute, Storage and Database, Networking, Big Data, Machine Learning 등의 제품들을 제공하고 있다. 모든 제품들은 사용 시간 또는 트래픽 당 과금을 매기고 있는데, 예를 들면 vCPU 1개, 3.75GB 메모리, 10G 디스크의 가상 컴퓨터를 24시간 동안 사용하면서 1달간 사용하면 약 2만 8천원 정도의 비용이 들어간다. 시간당 비용을 따지면 약 43원 정도이다. 하지만 vCPU 개수, 메모리 및 하드 디스크의 크기에 따라 그 비용은 다를 수 있다. 현재 60일간의 무료 사용 기간을 제공하고 있으며,  프로모션으로 무료 크래딧 $300를 지급한다. Google Cloud Platform의 웹 페이지 주소는  https://cloud.google.com/  이다. 구글 계정이 있다면 바로 무료로 사용해 볼 수 있으며, 특별히 계정을 업그레이드 하지 않는다면 60일이 지나도 결제가 자동으로 이뤄지지 않는다. Google Cloud Platfom 홈페이지 1. Google Cloud Platform 가입 무료 사용을 한글로 안내하고 있어서 쉽게 가입할 수 있다. 무료 사용을 위한 절차가 끝났다면 다음과 같이 대시보드가 나타난다. Google Cloud Platform은 '프로젝트' 단위로 가상컴퓨터와 서비스들을 관리하기 때문에 우선 프...

Linux NetworkManager을 Command Line에서 사용하기, nmcli

nmcli 툴은 readhat에서 개발한 NetworkManager을 제어할 수 있는 command-line 툴이다. 기본 명령은 다음과 같다. nmcli OPTIONS OBJECT { COMMAND | help } 만일 설치된 Linux의 언어가 한글로 설정되어 있다면 설명과 결과들을 한글로 확인 할 수 있다. ~]$  nmcli help Usage: nmcli [OPTIONS] OBJECT { COMMAND | help } OPTIONS -t[erse] terse output -p[retty] pretty output -m[ode] tabular|multiline output mode -f[ields] |all|common specify fields to output -e[scape] yes|no escape columns separators in values -n[ocheck] don't check nmcli and NetworkManager versions -a[sk] ask for missing parameters -w[ait] set timeout waiting for finishing operations -v[ersion] show program version -h[elp] print this help OBJECT g[eneral] NetworkManager's general statu...