Skip to content

Commit

Permalink
Added support for RGGB bayer pattern if the user requests it. Default…
Browse files Browse the repository at this point in the history
… is still BGGR as SBIG-aware applications expect it.
  • Loading branch information
cedric-r committed Sep 10, 2021
1 parent df99dcf commit fb4ac93
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 26 deletions.
6 changes: 3 additions & 3 deletions ASCOM.HomeMade.SBIGCamera.iss
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[Setup]
AppID={{3a7e63ad-c913-44f0-9489-e1744c9c2991}}
AppName=ASCOM HomeMade Camera
AppVerName=ASCOM HomeMade SBig Camera Driver 1.0.8
AppVersion=1.0.8
AppVerName=ASCOM HomeMade SBig Camera Driver 1.1.0
AppVersion=1.1.0
AppPublisher=Cedric Raguenaud <cedric@raguenaud.earth>
AppPublisherURL=mailto:cedric@raguenaud.earth
AppSupportURL=https://github.com/cedric-r/ASCOM.HomeMade.SBIGCamera
AppUpdatesURL=https://github.com/cedric-r/ASCOM.HomeMade.SBIGCamera
VersionInfoVersion=1.0.8
VersionInfoVersion=1.1.0
MinVersion=0,6.1
DefaultDirName="{cf}\ASCOM\Camera\HomeMade SBIGCamera\"
DisableDirPage=yes
Expand Down
1 change: 1 addition & 0 deletions ASCOM.HomeMade.SBIGClient/ASCOM.HomeMade.SBIGClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<Compile Include="ImageTakerThread.cs" />
<Compile Include="ISBIGCameraSpecs.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SBIGBayerPattern.cs" />
<Compile Include="SBIGClient.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions ASCOM.HomeMade.SBIGClient/ISBIGCameraSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ protected CameraInfo GetCameraSpecs()
}
return cameraInfo;
}

public virtual SBIGBayerPattern GetBayerPattern()
{
return SBIGBayerPattern.Mono;
}
}

public class CameraInfo
Expand Down
29 changes: 14 additions & 15 deletions ASCOM.HomeMade.SBIGClient/ImageTakerThread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,20 @@ public void TakeImage()
for (int j = 0; j < exposureParams2.height; j++)
camera.cameraImageArray.SetValue((Int32)(UInt16)data[(j * exposureParams2.width) + i], i, j);

if (camera.cameraInfo.colourCamera)
{
if (camera.cameraInfo.bayer != CameraInfo.TRUESENSE)
{
// If we have a colour camera that isn't TRUESENSE, it's BGGR. However ASCOM expects to return RBBG so we need to map. Let's swap R and B
for (int x = 0; x < exposureParams2.width; x += 2)
for (int y = 0; y < exposureParams2.height; y += 2)
{
int bluePixel = (int)camera.cameraImageArray.GetValue(x, y);
int redPixel = (int)camera.cameraImageArray.GetValue(x+1, y+1);
camera.cameraImageArray.SetValue(bluePixel, x + 1, y + 1);
camera.cameraImageArray.SetValue(redPixel, x, y);
}
}
}
if (camera.cameraInfo.colourCamera) // Ignore bayer if the camnera is mono, no matter what the user says
if (camera.cameraInfo.bayer == CameraInfo.COLOR) // Ignore if the sensor type is TRUESENSE, no matter what the user says
if (camera.GetBayerPattern() == SBIGBayerPattern.RGGB)
{
// If we have a colour camera that isn't TRUESENSE, it's BGGR. However ASCOM expects to return RBBG so we need to map. Let's swap R and B
for (int x = 0; x < exposureParams2.width; x += 2)
for (int y = 0; y < exposureParams2.height; y += 2)
{
int bluePixel = (int)camera.cameraImageArray.GetValue(x, y);
int redPixel = (int)camera.cameraImageArray.GetValue(x+1, y+1);
camera.cameraImageArray.SetValue(bluePixel, x + 1, y + 1);
camera.cameraImageArray.SetValue(redPixel, x, y);
}
}
//camera.cameraImageArray = Utils.RotateMatrixCounterClockwiseAndConvertToInt(data);
data = null;
debug.LogMessage("ImageTakerThread TakeImage", "Finishing readout");
Expand Down
15 changes: 15 additions & 0 deletions ASCOM.HomeMade.SBIGClient/SBIGBayerPattern.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ASCOM.HomeMade.SBIGClient
{
public enum SBIGBayerPattern
{
BGGR,
RGGB,
Mono
}
}
4 changes: 2 additions & 2 deletions ASCOM.HomeMade.SBIGCommon/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@
// by using the '*' as shown below:
//
// TODO - Set your driver's version here
[assembly: AssemblyVersion("1.0.8.0")]
[assembly: AssemblyFileVersion("1.0.8.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
6 changes: 6 additions & 0 deletions ASCOM.HomeMade.SBIGGuidingCamera/Driver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class Camera : SBIGCamera.SBIGCamera

public static string IPAddress = "";
public static bool HideReadout = true;
public static SBIGBayerPattern BayerPattern = SBIGBayerPattern.Mono;

/// <summary>
/// Initializes a new instance of the <see cref="HomeMade"/> class.
Expand Down Expand Up @@ -111,6 +112,11 @@ protected override bool GetHideReadout()
return HideReadout;
}

public override SBIGBayerPattern GetBayerPattern()
{
return BayerPattern;
}

/// <summary>
/// Displays the Setup Dialog form.
/// If the user clicks the OK button to dismiss the form, then
Expand Down
12 changes: 12 additions & 0 deletions ASCOM.HomeMade.SBIGImagingCamera/Driver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class Camera : SBIGCamera.SBIGCamera

public static string IPAddress = "";
public static bool HideReadout = true;
public static SBIGBayerPattern BayerPattern = SBIGBayerPattern.BGGR;

/// <summary>
/// Initializes a new instance of the <see cref="HomeMade"/> class.
Expand Down Expand Up @@ -109,6 +110,11 @@ protected override bool GetHideReadout()
return HideReadout;
}

public override SBIGBayerPattern GetBayerPattern()
{
return BayerPattern;
}

/// <summary>
/// Displays the Setup Dialog form.
/// If the user clicks the OK button to dismiss the form, then
Expand Down Expand Up @@ -155,6 +161,11 @@ internal void ReadProfile()
HideReadout = Convert.ToBoolean(driverProfile.GetValue(driverID, "HideReadout", "", "True"));
}
catch (Exception) { }
try
{
BayerPattern = (SBIGBayerPattern)Convert.ToInt32(driverProfile.GetValue(driverID, "BayerPattern", "", ((int)SBIGBayerPattern.BGGR).ToString()));
}
catch (Exception) { }
}
}

Expand All @@ -169,6 +180,7 @@ internal void WriteProfile()
driverProfile.WriteValue(driverID, "TraceDebug", ASCOM.HomeMade.SBIGCommon.Debug.TraceEnabled.ToString());
driverProfile.WriteValue(driverID, "IPAddress", IPAddress);
driverProfile.WriteValue(driverID, "HideReadout", HideReadout.ToString());
driverProfile.WriteValue(driverID, "BayerPattern", ((int)BayerPattern).ToString());
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion ASCOM.HomeMade.SBIGImagingCamera/SetupDialogForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ private void cmdOK_Click(object sender, EventArgs e) // OK button event handler
ASCOM.HomeMade.SBIGCommon.Debug.TraceEnabled = chkTrace.Checked;
Camera.IPAddress = textBox1.Text;
Camera.HideReadout = hideReadoutCheckBox.Checked;
Camera.BayerPattern = (SBIGClient.SBIGBayerPattern)bayerPatternComboBox.SelectedItem;
}

private void cmdCancel_Click(object sender, EventArgs e) // Cancel button event handler
Expand Down Expand Up @@ -75,7 +76,11 @@ private void InitUI()
chkTrace.Checked = ASCOM.HomeMade.SBIGCommon.Debug.TraceEnabled;
textBox1.Text = Camera.IPAddress;
hideReadoutCheckBox.Checked = Camera.HideReadout;
// set the list of com ports to those that are currently available
foreach (SBIGClient.SBIGBayerPattern pattern in Enum.GetValues(typeof(SBIGClient.SBIGBayerPattern)))
{
bayerPatternComboBox.Items.Add(pattern);
}
bayerPatternComboBox.SelectedItem = Camera.BayerPattern;
}
}
}
48 changes: 43 additions & 5 deletions ASCOM.HomeMade.SBIGImagingCamera/SetupDialogForm.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions ASCOM.HomeMade.SBIGImagingCamera/SetupDialogForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,21 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="ascomOptionsToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<data name="ascomOptionsToolTip.ToolTipTitle" xml:space="preserve">
<value>Only useful for colour cameras. SBIG sensors produce a BGGR pattern which will need to be used to debayer (in NINA, CCDCiel, PixInsight, etc.). ASCOM requires that pattern to be RGGB. But as SBIG aware applications expect BGGR, it is the default here.</value>
</data>
<data name="bayerPatternComboBox.ToolTip" xml:space="preserve">
<value>Only useful for colour cameras. SBIG sensors produce a BGGR pattern which will need to be used to debayer (in NINA, CCDCiel, PixInsight, etc.).
ASCOM requires that pattern to be RGGB.
But as SBIG aware applications expect BGGR, it is the default here.
</value>
</data>
<data name="label3.ToolTip" xml:space="preserve">
<value>Only useful for colour cameras. SBIG sensors produce a BGGR pattern which will need to be used to debayer (in NINA, CCDCiel, PixInsight, etc.).
ASCOM requires that pattern to be RGGB.
But as SBIG aware applications expect BGGR, it is the default here.</value>
</data>
</root>
Binary file modified HomeMade SBIG Camera Setup.exe
Binary file not shown.

0 comments on commit fb4ac93

Please sign in to comment.