PokerNet-poker recognition: 基于人工神经网络的扑克识别 (5)
结果1

void computeBCValue(cv::Mat mat_img, std::vector<bbox_t> result_vec, std::vector<std::string> obj_names,
int current_det_fps = -1, int current_cap_fps = -1)
{
int const colors[6][3] = { { 1,0,1 },{ 0,0,1 },{ 0,1,1 },{ 0,1,0 },{ 1,1,0 },{ 1,0,0 } };
Cardsets cardsets;
int tempx = 0;
vector<bbox_t> mypoints; //
for (auto &i : result_vec) {
if (i.prob < confidencetheta) { // if I am not confident than 50%, skip this poker
continue;
}
// here we compute the distance w.r.t (0,0)
if (i.h < i.w) {// 3rd
if (i.prob > cardsets.confidence[2]) {
cardsets.confidence[2] = i.prob;
cardsets.cardvalues[2] = Point3f(i.x, i.y, i.obj_id);
}
}
else {
mypoints.push_back(i);
}
}
if (cardsets.cardvalues[2].x > 0) {
//cout << "3rd-" << obj_names[cardsets.cardvalues[2].z] << endl;
}
if (mypoints.size() < 2) { return; }
sort(mypoints.begin(), mypoints.end(), SetSortRule);
int first = 0;
int second = 0;
if (mypoints.size() == 4) {//
if (mypoints[0].prob > mypoints[1].prob) {
//cout << "1st-" << obj_names[mypoints[0].obj_id] << endl;
first = 0;
}
else {
//cout << "1st-" << obj_names[mypoints[1].obj_id] << endl;
first = 1;
}
if (mypoints[2].prob > mypoints[3].prob) {
// cout << "2ed-" << obj_names[mypoints[2].obj_id] << endl;
second = 2;
}
else {
//cout << "2ed-" << obj_names[mypoints[3].obj_id] << endl;
second = 3;
}
}
else if (mypoints.size() == 3) {// if we only detect 3 points, take first one to match with other two decide which is pair
/* details of the theroy are on the notebook page */
int delta_y = mypoints[1].y - mypoints[0].y;
if (getCosineDistance(mypoints[0], mypoints[1]) < getCosineDistance(mypoints[0], mypoints[2]) && delta_y > 100) { // we assume they belong to one card
first = mypoints[0].prob > mypoints[1].prob ? 0 : 1;
second = 2;
}
else {// 0 and 1 not one card
// cout << "1st-" << obj_names[mypoints[0].obj_id] << endl;
second = mypoints[1].prob > mypoints[2].prob ? 1 : 2;
}
}
else if (mypoints.size() == 2) {
if (getCosineDistance(mypoints[0], mypoints[1]) < cosinetheta) { // we assume they belong to one card
first = mypoints[0].prob > mypoints[1].prob ? 0 : 1;
}
else {
second = 1;
}
}
cardsets.confidence[0] = mypoints[first].prob;
cardsets.cardvalues[0] = Point3f(mypoints[first].x, mypoints[first].y, mypoints[first].obj_id);
cardsets.confidence[1] = mypoints[second].prob;
cardsets.cardvalues[1] = Point3f(mypoints[second].x, mypoints[second].y, mypoints[second].obj_id);
ostringstream info;
info << "1st-" << obj_names[mypoints[first].obj_id] << ",confidence-" << setprecision(2) << fixed << mypoints[first].prob << ",";
info << "2ed-" << obj_names[mypoints[second].obj_id] << ",confidence-" << setprecision(2) << fixed << mypoints[second].prob << ",";
if (cardsets.cardvalues[2].x > 0) { info << "3rd-" << obj_names[cardsets.cardvalues[2].z] << ",confidence-" << setprecision(2) << fixed << cardsets.confidence[2] << ","; }
cout << info.str() << endl;
putText(mat_img, info.str(), cv::Point(5, 40), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 0, 255));
}
结果2

void computeDTValue(cv::Mat mat_img, std::vector<bbox_t> result_vec, std::vector<std::string> obj_names,
int current_det_fps = -1, int current_cap_fps = -1)
{
int const colors[6][3] = { { 1,0,1 },{ 0,0,1 },{ 0,1,1 },{ 0,1,0 },{ 1,1,0 },{ 1,0,0 } };
int tempx = 0;
vector<bbox_t> mypoints; //
for (auto &i : result_vec) {
if (i.prob > confidencetheta) { // if I am not confident than 50%, skip this poker
mypoints.push_back(i);
}
}
sort(mypoints.begin(), mypoints.end(), SetSortRulebyConfidence);
int cardids = 0;
float confidence = 0;
if (mypoints.size() > 0) {
cardids = mypoints[0].obj_id;
confidence = mypoints[0].prob;
}
else { //error
cout << "nothing detected" << endl;
}
ostringstream info;
info << "1st-" << obj_names[cardids] << ",confidence-" << setprecision(2) << fixed << confidence << ",";
cout << info.str() << endl;
cv::putText(mat_img, info.str(), cv::Point(5, 40), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 0, 255));
}
PokerNet-poker recognition: 基于人工神经网络的扑克识别 (5)的更多相关文章
- 基于卷积神经网络的人脸识别项目_使用Tensorflow-gpu+dilib+sklearn
https://www.cnblogs.com/31415926535x/p/11001669.html 基于卷积神经网络的人脸识别项目_使用Tensorflow-gpu+dilib+sklearn ...
- Pytorch实现基于卷积神经网络的面部表情识别(详细步骤)
文章目录 一.项目背景 二.数据处理 1.标签与特征分离 2.数据可视化 3.训练集和测试集 三.模型搭建 四.模型训练 五.完整代码 一.项目背景数据集cnn_train.csv包含人类面部表情的图 ...
- 基于卷积神经网络的面部表情识别(Pytorch实现)----台大李宏毅机器学习作业3(HW3)
一.项目说明 给定数据集train.csv,要求使用卷积神经网络CNN,根据每个样本的面部图片判断出其表情.在本项目中,表情共分7类,分别为:(0)生气,(1)厌恶,(2)恐惧,(3)高兴,(4)难过 ...
- 深度学习项目——基于卷积神经网络(CNN)的人脸在线识别系统
基于卷积神经网络(CNN)的人脸在线识别系统 本设计研究人脸识别技术,基于卷积神经网络构建了一套人脸在线检测识别系统,系统将由以下几个部分构成: 制作人脸数据集.CNN神经网络模型训练.人脸检测.人脸 ...
- 硕毕论文_基于 3D 卷积神经网络的行为识别算法研究
论文标题:基于 3D 卷积神经网络的行为识别算法研究 来源/作者机构情况: 中 国 地 质 大 学(北京),计算机学院,图像处理方向 解决问题/主要思想贡献: 1. 使用张量CP分解的原理, ...
- C#中调用Matlab人工神经网络算法实现手写数字识别
手写数字识别实现 设计技术参数:通过由数字构成的图像,自动实现几个不同数字的识别,设计识别方法,有较高的识别率 关键字:二值化 投影 矩阵 目标定位 Matlab 手写数字图像识别简介: 手写 ...
- 人工神经网络简介和单层网络实现AND运算--AForge.NET框架的使用(五)
原文:人工神经网络简介和单层网络实现AND运算--AForge.NET框架的使用(五) 前面4篇文章说的是模糊系统,它不同于传统的值逻辑,理论基础是模糊数学,所以有些朋友看着有点迷糊,如果有兴趣建议参 ...
- 基于BP神经网络的字符识别研究
基于BP神经网络的字符识别研究 原文作者:Andrew Kirillov. http://www.codeproject.com/KB/cs/neural_network_ocr.aspx 摘要:本文 ...
- 人工神经网络--ANN
神经网络是一门重要的机器学习技术.它是目前最为火热的研究方向--深度学习的基础.学习神经网络不仅可以让你掌握一门强大的机器学习方法,同时也可以更好地帮助你理解深度学习技术. 本文以一种简单的,循序的方 ...
随机推荐
- Java 自动检测文本文件编码
private String guessCharset(InputStream is) throws IOException { return new TikaEncodingDetector().g ...
- Hive之explode和lateral view
Hive之explode 一. explode, 行转列. 1.1. 用于array类型的数据 table_name 表名 array_col 为数组类型的字段 new_col array_col被e ...
- Mac版本的 Axure rp8 不显示菜单栏
我之前也是一直在找这个问题,可能mac用的不熟练吧,其实他的菜单栏就近在眼前 你看不见只是因为你的关注点在axure上 往大了看,他的菜单栏显示在你的电脑的菜单栏上,mac的菜单栏基本都是这么显示的, ...
- ubuntu QT安装以及配置交叉编译环境
我的环境:ubuntu14.04 64位 1.下载Qt: 上网搜索 qt-opensource-linux-x64-5.3.0.run下载有好多百度云盘 要么在官网下载追新版本http://down ...
- boost asio tcp 多线程异步读写,服务器与客户端。
// server.cpp #if 0 多个线程对同一个io_service 对象处理 用到第三方库:log4cplus, google::protobuf 用到C++11的特性,Windows 需要 ...
- ubuntu配置阿里云源
换成国内最快的阿里云源 第一步:备份原来的源文件 cd /etc/apt/ 然后会显示下面的源文件sources.list 输入命令 sudo cp sources.list sources.list ...
- Mycat搭建负载均衡,读写分离的Mysql集群
Mycat搭建负载均衡,读写分离的Mysql集群 准备环境 1.mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz 2.Mycat-server-1.6.7.4-te ...
- Windows的ODBC配置指南: MySQL, PostgreSQL, DB2, Oracle
MySQL- 官网: https://dev.mysql.com/downloads/connector/odbc/- 安装: * msi格式, 直接安装即可 * zip格式, 解压缩, 命令行(管理 ...
- Redis探索之路(一):Redis简介
一:NOSQL NotOnlySQL 反SQL运动,非关系型数据库(区别于Mysql关系型书库). 随着Web2.0兴起,“高性能”,“高并发”成为主流. NoSQL以key-value形式存储数据, ...
- Android android studio常用的一些快捷键以及常用权限
android studio的常用快捷键:一.打印log:1.输入logt回车: 自动生成TAG的全局变量:private static final String TAG = "MainA ...