Commit be49e4a0 authored by Alex Leontiev's avatar Alex Leontiev

commit

parent c27db0d1
......@@ -103,7 +103,7 @@ std::string type2str(const Mat& mat){
std::string r;
uchar depth = type & CV_MAT_DEPTH_MASK;
uchar chans = 1 + (type >> CV_CN_SHIFT);
uchar chans =(uchar)( 1 + (type >> CV_CN_SHIFT));
switch ( depth ) {
case CV_8U: r = "8U"; break;
......@@ -221,7 +221,7 @@ double NCC(Mat_<uchar> patch1,Mat_<uchar> patch2){
}
unsigned int getMedian(const std::vector<unsigned int>& values, int size){
if(size==-1){
size=values.size();
size=(int)values.size();
}
std::vector<int> copy(values.begin(),values.begin()+size);
std::sort(copy.begin(),copy.end());
......@@ -270,7 +270,7 @@ void resample(const Mat& img,const RotatedRect& r2,Mat_<uchar>& samples){
}
}
void resample(const Mat& img,const Rect2d& r2,Mat_<uchar>& samples){
if(true){
#if 1
double x,y,a,b,tx,ty;int ix,iy;
for(int i=0;i<samples.rows;i++){
y=r2.y+i*r2.height/samples.rows;
......@@ -285,21 +285,21 @@ void resample(const Mat& img,const Rect2d& r2,Mat_<uchar>& samples){
samples(i,j)=(uchar)(a * (1.0 - ty) + b * ty);
}
}
}else{
#else
Point2f center((float)(r2.x+r2.width/2),(float)(r2.y+r2.height/2));
return resample(img,RotatedRect(center,Size2f(r2.width,r2.height),0.0f),samples);
}
return resample(img,RotatedRect(center,Size2f((float)r2.width,(float)r2.height),0.0f),samples);
#endif
}
//other stuff
void TLDEnsembleClassifier::stepPrefSuff(uchar* arr,int len){
int gridSize=getGridSize();
if(false){
#if 0
int step=len/(gridSize-1), pref=(len-step*(gridSize-1))/2;
for(int i=0;i<(int)(sizeof(x1)/sizeof(x1[0]));i++){
arr[i]=pref+arr[i]*step;
}
}else{
#else
int total=len-gridSize;
int quo=total/(gridSize-1),rem=total%(gridSize-1);
int smallStep=quo,bigStep=quo+1;
......@@ -307,20 +307,20 @@ void TLDEnsembleClassifier::stepPrefSuff(uchar* arr,int len){
int bigOnes_front=bigOnes/2,bigOnes_back=bigOnes-bigOnes_front;
for(int i=0;i<(int)(sizeof(x1)/sizeof(x1[0]));i++){
if(arr[i]<bigOnes_back){
arr[i]=arr[i]*bigStep+arr[i];
arr[i]=(uchar)(arr[i]*bigStep+arr[i]);
continue;
}
if(arr[i]<(bigOnes_front+smallOnes)){
arr[i]=bigOnes_front*bigStep+(arr[i]-bigOnes_front)*smallStep+arr[i];
arr[i]=(uchar)(bigOnes_front*bigStep+(arr[i]-bigOnes_front)*smallStep+arr[i]);
continue;
}
if(arr[i]<(bigOnes_front+smallOnes+bigOnes_back)){
arr[i]=bigOnes_front*bigStep+smallOnes*smallStep+(arr[i]-(bigOnes_front+smallOnes))*bigStep+arr[i];
arr[i]=(uchar)(bigOnes_front*bigStep+smallOnes*smallStep+(arr[i]-(bigOnes_front+smallOnes))*bigStep+arr[i]);
continue;
}
arr[i]=len-1;
arr[i]=(uchar)(len-1);
}
}
#endif
}
TLDEnsembleClassifier::TLDEnsembleClassifier(int ordinal,Size size){
preinit(ordinal);
......@@ -330,7 +330,7 @@ TLDEnsembleClassifier::TLDEnsembleClassifier(int ordinal,Size size){
stepPrefSuff(y2,size.height);
}
void TLDEnsembleClassifier::integrate(Mat_<uchar> patch,bool isPositive){
unsigned short int position=code(patch.data,patch.step[0]);
unsigned short int position=code(patch.data,(int)patch.step[0]);
if(isPositive){
pos[position]++;
}else{
......@@ -348,18 +348,18 @@ double TLDEnsembleClassifier::posteriorProbability(const uchar* data,int rowstep
}
unsigned short int TLDEnsembleClassifier::code(const uchar* data,int rowstep)const{
unsigned short int position=0;
char codeS[20];
//char codeS[20];
for(int i=0;i<(int)(sizeof(x1)/sizeof(x1[0]));i++){
if(*(data+rowstep*y1[i]+x1[i])<*(data+rowstep*y2[i]+x2[i])){
position++;
codeS[i]='o';
//codeS[i]='o';
}else{
codeS[i]='x';
//codeS[i]='x';
}
position=position<<1;
}
codeS[13]='\0';
if(!true)printf("integrate with code %s\n",codeS);
//codeS[13]='\0';
//printf("integrate with code %s\n",codeS);
return position;
}
......
......@@ -163,7 +163,7 @@ std::string MedianFlowCore::type2str(int type) {
std::string r;
uchar depth = type & CV_MAT_DEPTH_MASK;
uchar chans = 1 + (type >> CV_CN_SHIFT);
uchar chans = (uchar)(1 + (type >> CV_CN_SHIFT));
switch ( depth ) {
case CV_8U: r = "8U"; break;
......@@ -192,8 +192,8 @@ bool MedianFlowCore::medianFlowImpl(Mat oldImage,Mat newImage,Rect2d& oldBox){
for(int i=0;i<params.pointsInGrid;i++){
for(int j=0;j<params.pointsInGrid;j++){
pointsToTrackOld.push_back(
Point2f(oldBox.x+((1.0*oldBox.width)/params.pointsInGrid)*j+.5*oldBox.width/params.pointsInGrid,
oldBox.y+((1.0*oldBox.height)/params.pointsInGrid)*i+.5*oldBox.height/params.pointsInGrid));
Point2f((float)(oldBox.x+((1.0*oldBox.width)/params.pointsInGrid)*j+.5*oldBox.width/params.pointsInGrid),
(float)(oldBox.y+((1.0*oldBox.height)/params.pointsInGrid)*i+.5*oldBox.height/params.pointsInGrid)));
}
}
......@@ -235,7 +235,7 @@ bool MedianFlowCore::medianFlowImpl(Mat oldImage,Mat newImage,Rect2d& oldBox){
di[i]-=mDisplacement;
displacements.push_back(sqrt(di[i].ddot(di[i])));
}
if(getMedian(displacements,displacements.size())>10){
if(getMedian(displacements,(int)displacements.size())>10){
return false;
}
......@@ -247,7 +247,7 @@ Rect2d MedianFlowCore::vote(const std::vector<Point2f>& oldPoints,const std::vec
static int iteration=0;//FIXME -- we don't want this static var in final release
Rect2d newRect;
Point2d newCenter(oldRect.x+oldRect.width/2.0,oldRect.y+oldRect.height/2.0);
int n=oldPoints.size();
int n=(int)oldPoints.size();
std::vector<double> buf(std::max(n*(n-1)/2,3),0.0);
if(oldPoints.size()==1){
......@@ -265,7 +265,7 @@ Rect2d MedianFlowCore::vote(const std::vector<Point2f>& oldPoints,const std::vec
for(int i=0;i<n;i++){ buf[i]=newPoints[i].y-oldPoints[i].y; }
yshift=getMedian(buf,n);
newCenter.y+=yshift;
mD=Point2f(xshift,yshift);
mD=Point2f((float)xshift,(float)yshift);
if(oldPoints.size()==1){
newRect.x=newCenter.x-oldRect.width/2.0;
......@@ -275,12 +275,12 @@ Rect2d MedianFlowCore::vote(const std::vector<Point2f>& oldPoints,const std::vec
return newRect;
}
float nd,od;
double nd,od;
for(int i=0,ctr=0;i<n;i++){
for(int j=0;j<i;j++){
nd=l2distance(newPoints[i],newPoints[j]);
od=l2distance(oldPoints[i],oldPoints[j]);
buf[ctr]=(od==0)?0:(nd/od);
buf[ctr]=(od==0.0)?0.0:(nd/od);
ctr++;
}
}
......@@ -304,12 +304,12 @@ Rect2d MedianFlowCore::vote(const std::vector<Point2f>& oldPoints,const std::vec
template<typename T>
T MedianFlowCore::getMedian(std::vector<T>& values,int size){
if(size==-1){
size=values.size();
size=(int)values.size();
}
std::vector<T> copy(values.begin(),values.begin()+size);
std::sort(copy.begin(),copy.end());
if(size%2==0){
return (copy[size/2-1]+copy[size/2])/2.0;
return (copy[size/2-1]+copy[size/2])/((T)2.0);
}else{
return copy[(size-1)/2];
}
......@@ -318,7 +318,7 @@ T MedianFlowCore::getMedian(std::vector<T>& values,int size){
void MedianFlowCore::computeStatistics(std::vector<float>& data,int size){
int binnum=10;
if(size==-1){
size=data.size();
size=(int)data.size();
}
float mini=*std::min_element(data.begin(),data.begin()+size),maxi=*std::max_element(data.begin(),data.begin()+size);
std::vector<int> bins(binnum,(int)0);
......@@ -374,7 +374,7 @@ void MedianFlowCore::check_NCC(const Mat& oldImage,const Mat& newImage,
double sq1=sqrt(n1*n1-s1*s1/N),sq2=sqrt(n2*n2-s2*s2/N);
double ares=(sq2==0)?sq1/abs(sq1):(prod-s1*s2/N)/sq1/sq2;
NCC[i] = ares;
NCC[i] = (float)ares;
}
float median = getMedian(NCC);
for(int i = 0; i < (int)oldPoints.size(); i++) {
......
......@@ -63,7 +63,7 @@ using namespace cv;
* THETA_NN 0.5<->0.6 dramatic change vs video 6
* TODO:
* schoolPC: codec, libopencv-dev
* fix pushbot ||video(vadim random, better?) --> debug if box size is less than 20 --> (remove ensemble self-loop) --> (try inter_area)
* fix pushbot -> compare_branches ||video(vadim random, better?) --> debug if box size is less than 20 --> (remove ensemble self-loop) --> (try inter_area)
* perfect PN
*/
......@@ -77,13 +77,13 @@ namespace cv
class TLDDetector;
class MyMouseCallbackDEBUG{
public:
MyMouseCallbackDEBUG(const Mat& img,const Mat& imgBlurred,TLDDetector* detector):img_(img),imgBlurred_(imgBlurred),detector_(detector){}
MyMouseCallbackDEBUG( Mat& img, Mat& imgBlurred,TLDDetector* detector):img_(img),imgBlurred_(imgBlurred),detector_(detector){}
static void onMouse( int event, int x, int y, int, void* obj){
((MyMouseCallbackDEBUG*)obj)->onMouse(event,x,y);
}
private:
void onMouse( int event, int x, int y);
const Mat& img_,imgBlurred_;
Mat& img_,imgBlurred_;
TLDDetector* detector_;
};
......@@ -248,7 +248,7 @@ bool TrackerTLD::initImpl(const Mat& image, const Rect2d& boundingBox ){
privateInfo.push_back(Ptr<TLDDetector>(detector));
privateInfo.push_back(Ptr<Data>(data));
if(!true){
#if !1
printf("here I am\n");
Mat image_blurred;
GaussianBlur(image_gray,image_blurred,GaussBlurKernelSize,0.0);
......@@ -256,7 +256,7 @@ bool TrackerTLD::initImpl(const Mat& image, const Rect2d& boundingBox ){
imshow("picker",image_gray);
setMouseCallback( "picker", MyMouseCallbackDEBUG::onMouse, (void*)callback);
waitKey();
}
#endif
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment