Skip to content

Instantly share code, notes, and snippets.

View MarcWang's full-sized avatar

MarcWang MarcWang

  • 吾微而智
View GitHub Profile

Lambda functions:

Syntax

1. [ capture-list ] ( params ) mutable(optional) exception attribute -> ret { body }	
2. [ capture-list ] ( params ) -> ret { body }
3. [ capture-list ] ( params ) { body }
4. [ capture-list ] { body }

capture-list

#include <iostream>
#include <pxcprojection.h>
#include <pxcsensemanager.h>
#include <pxccapturemanager.h>
#include <common/util_render.h>
#define WIDTH 640
#define HEIGHT 480
#define MIN_DISTANCE 100
#include <iostream>
#include <TEXTRecognizer.h>
void main()
{
TEXTRecognizer textHandler;
// std::vector<std::string> lexicon;
// lexicon.push_back(std::string("CHINA"));
// textHandler.initialize( lexicon );
textHandler.initialize();

Ref

Node-arm

NOTE: UPGRADE YOUR GCC to V4.8 for this package to work!

Option 1 (the better option):

$ sudo apt-get update
$ sudo apt-get install gcc-4.8 g++-4.8
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20

#Installing OpenCV 3 on Raspbian Jessie

Step.1 安裝

更新和升級樹梅派上已經安裝的套件,並更新韌體

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo rpi-update
#include <opencv2/opencv.hpp>
#include <iostream>
const std::string keys =
"{help | | print this message }"
;
int main( int argc, char *argv[] )
{
cv::CommandLineParser parser( argc, argv, keys);
#include <opencv2/opencv.hpp>
#include <iostream>
const std::string keys =
"{help | | print this message }"
;
int main( int argc, char *argv[] )
{
cv::CommandLineParser parser( argc, argv, keys);

ES6 - 箭頭函數( Arrow Function )

箭頭函數表示式 (Arrow function expression,也是所謂的 fat arrow function) 比起一般的函數表示式擁有更短的語法以及詞彙上綁定 this 變數,所有的箭頭函數都是無名函數 (anonymous function).

箭頭函數有兩個重要的特性:更短的函數寫法與 this 變數綁定

更短的函數寫法

() => expression 

ES6 - 類別 (classes)

要在ES6中使用class必須加入"strict mode"

類別實際上是函數(functions),簡單又分為以下兩種:

  • 類別敘述(class expressions)
  • 類別宣告(class declarations)

建構子(constructor)用來建立和初始化一個類別的物件,一個類別只能有一個名為 constructor

ES6 - 物件語法 (Object Literal)

Shorter property name

var name = 'Mario',
    age = 29,
    gender = 'male';

var es5Obj = { name: name, age: age, gender: gender };