Example #1
0
SUMOReal
MSPerson::MSPersonStage_Driving::getAngle(SUMOTime /* now */) const {
    if (myVehicle != 0) {
        MSVehicle* veh = dynamic_cast<MSVehicle*>(myVehicle);
        if (veh != 0) {
            return veh->getAngle() + 90;
        } else {
            return 0;
        }
    }
    return getEdgeAngle(myWaitingEdge, myWaitingPos);
}
Example #2
0
double Sobel(double *src,double *dst,double *edgedriction,int width,int height,int sobel_size){
    //double SobelMask_x[3]={-1,-2,-1,0,0,0,1,2,1};
    double *dst_x=(double *)malloc(sizeof(double)*width*height);
    double *dst_y=(double *)malloc(sizeof(double)*width*height);
    if(sobel_size==-1){
        return Scharr(src, dst, edgedriction, width, height);
    }
    else if(sobel_size==3){
        double SobelMask1[3]={0.25,0.5,0.25};
        double SobelMask2[3]={1,0,-1};
        RealConvolution(src, dst_y, SobelMask2, width, height, 1, 3 );
        RealConvolution(dst_y, dst_y,SobelMask1, width, height, 3, 1);
        
        RealConvolution(src, dst_x, SobelMask1, width, height, 1, 3);
        RealConvolution(dst_x, dst_x, SobelMask2, width, height, 3, 1);
    
       
    }else if(sobel_size==5){
        double SobelMask1[5]={1/16.,4/16.,6/16.,4/16.,1/16.};
        double SobelMask2[5]={1/3.,2/3.,0,-2/3.,-1/3.};
        RealConvolution(src, dst_x, SobelMask1, width, height, 1, 5);
        RealConvolution(dst_x, dst_x, SobelMask2, width, height, 5, 1);
        
        RealConvolution(src, dst_y, SobelMask2, width, height, 1, 5);
        RealConvolution(dst_y, dst_y, SobelMask1, width, height, 5, 1);
    
    }else if(sobel_size==7){
        double SobelMask1[7]={1/64.,6/64.,15/64.,20/64.,15/64.,6/64.,1/64.};
        double SobelMask2[7]={0.1,0.4,0.5,0,-0.5,-0.4,-0.1};
        RealConvolution(src, dst_x, SobelMask1, width, height, 1, 7);
        RealConvolution(dst_x, dst_x, SobelMask2, width, height, 7, 1);
        
        RealConvolution(src, dst_y, SobelMask2, width, height, 1, 7);
        RealConvolution(dst_y, dst_y, SobelMask1, width, height, 7, 1);
        
    }
    
    for(int i=0;i<width*height;i++)
        dst_y[i]=-dst_y[i];
    if(edgedriction!=NULL)
        getEdgeAngle(dst_x, dst_y, edgedriction, width, height);
    for(int j=0;j<height;j++)
        for(int i=0;i<width;i++){
            dst[j*width+i]=abs(dst_x[j*width+i])+abs(dst_y[j*width+i]);
        }
    free(dst_x);
    free(dst_y);
    return findMatrixMax(dst,width,height,NULL);
}
Example #3
0
double Robert(double *src,double *dst,double *edgedriction,int width,int height){
    double RobertMask_x[9]={0,0,0,0,-1,0,0,0,1};
    double RobertMask_y[9]={0,0,0,0,0,-1,0,1,0};
    
    double *dst_x=(double *)malloc(sizeof(double)*width*height);
    double *dst_y=(double *)malloc(sizeof(double)*width*height);
    RealConvolution(src, dst_x, RobertMask_x, width, height, ROBERT_MASK_SIZE,ROBERT_MASK_SIZE);
    RealConvolution(src, dst_y, RobertMask_y, width, height, ROBERT_MASK_SIZE,ROBERT_MASK_SIZE);
    if(edgedriction!=NULL)
        getEdgeAngle(dst_x, dst_y, edgedriction, width, height);
    for(int j=0;j<height;j++)
        for(int i=0;i<width;i++){
            dst[j*width+i]=abs(dst_x[j*width+i])+abs(dst_y[j*width+i]);
            
        }
    free(dst_x);
    free(dst_y);
    return findMatrixMax(dst,width,height,NULL);
    
}
Example #4
0
double Scharr(double *src,double *dst,double *edgedriction,int width,int height){
    double ScharrMask1[3]={3,10,3};
    double ScharrMask2[3]={1,0,-1};
    double *dst_x=(double *)malloc(sizeof(double)*width*height);
    double *dst_y=(double *)malloc(sizeof(double)*width*height);
    RealConvolution(src, dst_x, ScharrMask1, width, height, 1, 3);
    RealConvolution(dst_x, dst_x, ScharrMask2, width, height, 3, 1);
    
    RealConvolution(src, dst_y, ScharrMask2, width, height, 1, 3);
    RealConvolution(dst_y, dst_y, ScharrMask1, width, height, 3, 1);
    for(int i=0;i<width*height;i++)
        dst_y[i]=-dst_y[i];
    if(edgedriction!=NULL)
        getEdgeAngle(dst_x, dst_y, edgedriction, width, height);
    for(int j=0;j<height;j++)
        for(int i=0;i<width;i++){
            dst[j*width+i]=abs(dst_x[j*width+i])+abs(dst_y[j*width+i]);
        }
    free(dst_x);
    free(dst_y);
    return findMatrixMax(dst,width,height,NULL);
}
Example #5
0
SUMOReal
MSPerson::MSPersonStage_Waiting::getAngle(SUMOTime /* now */) const {
    return getEdgeAngle(&myDestination, myStartPos) + 45;
}
Example #6
0
SUMOReal
MSPerson::MSPersonStage_Walking::getAngle(SUMOTime now) const {
    const MSEdge* e = getEdge(now);
    SUMOReal off = STEPS2TIME(now - myLastEntryTime);
    return getEdgeAngle(e, myCurrentBeginPos + myCurrentLength / myCurrentDuration * off) + 90;
}
Example #7
0
SUMOReal
MSPerson::MSPersonStage_Waiting::getAngle(SUMOTime /* now */) const {
    return getEdgeAngle(&myDestination, myArrivalPos) + M_PI / 2;
}