Skip to content
Snippets Groups Projects
Commit c6a835ef authored by GGomez99's avatar GGomez99
Browse files

Fix FOV calibration

parent 720c8e34
No related branches found
No related tags found
No related merge requests found
......@@ -70,7 +70,7 @@ public class WebcamCalibration : MonoBehaviour
SceneManager.LoadScene("CalibrateCamera");
}
void switchCalibrationMode()
void toggleCalibrationMode()
{
doCalibrate = !doCalibrate;
......@@ -83,7 +83,11 @@ public class WebcamCalibration : MonoBehaviour
if (doCalibrate)
{
loadWebcamParams();
//init on FOV calib
doCalibrateFOV = false;
InvokeRepeating("calibrateAxis", 0.5f, 1f);
ScreenWebcamScript.stopCam();
foreach (ConfigurableController ARController in ArucoWebcamScripts)
{
......@@ -95,6 +99,7 @@ public class WebcamCalibration : MonoBehaviour
if (!doCalibrate)
{
CancelInvoke();
doCalibrateFOV = false;
foreach (ConfigurableController ARController in ArucoWebcamScripts)
{
if (ARController.IsStarted) //some controllers can stop others
......@@ -148,21 +153,21 @@ public class WebcamCalibration : MonoBehaviour
float OTAngle = Mathf.Atan(OTPosVert.y / OTPosVert.z);
//get correcting angle for FOV
float correctAngleDeg = ARucoWebcam.fieldOfView * OTAngle / ARAngle;
float correctAngleRatio = OTAngle / ARAngle;
//add to list of measures
FOVCorrectionData.Add(correctAngleDeg);
FOVCorrectionData.Add(correctAngleRatio);
FOVCorrectionData.Sort();
//get maximum angle correction
float maxAngle = FOVCorrectionData[FOVCorrectionData.Count - 1];
//get median angle correction
float medianRatio = FOVCorrectionData[FOVCorrectionData.Count / 2];
//apply correction to webcam camera
WebcamDisplay.fieldOfView = ARucoWebcam.fieldOfView + maxAngle;
WebcamDisplay.fieldOfView = ARucoWebcam.fieldOfView * medianRatio;
WebcamInfosText.text = "FOV Calibration \n \n" +
"Angles tracked : " + FOVCorrectionData.Count + "\n" +
"Corrected vertical FOV : " + WebcamDisplay.fieldOfView + " \n" +
"(R) Reset all \n" +
"(R) Reset FOV data only \n" +
"(W) Back to main scene \n" +
"(S) Switch to Axis calib.";
......@@ -186,7 +191,7 @@ public class WebcamCalibration : MonoBehaviour
WebcamInfosText.text = "Axis Calibration \n \n" +
"Positions tracked : " + calibrationData.Count + "\n" +
"Deviation : " + System.Math.Round(meanDeviation / calibrationData.Count, 4) + " \n" +
"(R) Reset all \n" +
"(R) Reset all data \n" +
"(W) Back to main scene \n" +
"(S) Switch to FOV calib.";
} else
......@@ -194,7 +199,7 @@ public class WebcamCalibration : MonoBehaviour
WebcamInfosText.text = "Axis Calibration \n \n" +
"Positions tracked : 0 \n" +
"Deviation : 0 \n" +
"(R) Reset all \n" +
"(R) Reset all data \n" +
"(W) Back to main scene \n" +
"(S) Switch to FOV calib.";
}
......@@ -212,7 +217,7 @@ public class WebcamCalibration : MonoBehaviour
WebcamInfosText.text = "FOV Calibration \n \n" +
"Angles tracked : " + FOVCorrectionData.Count + "\n" +
"Vertical FOV : " + WebcamDisplay.fieldOfView + " \n" +
"(R) Reset all \n" +
"(R) Reset FOV data only \n" +
"(W) Back to main scene \n" +
"(S) Switch to Axis calib.";
} else
......@@ -232,7 +237,7 @@ public class WebcamCalibration : MonoBehaviour
if (Input.GetKeyDown(KeyCode.W))
{
switchCalibrationMode();
toggleCalibrationMode();
}
if (doCalibrate)
{
......@@ -244,9 +249,20 @@ public class WebcamCalibration : MonoBehaviour
calibrationData.Clear();
}
FOVCorrectionData.Clear();
WebcamInfosText.text = (doCalibrateFOV ? "FOV Calibration" : "Axis Calibration") + "\n \n" +
"Reset data done \n" +
"Please calibrate new value";
WebcamInfosText.text = (doCalibrateFOV ?
"FOV Calibration \n \n" +
"Angles tracked : " + FOVCorrectionData.Count + "\n" +
"Corrected vertical FOV : " + WebcamDisplay.fieldOfView + " \n" +
"(R) Reset FOV data only \n" +
"(W) Back to main scene \n" +
"(S) Switch to Axis calib." :
"Axis Calibration \n \n" +
"Positions tracked : 0 \n" +
"Deviation : 0 \n" +
"(R) Reset all data \n" +
"(W) Back to main scene \n" +
"(S) Switch to FOV calib.");
}
if (Input.GetKeyDown(KeyCode.S))
......
fileFormatVersion: 2
guid: a2ce86204bf26e341b2ecf5e71890fd8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1953259897 &8574412962073106934
TerrainLayer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: layer_Sand 118c7f28bcf2878ea
m_DiffuseTexture: {fileID: 2800000, guid: dfa00e7ed2c3ac148bb645a9e98e8e64, type: 3}
m_NormalMapTexture: {fileID: 0}
m_MaskMapTexture: {fileID: 0}
m_TileSize: {x: 25, y: 25}
m_TileOffset: {x: 0, y: 0}
m_Specular: {r: 0, g: 0, b: 0, a: 0}
m_Metallic: 0
m_Smoothness: 0
m_NormalScale: 1
m_DiffuseRemapMin: {x: 0, y: 0, z: 0, w: 0}
m_DiffuseRemapMax: {x: 1, y: 1, z: 1, w: 1}
m_MaskMapRemapMin: {x: 0, y: 0, z: 0, w: 0}
m_MaskMapRemapMax: {x: 1, y: 1, z: 1, w: 1}
fileFormatVersion: 2
guid: ba34a3a70bf8e424cb512d2fa184ef68
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 8574412962073106934
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1953259897 &8574412962073106934
TerrainLayer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: layer_Sand 218c7f28bcf2878ea
m_DiffuseTexture: {fileID: 2800000, guid: 5461d399a38c0ad42b70028dce1636a8, type: 3}
m_NormalMapTexture: {fileID: 0}
m_MaskMapTexture: {fileID: 0}
m_TileSize: {x: 25, y: 25}
m_TileOffset: {x: 0, y: 0}
m_Specular: {r: 0, g: 0, b: 0, a: 0}
m_Metallic: 0
m_Smoothness: 0
m_NormalScale: 1
m_DiffuseRemapMin: {x: 0, y: 0, z: 0, w: 0}
m_DiffuseRemapMax: {x: 1, y: 1, z: 1, w: 1}
m_MaskMapRemapMin: {x: 0, y: 0, z: 0, w: 0}
m_MaskMapRemapMax: {x: 1, y: 1, z: 1, w: 1}
fileFormatVersion: 2
guid: b2c5a2ea6763d3b42982d8fa6be15e6f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 8574412962073106934
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1953259897 &8574412962073106934
TerrainLayer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: layer_Sand 33d3aba195e4d26ee
m_DiffuseTexture: {fileID: 2800000, guid: 6bd946e608e4ac348a11f3e4da184f3d, type: 3}
m_NormalMapTexture: {fileID: 0}
m_MaskMapTexture: {fileID: 0}
m_TileSize: {x: 15, y: 15}
m_TileOffset: {x: 0, y: 0}
m_Specular: {r: 0, g: 0, b: 0, a: 0}
m_Metallic: 0
m_Smoothness: 0
m_NormalScale: 1
m_DiffuseRemapMin: {x: 0, y: 0, z: 0, w: 0}
m_DiffuseRemapMax: {x: 1, y: 1, z: 1, w: 1}
m_MaskMapRemapMin: {x: 0, y: 0, z: 0, w: 0}
m_MaskMapRemapMax: {x: 1, y: 1, z: 1, w: 1}
fileFormatVersion: 2
guid: 732b4a67bc1d7c94ba5fbdf9fdabfc39
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 8574412962073106934
userData:
assetBundleName:
assetBundleVariant:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment