Skip to content

Commit

Permalink
Revert "Handle 10p conversion"
Browse files Browse the repository at this point in the history
This reverts commit 06fc7ee.
  • Loading branch information
bruno-f-cruz committed Nov 9, 2024
1 parent 9ae4ed6 commit bc577ef
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 69 deletions.
67 changes: 0 additions & 67 deletions src/AllenNeuralDynamics.Core/AindSpinnakerCapture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,73 +109,6 @@ private void SetRegionOfInterest(IManagedCamera camera)
camera.OffsetY.Value = RegionOfInterest.Y;
}
}

static Func<IManagedImage, IplImage> GetConverter(PixelFormatEnums pixelFormat, Bonsai.Spinnaker.ColorProcessingAlgorithm colorProcessing)
{
int outputChannels;
IplDepth outputDepth;
if (pixelFormat < PixelFormatEnums.BayerGR8 || pixelFormat == PixelFormatEnums.BGR8 ||
pixelFormat <= PixelFormatEnums.BayerBG16 && colorProcessing == Bonsai.Spinnaker.ColorProcessingAlgorithm.NoColorProcessing)
{
if (pixelFormat == PixelFormatEnums.BGR8)
{
outputChannels = 3;
outputDepth = IplDepth.U8;
}
else
{
outputChannels = 1;
var depthFactor = (int)pixelFormat;
if (pixelFormat > PixelFormatEnums.Mono16) depthFactor = (depthFactor - 3) / 4;
outputDepth = (IplDepth)(8 * (depthFactor + 1));
}

return image =>
{
var width = (int)image.Width;
var height = (int)image.Height;
using (var bitmapHeader = new IplImage(new Size(width, height), outputDepth, outputChannels, image.DataPtr))
{
var output = new IplImage(bitmapHeader.Size, outputDepth, outputChannels);
CV.Copy(bitmapHeader, output);
return output;
}
};
}

PixelFormatEnums outputFormat;
if (pixelFormat == PixelFormatEnums.Mono10p ||
pixelFormat == PixelFormatEnums.Mono10Packed ||
pixelFormat == PixelFormatEnums.Mono12p ||
pixelFormat == PixelFormatEnums.Mono12Packed)
{
outputFormat = PixelFormatEnums.Mono16;
outputDepth = IplDepth.U16;
outputChannels = 1;
}
else if (pixelFormat >= PixelFormatEnums.BayerGR8 && pixelFormat <= PixelFormatEnums.BayerBG16)
{
outputFormat = PixelFormatEnums.BGR8;
outputDepth = IplDepth.U8;
outputChannels = 3;
}
else throw new InvalidOperationException(string.Format("Unable to convert pixel format {0}.", pixelFormat));

return image =>
{
var width = (int)image.Width;
var height = (int)image.Height;
var output = new IplImage(new Size(width, height), outputDepth, outputChannels);
unsafe
{
using (var destination = new ManagedImage((uint)width, (uint)height, 0, 0, outputFormat, output.ImageData.ToPointer()))
{
image.Convert(destination, outputFormat, (SpinnakerNET.ColorProcessingAlgorithm)colorProcessing);
return output;
}
}
};
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/AllenNeuralDynamics.Core/AllenNeuralDynamics.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
<PackageTags>Bonsai Rx Core AllenNeuralDynamics</PackageTags>
<TargetFramework>net472</TargetFramework>
<Features>strict</Features>
<Version>0.2.8-preview01</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Version>0.2.7</Version>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit bc577ef

Please sign in to comment.