Skip to content

Instantly share code, notes, and snippets.

@ryanorz
ryanorz / using_script_in_elasticsearch
Created August 21, 2017 10:42
datafile of using_script_in_elasticsearch
{
"script" : {
"lang": "painless",
"inline" : "
for (def key : params.keySet()) {
if (key == \"ctx\")
continue;
if (key == \"array1\") {
for (int i = 0; i < params.array1.size(); i++) {
for (int j = 0; j < ctx._source.array1.size(); j++) {
@ryanorz
ryanorz / picture_hash.cpp
Created February 21, 2017 09:06
Picture similarity judgement
/**
* 图像匹配 - 在另一附图中找到匹配部分(小图是大图中的一部分)
* 1. 归一化互相关算法 - 简单, 但是需要尺寸不变, 应用较少
* 2. SIFT(Scale-invariant feature transform, 尺度不变特征转换) - 对形变支持好
*
* 图像相似度识别 - 给出两幅图的相似程度
* 1. 颜色直方图计算方法
* 缺点: 按照颜色的全局分布来看的,无法描述颜色的局部分布和色彩所处的位置。
* 2. 图像指纹与汉明距离 (图像相似度比较的核心思想)
@ryanorz
ryanorz / my_exceptions.h
Last active February 21, 2017 09:01
C++ thread pool implementation
#ifndef _UITILS_EXCEPTIONS_H
#define _UITILS_EXCEPTIONS_H
#include <stdexcept>
#include <string>
#include <cstring>
#include <errno.h>
#define NOEXCEPT noexcept