• Dollar One算法的第一步是重采样，该步骤将样本进行处理，重采样为指定的点的数目： Points resample(Points p,int n) { if (p.size()) { while (1) puts("a o"); exit(0); } if (p.size()==1) return vector(n...
首先上一个演示视频，这是一个我们课余时间调了一个月的交互系统，这个Demo是玩儿MC（手机拍的，不是很清楚）
http://v.youku.com/v_show/id_XMTQxMzIyOTM3Mg==.html?from=y1.7-1.2

上一篇文章里简单总结了一下Kinect的工作流程，接下来就写一下我们当前在做的应用好了。这个系统工作流程也很简单，通过Kinect获得肢体节点信息，然后进行识别，然后输出控制指令。这篇文章来说说我们用的手势识别。

我们用的算法是Dollar One算法，这个算法是老师介绍给我们的。这个算法本来是用来做鼠标手势识别的，但是鼠标手势也是一种手势，所以也是可以拿来用的。这个算法的基本思想是逐点比较标准化的模板和样本之间的标准差，然后根据阈值来决定是否和模板匹配，是一种简单而且易用的算法。由于是逐点比较，所以该算法对手势绘制顺序敏感。

Dollar One算法的第一步是重采样，该步骤将样本进行处理，重采样为指定的点的数目：

Points resample(Points p,int n)
{
if (p.size()<=0) { while (1) puts("a o"); exit(0); }
if (p.size()==1) return vector<VEC>(n,p);

double I=pathLength(p)/(n-1);
double D=0;
Points q; q.push_back(p);
for (int i=1;i<p.size();i++) {
double d=(p[i]-p[i-1]).len();
if (D+d>=I-EPS) {
VEC newp=(I-D)/d*(p[i]-p[i-1])+p[i-1];
q.push_back(newp);
p.insert(p.begin()+i,newp);
D=0;
}
else D+=d;
}
return q;
}

这个重采样的方法是首先算出绘制图形总长度，然后每隔一定距离就采样一个点。

重采样之后要缩放到同一的大小，将样本重新映射进一个指定大小的正方形中：

Points scaleTo(Points p, double size)
{
//把所有点给映射到一个正方形里
VEC tmp=boundingBox(p);
double width=tmp.x,height=tmp.y;
Points newp;
for (auto pp:p) newp.push_back(VEC(pp.x*size/width,pp.y*size/height));
return newp;
}

接下来是旋转，由于不知道目标角度，所以需要用二分的方法，不断尝试角度，然后取方差最小的角度：

double distanecAtBestAngle(Points p,Points T,double Oa,double Ob,double delta)
{
const double fi=(sqrt(5)-1)/2;

double x1=fi*Oa+(1-fi)*Ob;
double f1=distanceAtAngle(p,T,x1);
double x2=(1-fi)*Oa+fi*Ob;
double f2=distanceAtAngle(p,T,x2);
while (fabs(Ob-Oa)>delta) {
if (f1<f2) {
Ob=x2;
x2=x1;
f2=f1;
x1=fi*Oa+(1-fi)*Ob;
f1=distanceAtAngle(p,T,x1);
}
else {
Oa=x1;
x1=x2;
f1=f2;
x2=(1-fi)*Oa+fi*Ob;
f2=distanceAtAngle(p,T,x2);
}
}
return (f1 < f2) ? f1 : f2;
}


接下来是计算旋转后的两条路径的方差：

double pathDistance(const Points &a,const Points &b)
{
double d=0;
for (int i=0;i<a.size();i++)
d+=(b[i]-a[i]).len();
return d/a.size();  //算的是平均值
}

这样就算出了样本和指定模板的最小方差，然后再去和阈值比较，就可以得到匹配的结果。
展开全文 • 数据结构第一课：百钱买百鸡 现有100美元，母鸡3美元，公鸡2美元，小鸡0.5美元，请问应该怎么买，可以使100美元刚好买到100只鸡？ 代码如下（还可以改进）： #include &lt;iostream&...
数据结构第一课：百钱买百鸡
现有100美元，母鸡3美元，公鸡2美元，小鸡0.5美元，请问应该怎么买，可以使100美元刚好买到100只鸡？
代码如下（还可以改进）：
#include <iostream> using namespace std; int main() {     int i,j,k,sum=0;     for(i=1;i<=98;i++)     for(j=1;j<=98;j++)     for(k=2;k<=98;k=k+2)         {   sum++;             if((i+j+k==100)&&(3*i+2*j+0.5*k==100))             cout<<"母鸡"<<i<<"只，"<<"公鸡"<<j<<"只，"<<"小鸡"<<k<<"只"<<endl;         }     cout<<"一共"<<sum<<"组"<<endl;     return 0; }


展开全文  C
• http://hackaday.com/2014/01/23/arm-debugger-for-nearly-one-dollar/ Oh that title is so misleading. But if you squint your eyes and scratch your noggin it’s almost true. Thanks to the hard work ... Oh that title is so misleading.
But if you squint your eyes and scratch your noggin it’s almost true.
Thanks to the hard work of [Peter Lawrence] it is now possible to hack together
an extremely inexpensive CMSIS-DAP ARM debugger.
Let’s talk about function and we’ll get back to cost later.
CMSIS-DAP is a standard that gives you the kind of breakpoint control you expect from a proper debugger.
In this case [Peter] implemented the standard using 4k words of space on a PIC 16F1454.
This lets it talk to the debug port on ARM chips, and the bootloader (also written by him)
doubles as a USB-to-UART bridge. Boom, done.
OpenOCD (and a couple of other software packages) talks to the PIC and it talks to the ARM. Nice.
Back to the cost question.
You can get a 16F1454 for nearly a dollar when you order in quantity.
If you cut up an old USB cable, recycle some jumper wire, and already have power
and decoupling on hand, you’re in business for nearly one dollar.


展开全文 • Kingpin How One Hacker Took Over the Billion-Dollar Cybercrime Underground Hacker
• One day Vasya got hold of information on the Martian dollar course in bourles for the next n days. The buying prices and the selling prices for one dollar on day i are the same and are equ
Description  One day Vasya got hold of information on the Martian dollar course in bourles for the next n days. The buying prices and the selling prices for one dollar on day i are the same and are equal to ai. Vasya has b bourles. He can buy a certain number of dollars and then sell it no more than once in n days. According to Martian laws, one can buy only an integer number of dollars. Which maximal sum of money in bourles can Vasya get by the end of day n?
Input  The first line contains two integers n and b (1 ≤ n, b ≤ 2000) — the number of days and the initial number of money in bourles. The next line contains n integers ai (1 ≤ ai ≤ 2000) — the prices of Martian dollars.
Output  Print the single number — which maximal sum of money in bourles can Vasya get by the end of day n.
Sample Input  Input  2 4  3 7  Output  8  Input  4 10  4 3 2 1  Output  10  Input  4 10  4 2 3 1  Output  15  题意：就是买股票，低买，高卖，只能买一次，卖一次，想办法赚的钱多。  两种方法，直接暴力和加一点优化  给一下代码：  第一种 直接暴力：
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
int n, b, a, maxx, flag, t, k, mm, j;
while(~scanf("%d %d", &n, &b))
{
memset(mm, 0, sizeof(mm));
maxx = flag = t = k = j = 0;
for(int i = 0; i < n; i++)
{
scanf("%d", &a[i]);
}
for(int i = 0; i < n - 1; i++)
{
t = b / a[i];
for(int j  = i + 1; j < n; j++)
{
k = max(k, a[j] * t + b - t * a[i]);
}
}
if(b > k) printf("%d\n", b);
else printf("%d\n", k);
}
return 0;
}
第二种 优化
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
int n, b, a, maxx, flag, t, k, mm, j;
while(~scanf("%d %d", &n, &b))
{
memset(mm, 0, sizeof(mm));
maxx = flag = t = k = j = 0;
for(int i = 0; i < n; i++)
{
scanf("%d", &a[i]);
}
for(int i = 0; i < n - 1; i++)
{
if(a[i] < a[i + 1])
{
t = b / a[i];
flag = 2, maxx = 0; //注意每一次都要初始化
for(int j = i + 1; j < n; j++)
maxx = max(maxx, a[j]);
k= max( maxx * t + (b - a[i] * t), k);
}
}
if(!flag) printf("%d\n", b);
else printf("%d\n", k);
}
return 0;
}
第二种方法有bug，就是maxx的初始化问题，开始没有初始化，所以一直WA，加一个初始化就AC了，呵呵呵，这也是大问题啊！
展开全文 • Counterfeit Dollar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 55414 Accepted: 17206 Description Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are...
• one coin is counterfeit even though its color and size make it indistinguishable from the real silver dollars. The counterfeit coin has a different weight from the other coins but Sally does not know... Golang erlang r语言
• POJ 1013 Counterfeit Dollar Description 枚举类
• [dollar]55.00 (paper) Psychology in rhe Schools Volume 1 9 . Ocrober. 1982 B O O K R E V I E W S GILBERT R. GREDLER University of South Carolina FOSTER, S. The One Girl in Ten: A Self-...
• Counterfeit Dollar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 45287   Accepted: 14316 Description Sally Jones has a dozen Voyageur poj
• POJ1013 Counterfeit Dollar Description Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are true silver dollars; one coin is counterfeit even though its color and... POJ
• Counterfeit DollarTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 27942Accepted: 8742 DescriptionSally Jones has a dozen Voyageur silver dollars. However, only eleven of the ... string each input integer
• S - Counterfeit Dollar Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are true silver dollars; one coin is counterfeit even though its color and size make it i  ...