martes, 17 de noviembre de 2015

Experiments to see what distance works better 2.0

We wanted to find out which distance was the best one in order to get better results. For the next four experiments we used this resolution: 2448 x 3264. We used this program to calculate the lengths: 


#include <iostream>
using namespace std;
float lmc, lmp, lop, w, h;

void calc_length(float a, float b, double c){
    double scale, loc;
    scale= a/b; //We get how many centimeters a pixels is
    loc= c*scale;
    cout<<"The length of your object is of: "<<loc<<" cm. "<<loc*0.39370079<<" inches.";
}

int main() {
    cout<<"I give the lengths of an object in centimeters and inches, or angles in radians and degrees, all of this using a digital picture with a marker information."<<endl<<endl;
    cout<<"Tell me the length of your marker (in cm.): ";
    cin>>lmc;
    cout<<"Tell me the length of your marker (in pixels): ";
    cin>>lmp;
    cout<<"Tell me the length of your object (in pixels): ";
    cin>>lop;
    while(((lmp>=2448)&&(lmp>=3264))||((lop>=2448)&&(lop>=3264))){
        cout<<"You are giving a pixel size of one of your objects bigger than your actual image, the objects you want to measure MUST be inside the image.\n";
        cout<<"Tell me again the length of your marker (in pixels): ";
        cin>>lmp;
        cout<<"Tell me again the length of your object (in pixels): ";
        cin>>lop;
    }
    calc_length(lmc, lmp, lop);//We still need to make the program to only show either measures or angles

}

This program to calculate de %error: 

#include <iostream>
using namespace std;
float mr, mo, per;

int main() {
    cout<<"Value of measure with ruler (real value): ";
    cin>>mr;
    cout<<"Value of measure obtained: ";
    cin>>mo;
    per=((mr-mo)/mr)*100;
    cout<<"The error obtained was of: "<<per<<"%"<<endl<<endl;
    return 0;

}



And from the following image:


We measured the red lines on the paper (one of 10 cm. and the other one of 25 cm.) and this area of the small agenda:


And we obtained the following results:




So now we now that if you get closer to the object you'll get better results.

*The biggest object in the image is the length from corner to corner
*Inclination of the camera of 0º with respect of the objects.



As conclusion, the closer you get to the image, the %error decreases. So we are now going to work with a distance of 1 meter away from our object.








No hay comentarios:

Publicar un comentario