Skip to content
Permalink
Browse files

Implement Metrilus.Util changes (#198)

  • Loading branch information...
sisiplac authored and jangernert committed Aug 2, 2019
1 parent 72128c0 commit 3328fc08d7a89ff35476014a1385ea183bc824d2
Showing with 328 additions and 343 deletions.
  1. +2 −2 BetaCameras/BaslerACE/BaslerACE.cs
  2. +12 −12 BetaCameras/BaslerToF/BaslerToF.cs
  3. +5 −4 BetaCameras/CameraTemplate/CameraTemplate.cs
  4. +2 −1 BetaCameras/CameraTemplate/CameraTemplate.csproj
  5. +18 −18 BetaCameras/Kinect2/Kinect2.cs
  6. +14 −14 BetaCameras/Kinect4Azure/Kinect4Azure.cs
  7. +29 −29 BetaCameras/MatrixVision/MvBlueSirius.cpp
  8. +15 −15 BetaCameras/MatrixVision/MvBlueSirius.h
  9. +20 −20 BetaCameras/OrbbecOpenNI/OrbbecOpenNI.cpp
  10. +11 −11 BetaCameras/OrbbecOpenNI/OrbbecOpenNI.h
  11. +9 −9 BetaCameras/Pico/Zense.cs
  12. +6 −6 BetaCameras/RealSense/F200.cs
  13. +8 −8 BetaCameras/RealSense/R200.cs
  14. +17 −19 BetaCameras/RealSense2/RealSense2.cs
  15. +16 −16 BetaCameras/SVS/SVS.cs
  16. +5 −5 BetaCameras/Sick.TiM561/TiM561.cs
  17. +9 −9 BetaCameras/Sick.VisionaryT.Pro/VisionaryTPro.cs
  18. +17 −17 BetaCameras/Sick.VisionaryT/VisionaryT.cs
  19. +19 −19 BetaCameras/TIVoxel/TIVoxel.cpp
  20. +13 −13 BetaCameras/TIVoxel/TIVoxel.h
  21. +14 −14 BetaCameras/UEye/UEyeCamera.cs
  22. +2 −2 BetaCameras/WebCam/WebCam.h
  23. +4 −4 BetaCameras/Xtion2/OpenNI2CApi.cs
  24. +1 −1 BetaCameras/Xtion2/Xtion2.cs
  25. +17 −17 BetaCameras/ifm/O3D3xx.cs
  26. +16 −16 MetriCam2/Camera.cs
  27. +13 −13 MetriCam2/ChannelRegistry.cs
  28. +0 −8 Samples/MinimalSample/MinimalSample.csproj
  29. +3 −10 Samples/MinimalSample/Program.cs
  30. +8 −8 Samples/SimpleViewer/SimpleViewer.cs
  31. +3 −3 doc/code_snippets.md
  32. BIN lib/Metrilus.Util.dll
  33. BIN lib_netstandard2.0/Metrilus.Util.dll
  34. BIN lib_strongname/Metrilus.Util.dll
@@ -150,12 +150,12 @@ protected override void UpdateImpl()
}
}

protected override CameraImage CalcChannelImpl(string channelName)
protected override ImageBase CalcChannelImpl(string channelName)
{
switch (channelName)
{
case ChannelNames.Color:
return new ColorCameraImage(_bitmap);
return new ColorImage(_bitmap);
}

log.Error($"{Name}: Unexpected ChannelName in CalcChannel().");
@@ -18,10 +18,10 @@ public class BaslerToF : Camera
private Coord3D[] bufferPoint3f;
private AutoResetEvent dataAvailable = new AutoResetEvent(false);

private FloatCameraImage distanceImage;
private UShortCameraImage intensityImage;
private UShortCameraImage confidenceImage;
private Point3fCameraImage point3fImage;
private FloatImage distanceImage;
private UShortImage intensityImage;
private UShortImage confidenceImage;
private Point3fImage point3fImage;

private Object dataLock = new Object();

@@ -445,7 +445,7 @@ protected override void UpdateImpl()
{
if (IsChannelActive(ChannelNames.Point3DImage))
{
point3fImage = new Point3fCameraImage(width, height);
point3fImage = new Point3fImage(width, height);
for (int y = 0, i = 0; y < height; y++)
{
for (int x = 0; x < width; x++, i++)
@@ -458,7 +458,7 @@ protected override void UpdateImpl()

if (IsChannelActive(ChannelNames.Distance))
{
distanceImage = new FloatCameraImage(width, height);
distanceImage = new FloatImage(width, height);
for (int y = 0, i = 0; y < height; y++)
{
for (int x = 0; x < width; x++, i++)
@@ -471,7 +471,7 @@ protected override void UpdateImpl()

if (IsChannelActive(ChannelNames.Intensity))
{
intensityImage = new UShortCameraImage(width, height);
intensityImage = new UShortImage(width, height);

for (int y = 0, i = 0; y < height; y++)
{
@@ -484,7 +484,7 @@ protected override void UpdateImpl()

if (IsChannelActive(ChannelNames.ConfidenceMap))
{
confidenceImage = new UShortCameraImage(width, height);
confidenceImage = new UShortImage(width, height);

for (int y = 0, i = 0; y < height; y++)
{
@@ -504,7 +504,7 @@ protected override void UpdateImpl()
/// <param name="channelName">Channel name.</param>
/// <returns>(Image) Data.</returns>
/// <seealso cref="Camera.CalcChannel"/>
protected override CameraImage CalcChannelImpl(string channelName)
protected override ImageBase CalcChannelImpl(string channelName)
{
switch (channelName)
{
@@ -513,7 +513,7 @@ protected override CameraImage CalcChannelImpl(string channelName)
case ChannelNames.Distance:
return distanceImage;
case ChannelNames.Intensity:
return intensityImage.ToFloatCameraImage();
return intensityImage.ToFloatImage();
case ChannelNames.Point3DImage:
return point3fImage;
}
@@ -528,13 +528,13 @@ protected override CameraImage CalcChannelImpl(string channelName)
/// </summary>
/// <param name="rawConfidenceMap">16-bit unsigned int raw confidence map as provided by camera</param>
/// <returns>Confidence map as float image with intensities between 0 and 1</returns>
private FloatCameraImage CalcConfidenceMap(UShortCameraImage rawConfidenceMap)
private FloatImage CalcConfidenceMap(UShortImage rawConfidenceMap)
{
int width = rawConfidenceMap.Width;
int height = rawConfidenceMap.Height;
float scaling = 1.0f / ushort.MaxValue;

FloatCameraImage confidenceMap = new FloatCameraImage(width, height);
FloatImage confidenceMap = new FloatImage(width, height);
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
@@ -3,6 +3,7 @@

using Metrilus.Util;
using System;
using System.Drawing;

namespace MetriCam2.Cameras
{
@@ -414,7 +415,7 @@ protected override void LoadAllAvailableChannels()

log.Warn(Name + ": TODO: Implement LoadAllAvailableChannels().");
Channels.Add(cr.RegisterChannel(ChannelNames.Intensity));
Channels.Add(cr.RegisterCustomChannel(CustomChannelNames.DummyNoiseChannel, typeof(FloatCameraImage)));
Channels.Add(cr.RegisterCustomChannel(CustomChannelNames.DummyNoiseChannel, typeof(FloatImage)));
}

/// <summary>
@@ -455,7 +456,7 @@ protected override void UpdateImpl()
/// <param name="channelName">Channel name.</param>
/// <returns>(Image) Data.</returns>
/// <seealso cref="Camera.CalcChannel"/>
protected override CameraImage CalcChannelImpl(string channelName)
protected override ImageBase CalcChannelImpl(string channelName)
{
log.Warn(Name + ": TODO: Implement CalcChannel().");
switch (channelName)
@@ -472,9 +473,9 @@ protected override CameraImage CalcChannelImpl(string channelName)
/// <summary>Computes (image) data for the fake Noise channel.</summary>
/// <returns>Noisy image data.</returns>
/// <seealso cref="Camera.CalcChannel"/>
private FloatCameraImage CalcDummyNoiseChannel()
private FloatImage CalcDummyNoiseChannel()
{
FloatCameraImage dummyNoiseImage = new FloatCameraImage(__noiseImageWidth, __noiseImageHeight);
FloatImage dummyNoiseImage = new FloatImage(__noiseImageWidth, __noiseImageHeight);
// TODO: Add channel data (here: noise)
return dummyNoiseImage;
}
@@ -60,6 +60,7 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -92,4 +93,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
@@ -168,8 +168,8 @@ protected override void LoadAllAvailableChannels()
Channels.Add(cr.RegisterChannel(ChannelNames.Distance));
Channels.Add(cr.RegisterChannel(ChannelNames.Color));
Channels.Add(cr.RegisterChannel(ChannelNames.Point3DImage));
Channels.Add(cr.RegisterCustomChannel(CustomChannelNames.LongExposureIR, typeof(FloatCameraImage)));
Channels.Add(cr.RegisterCustomChannel(CustomChannelNames.BodyIndex, typeof(FloatCameraImage)));
Channels.Add(cr.RegisterCustomChannel(CustomChannelNames.LongExposureIR, typeof(FloatImage)));
Channels.Add(cr.RegisterCustomChannel(CustomChannelNames.BodyIndex, typeof(FloatImage)));
}

/// <summary>
@@ -553,7 +553,7 @@ protected override void UpdateImpl()
/// <param name="channelName">Channel name.</param>
/// <returns>(Image) Data.</returns>
/// <seealso cref="Camera.CalcChannel"/>
protected override CameraImage CalcChannelImpl(string channelName)
protected override ImageBase CalcChannelImpl(string channelName)
{
switch (channelName)
{
@@ -580,9 +580,9 @@ protected override CameraImage CalcChannelImpl(string channelName)
/// <param name="channelName">The channel name.</param>
/// <returns>The ProjectiveTransformationRational</returns>
/// <remarks>The method first searches for a pt file on disk. If this fails it is able to provide internal intrinsics for amplitude / depth channel.</remarks>
public override IProjectiveTransformation GetIntrinsics(string channelName)
public override ProjectiveTransformation GetIntrinsics(string channelName)
{
IProjectiveTransformation result = null;
ProjectiveTransformation result = null;

log.Info("Trying to load projective transformation from file.");
try
@@ -616,7 +616,7 @@ public override IProjectiveTransformation GetIntrinsics(string channelName)
/// Read out the factory intrinsics for the IR/Depth channel. The principal point in x-direction depends on the prperty <see cref="FlipX"/.>
/// </summary>
/// <returns>Factory IR intrinsics.</returns>
public IProjectiveTransformation GetFactoryIRIntrinsics()
public ProjectiveTransformation GetFactoryIRIntrinsics()
{
CameraIntrinsics intrinsics = Coordinates.GetDepthCameraIntrinsics();
for (int i = 0; i < 100 && intrinsics.FocalLengthX == 0; i++)
@@ -703,11 +703,11 @@ protected void CalcDistanceMap()
/// Calculates the distance data for the current frame.
/// </summary>
/// <returns>Distance map with dimensions Width and Height.</returns>
protected virtual FloatCameraImage CalcDistances()
protected virtual FloatImage CalcDistances()
{
CalcDistanceMap();

FloatCameraImage img = new FloatCameraImage(depthWidth, depthHeight);
FloatImage img = new FloatImage(depthWidth, depthHeight);

lock (this.depthFrameData)
{
@@ -728,7 +728,7 @@ protected virtual FloatCameraImage CalcDistances()
/// Calculates the color image for the current frame.
/// </summary>
/// <returns>Color image.</returns>
protected virtual unsafe ColorCameraImage CalcColor()
protected virtual unsafe ColorImage CalcColor()
{
lock (this.colorFrameData)
{
@@ -741,13 +741,13 @@ protected virtual unsafe ColorCameraImage CalcColor()
bmp.UnlockBits(bData);
bmp.RotateFlip(RotateFlipType.RotateNoneFlipX); //Kinect images are flipped in x-direction

return new ColorCameraImage(bmp);
return new ColorImage(bmp);
}
}

protected virtual FloatCameraImage CalcAmplitudes()
protected virtual FloatImage CalcAmplitudes()
{
FloatCameraImage img = new FloatCameraImage(depthWidth, depthHeight);
FloatImage img = new FloatImage(depthWidth, depthHeight);

lock (this.irFrameData)
{
@@ -844,10 +844,10 @@ private void OpenMultiReader()
/// </summary>
/// <returns>3-D point coordinates in meters.</returns>
/// <remarks>Format is [height, width, coordinate] with coordinate in {0,1,2} for x, y and z.</remarks>
private Point3fCameraImage Calc3DCoordinates()
private Point3fImage Calc3DCoordinates()
{
CameraSpacePoint[] worldPoints = new CameraSpacePoint[depthHeight * depthWidth];
Point3fCameraImage img = new Point3fCameraImage(depthWidth, depthHeight);
Point3fImage img = new Point3fImage(depthWidth, depthHeight);

lock (this.depthFrameData)
{
@@ -866,9 +866,9 @@ private Point3fCameraImage Calc3DCoordinates()
return img;
}

private FloatCameraImage CalcBodyIndex()
private FloatImage CalcBodyIndex()
{
FloatCameraImage result = new FloatCameraImage(depthWidth, depthHeight);
FloatImage result = new FloatImage(depthWidth, depthHeight);

for (int y = 0; y < this.depthHeight; y++)
{
@@ -883,9 +883,9 @@ private FloatCameraImage CalcBodyIndex()
return result;
}

private FloatCameraImage CalcLongExposureIR()
private FloatImage CalcLongExposureIR()
{
FloatCameraImage result = new FloatCameraImage(depthWidth, depthHeight);
FloatImage result = new FloatImage(depthWidth, depthHeight);

for (int y = 0; y < this.depthHeight; y++)
{
@@ -21,7 +21,7 @@ public class Kinect4Azure : Camera, IDisposable
private object _lock = new object();

private Dictionary<string, RigidBodyTransformation> _extrinsicsCache = new Dictionary<string, RigidBodyTransformation>();
private Dictionary<string, IProjectiveTransformation> _intrinsicsCache = new Dictionary<string, IProjectiveTransformation>();
private Dictionary<string, ProjectiveTransformation> _intrinsicsCache = new Dictionary<string, ProjectiveTransformation>();
private K4AColorResolution _lastValidColorResolution = K4AColorResolution.r720p; //Last valid mode != off
private K4ADepthMode _lastValidDepthMode = K4ADepthMode.WFOV_Unbinned; //Last valid mode != off

@@ -315,7 +315,7 @@ protected override void UpdateImpl()
}
}

protected override CameraImage CalcChannelImpl(string channelName)
protected override ImageBase CalcChannelImpl(string channelName)
{
if (null == _capture)
{
@@ -340,7 +340,7 @@ protected override CameraImage CalcChannelImpl(string channelName)
throw new ImageAcquisitionFailedException($"Channel {channelName} not supported!");
}

unsafe private ColorCameraImage CalcColor()
unsafe private ColorImage CalcColor()
{
if (_capture.Color == null)
{
@@ -375,10 +375,10 @@ unsafe private ColorCameraImage CalcColor()
}

bitmap.UnlockBits(bmpData);
return new ColorCameraImage(bitmap);
return new ColorImage(bitmap);
}

unsafe private FloatCameraImage CalcZImage()
unsafe private FloatImage CalcZImage()
{
if (_capture.Depth == null)
{
@@ -393,7 +393,7 @@ unsafe private FloatCameraImage CalcZImage()
throw new ImageAcquisitionFailedException($"Expected format Depth16, found format {_capture.Depth.Format.ToString()}");
}

FloatCameraImage depthData = new FloatCameraImage(width, height);
FloatImage depthData = new FloatImage(width, height);
short* source = (short*)_capture.Depth.Buffer;

for (int i = 0; i < depthData.Length; i++)
@@ -404,7 +404,7 @@ unsafe private FloatCameraImage CalcZImage()
return depthData;
}

unsafe private FloatCameraImage CalcIntensityImage()
unsafe private FloatImage CalcIntensityImage()
{
int height = _capture.IR.HeightPixels;
int width = _capture.IR.WidthPixels;
@@ -414,7 +414,7 @@ unsafe private FloatCameraImage CalcIntensityImage()
throw new ImageAcquisitionFailedException($"Expected format IR16, found format {_capture.IR.Format.ToString()}");
}

FloatCameraImage irData = new FloatCameraImage(width, height);
FloatImage irData = new FloatImage(width, height);
short* source = (short*)_capture.IR.Buffer;

for (int i = 0; i < irData.Length; i++)
@@ -425,15 +425,15 @@ unsafe private FloatCameraImage CalcIntensityImage()
return irData;
}

private FloatCameraImage CalcDistanceImage()
private FloatImage CalcDistanceImage()
{
FloatCameraImage zImage = CalcZImage();
FloatImage zImage = CalcZImage();
ProjectiveTransformationRational projTrans = GetIntrinsics(ChannelNames.ZImage) as ProjectiveTransformationRational;
Point3fCameraImage p3fImage = projTrans.ZImageToWorld(zImage);
return p3fImage.ToFloatCameraImage();
Point3fImage p3fImage = projTrans.ZImageToWorld(zImage);
return p3fImage.ToFloatImage();
}

public override IProjectiveTransformation GetIntrinsics(string channelName)
public override ProjectiveTransformation GetIntrinsics(string channelName)
{
string keyName = channelName == ChannelNames.Color ? $"{channelName}_{ColorResolution.ToString()}" : $"{channelName}_{DepthMode.ToString()}";
if (_intrinsicsCache.ContainsKey(keyName) && _intrinsicsCache[keyName] != null)
@@ -471,7 +471,7 @@ public override IProjectiveTransformation GetIntrinsics(string channelName)
throw new System.Exception(msg);
}

IProjectiveTransformation projTrans = new ProjectiveTransformationRational(
ProjectiveTransformation projTrans = new ProjectiveTransformationRational(
width,
height,
intrinsics.parameters[(int)Intrinsics.Fx],

0 comments on commit 3328fc0

Please sign in to comment.
You can’t perform that action at this time.