martes, 10 de noviembre de 2015

Beginning Again (Lengths)

Resolution

After today classes we started to do new experiments, in order to accomplish all of the requirements.  First we took the same picture with three different cameras (different resolutions) to see which one gave us a smaller error percentage.

The next four experiments were measured with the following program:

#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<<"What is the resolution of the image:\n";
    cout<<"W: ";
    cin>>w;
    cout<<"H: ";
    cin>>h;
    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>=w)&&(lmp>=h))||((lop>=w)&&(lop>=h))){
        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

}

To calculate the %error we used the following program:

#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;

}


The picture we used is this one:



1.-
Resolution: 1936 x 2592 pixels.
Marker size: 21cm.-256 pixels.
Object size: 754 pixels.
Inclination of the camera of 0º with respect of the object.
Distance from the object: 2 meters.

Actual size of the object I want to measure: 60 cm. - 23.62 inches.
%Error: 3.086%
1 pixel :: 0.082031 cm

2.-
Resolution: 2448 x 3264 pixels.
Marker size: 21cm.-318 pixels.
Object size: 919 pixels.
Inclination of the camera of 0º with respect of the object.
Distance from the object: 2 m.

Actual size of the object I want to measure: 60 cm. - 23.62 inches.
%Error: 1.1478%
1 pixel :: 0.066038 cm.

3.-
Resolution: 720 x 960 pixels.
Marker size: 21cm.-115 pixels.
Object size: 342 pixels.
Inclination of the camera of 0º with respect of the object.
Distance from the object: 2m.

Actual size of the object I want to measure: 60 cm.- 23.62 inches.
%Error: 4.087%
1 pixel :: 0.182608

As our best experiment was #2 we decided to do another experiment to prove that we will get better results with that resolution (2448 x 3264 pixels). And this is the picture for that last experiment:



4.-
Resolution: 2448 x 3264 pixels.
Marker size: 21cm.-338 pixels.
Object size: 485 pixels.
Inclination of the camera of 0º with respect of the object.
Distance from the object: 2 m.

Actual size of the object I want to measure: 30 cm.- 11.8110 inches.
%Error: 0.44366%
1 pixel :: 0.062130 cm.

So we are going to keep working with this camera of 2448 x 3264 pixels. Because it gave us better results.




No hay comentarios:

Publicar un comentario