projects
/
trackerpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix nan issue in features
[trackerpp.git]
/
src
/
Utils.cpp
diff --git
a/src/Utils.cpp
b/src/Utils.cpp
index
c174e28
..
df6802b
100644
(file)
--- a/
src/Utils.cpp
+++ b/
src/Utils.cpp
@@
-1,10
+1,16
@@
#include "Utils.h"
#include "Utils.h"
+#include <iostream>
+#include <stdexcept>
using namespace suanzi;
using namespace cv;
using namespace suanzi;
using namespace cv;
+using namespace std;
double distance_cosine(const Eigen::VectorXd& u, const Eigen::VectorXd& v)
{
double distance_cosine(const Eigen::VectorXd& u, const Eigen::VectorXd& v)
{
+ if (u.dot(u) * v.dot(v) == 0){
+ throw overflow_error("zero vector for cosine distance");
+ }
return (1 - u.dot(v) / std::sqrt(u.dot(u) * v.dot(v)));
}
return (1 - u.dot(v) / std::sqrt(u.dot(u) * v.dot(v)));
}