Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

average of some frames/getting error

I want to get average of 5 frames which their Itime are equal to 1000. What is the problem in my code? Why I get error in retur part?

 float Data::HighestTime(float *distances){
        Mat mean_distances; 
        if(Itime=1000){
            for(int i=0; i<5; i++){
                cv::Mat matDistances = Mat(width, height, CV_32FC1, distances);
                Mat mean_distances = matDistances;
                mean_distances = mean_distances * (1/5);

            }
        }
        return mean_distances;
    }

average of some frames/getting error

I want to get average of 5 frames which their Itime are equal to 1000. What is the problem in my code? Why I get error in retur part?

 float cv::Mat Data::HighestTime(float *distances){
        Mat mean_distances; 
        if(Itime=1000){
            for(int i=0; i<5; i++){
                cv::Mat matDistances = Mat(width, height, CV_32FC1, distances);
                Mat mean_distances = matDistances;
                mean_distances = mean_distances * (1/5);

            }
        }
        return mean_distances;
    }

average of some frames/getting error

I want to get average of 5 frames which their Itime are equal to 1000. What is the problem in my code? Why I get error in retur part?

After Editing: cv::Mat Data::HighestTime(float *distances){ Mat mean_distances; if(Itime=1000){ for(int i=0; i<5; i++){ cv::Mat matDistances = Mat(width, height, CV_32FC1, distances); Mat mean_distances = matDistances; mean_distances = mean_distances * (1/5); (1/5);

            }
        }
        return mean_distances;
    }

average of some frames/getting error

I want to get average of 5 frames which their Itime are equal to 1000. What is the problem in my code? Why I get error in retur part?

After Editing: Editing:

 cv::Mat Data::HighestTime(float *distances){
         Mat mean_distances; 
         if(Itime=1000){
             for(int i=0; i<5; i++){
                 cv::Mat matDistances = Mat(width, height, CV_32FC1, distances);
             Mat mean_distances = matDistances;
             mean_distances = mean_distances * (1/5);

(1/5);
         }
     }
     return mean_distances;
 }

average of some frames/getting error

I want to get average of 5 frames which their Itime are equal to 1000. What is the problem in my code? Why I get error in retur part?

After Editing:

 cv::Mat Data::HighestTime(float *distances){
        Mat mean_distances; 
        if(Itime=1000){
            for(int i=0; i<5; i++){
                cv::Mat matDistances = Mat(width, height, CV_32FC1, distances);
            Mat mean_distances = matDistances;
            mean_distances = mean_distances * (1/5);

        }
    }
    return mean_distances;
}

I am going to use the returned value in another function like this:

void Data::Filter(){
  HighestTime(float* distances);
  medianBlur(mean_distances, mean_distances, ksize);
}

It complains that the mean_distances is not defined! should I define it as an argument to the function?

average of some frames/getting error

I want to get average of 5 frames which their Itime are equal to 1000. What is the problem in my code? Why I get error in retur part?

After Editing:

 cv::Mat Data::HighestTime(float *distances){
        Mat mean_distances; 
        if(Itime=1000){
            for(int i=0; i<5; i++){
                cv::Mat matDistances = Mat(width, height, CV_32FC1, distances);
        Mat mean_distances; 
        if(Itime=1000){
            for(int i=0; i<5; i++){
                Mat mean_distances = matDistances;
            mean_distances = mean_distances * (1/5);

        }
    }
    return mean_distances;
}

I am going to use the returned value in another function like this:

void Data::Filter(){
  HighestTime(float* distances);
  medianBlur(mean_distances, mean_distances, ksize);
}

It complains that the mean_distances is not defined! should I define it as an argument to the function?

average of some frames/getting error

I want to get average of 5 frames which their Itime are equal to 1000. What is the problem in my code? Why I get error in retur part?

After Editing:

 cv::Mat Data::HighestTime(float *distances){
        cv::Mat matDistances = Mat(width, height, CV_32FC1, distances);
        Mat mean_distances; 
        if(Itime=1000){
            for(int i=0; i<5; i++){
                Mat mean_distances = matDistances;
            mean_distances = mean_distances * (1/5);

        }
    }
    return mean_distances;
}

I am going to use the returned value in another function like this:

void Data::Filter(){
  HighestTime(float* distances);
  medianBlur(mean_distances, mean_distances, ksize);
}

It complains that the mean_distances is not defined! should I define it as an argument to the function?

To get the average of 5 frames, I changed the code like this:

cv::Mat Data::HighestTime(float *distances){
    cv::Mat matDistances = Mat(m_pmdDevice->GetY(), m_pmdDevice->GetX(), CV_32FC1, distances);
    int NumberOfFrames=5;
    cv::Mat mean_distances = Mat::zeros(m_pmdDevice->GetY(), m_pmdDevice->GetX(), CV_32FC1);
    vector< Mat> matSequence;

    matSequence.push_back(matDistances);       //accumulate frames

    if (matSequence.size() == NumberOfFrames+1) 
    {
        vector<Mat>::iterator it;
        it = matSequence.begin();
        matSequence.erase(it);
        matSequence = matSequence * (1/5);
    }

    return matSequence;
}

Still I get error..

average of some frames/getting error

I want to get average of 5 frames which their Itime are equal to 1000. What is the problem in my code? Why I get error in retur part?

After Editing:

 cv::Mat Data::HighestTime(float *distances){
        cv::Mat matDistances = Mat(width, height, CV_32FC1, distances);
        Mat mean_distances; 
        if(Itime=1000){
            for(int i=0; i<5; i++){
                Mat mean_distances = matDistances;
            mean_distances = mean_distances * (1/5);

        }
    }
    return mean_distances;
}

I am going to use the returned value in another function like this:

void Data::Filter(){
  HighestTime(float* distances);
  medianBlur(mean_distances, mean_distances, ksize);
}

It complains that the mean_distances is not defined! should I define it as an argument to the function?

To get the average of 5 frames, I changed the code like this:

cv::Mat Data::HighestTime(float *distances){
    cv::Mat matDistances = Mat(m_pmdDevice->GetY(), m_pmdDevice->GetX(), CV_32FC1, distances);
    int NumberOfFrames=5;
    cv::Mat mean_distances = Mat::zeros(m_pmdDevice->GetY(), m_pmdDevice->GetX(), Mat::zeros(width, height, CV_32FC1);
    vector< Mat> matSequence;

    matSequence.push_back(matDistances);       //accumulate frames

    if (matSequence.size() == NumberOfFrames+1) 
    {
        vector<Mat>::iterator it;
        it = matSequence.begin();
        matSequence.erase(it);
        matSequence = matSequence * (1/5);
    }

    return matSequence;
}

Still I get error..

average of some frames/getting error

I want to get average of 5 frames which their Itime are equal to 1000. What is the problem in my code? Why I get error in retur part?

After Editing:

 cv::Mat Data::HighestTime(float *distances){
        cv::Mat matDistances = Mat(width, height, CV_32FC1, distances);
        Mat mean_distances; 
        if(Itime=1000){
            for(int i=0; i<5; i++){
                Mat mean_distances = matDistances;
            mean_distances = mean_distances * (1/5);

        }
    }
    return mean_distances;
}

I am going to use the returned value in another function like this:

void Data::Filter(){
  HighestTime(float* distances);
  medianBlur(mean_distances, mean_distances, ksize);
}

It complains that the mean_distances is not defined! should I define it as an argument to the function?

To get the average of 5 frames, I changed the code like this:

cv::Mat Data::HighestTime(float *distances){
    cv::Mat matDistances = Mat(m_pmdDevice->GetY(), m_pmdDevice->GetX(), Mat(width, height, CV_32FC1, distances);
    int NumberOfFrames=5;
    cv::Mat mean_distances = Mat::zeros(width, height, CV_32FC1);
    vector< Mat> matSequence;

    matSequence.push_back(matDistances);       //accumulate frames

    if (matSequence.size() == NumberOfFrames+1) 
    {
        vector<Mat>::iterator it;
        it = matSequence.begin();
        matSequence.erase(it);
        matSequence = matSequence * (1/5);
    }

    return matSequence;
}

Still I get error..

average of some frames/getting error

I want to get average of 5 frames which their Itime are equal to 1000. What is the problem in my code? Why I get error in retur part?

After Editing:

 cv::Mat Data::HighestTime(float *distances){
        cv::Mat matDistances = Mat(width, height, CV_32FC1, distances);
        Mat mean_distances; 
        if(Itime=1000){
            for(int i=0; i<5; i++){
                Mat mean_distances = matDistances;
            mean_distances = mean_distances * (1/5);

        }
    }
    return mean_distances;
}

I am going to use the returned value in another function like this:

void Data::Filter(){
  HighestTime(float* distances);
  medianBlur(mean_distances, mean_distances, ksize);
}

It complains that the mean_distances is not defined! should I define it as an argument to the function?

To get the average of 5 frames, I changed the code like this:

cv::Mat Data::HighestTime(float *distances){
    cv::Mat matDistances = Mat(width, height, CV_32FC1, distances);
    int NumberOfFrames=5;
    cv::Mat mean_distances = Mat::zeros(width, height, CV_32FC1);
    vector< Mat> matSequence;

    matSequence.push_back(matDistances);       //accumulate frames

    if (matSequence.size() == NumberOfFrames+1) 
    {
        vector<Mat>::iterator it;
        it = matSequence.begin();
        matSequence.erase(it);
        matSequence = matSequence * (1/5);
0.2f;
    }

    return matSequence;
}

Still I get error..