This was working fine until I updated from v1.8.0 to v2.0.0: now I get the same pose failure as recently posted in this forum topic.
That is, the 'if (poseResult == MLResult.Code.Ok)' evaluation in the following method returns false:
private void OnCaptureRawImageComplete(MLCamera.CameraOutput capturedImage, MLCamera.ResultExtras resultExtras, MLCamera.Metadata metadataHandle)
{
Log("Image capture complete.");
// Adjust the directory path to include 'capture'
string directoryPath = Path.Combine(Application.persistentDataPath, "capture");
// Check if the 'capture' directory exists, create it if needed
if (!Directory.Exists(directoryPath))
{
Directory.CreateDirectory(directoryPath);
}
// Adjust file paths to use the updated directoryPath
string fileName = $"{resultExtras.VCamTimestamp}.txt";
string filePath = Path.Combine(directoryPath, fileName);
string imagePath = Path.Combine(directoryPath, $"{resultExtras.VCamTimestamp}.png");
File.WriteAllBytes(imagePath, capturedImage.Planes[0].Data);
Log($"Image saved to {imagePath}");
// Attempt to get the camera pose
if (resultExtras.VCamTimestamp > 0)
{
Matrix4x4 outTransform;
MLResult poseResult = MLCVCamera.GetFramePose(resultExtras.VCamTimestamp, out outTransform);
if (poseResult == MLResult.Code.Ok)
{
// Prepare the content for the file
string fileContent = "intrinsics\n";
fileContent += resultExtras.Intrinsics.HasValue ? resultExtras.Intrinsics.Value.ToString() : "Not Available";
fileContent += "\nextrinsics\n";
fileContent += outTransform.ToString();
// Write to the file
File.WriteAllText(filePath, fileContent);
Log($"Data saved to {filePath}");
}
else
{
Log($"Failed to obtain camera pose: {poseResult}");
}
}
else
{
Log("VCamTimestamp is not valid.");
}
}