Hi !
I bought a ZWO ASI120MC camera and I use a c# / ASCOM program do get camera imagens. I want to read RGB vaues from each pixel.
My problem is when I execute Ascom method Camera.Choose(...) appears one window to choose camera settings and at IMAGE TYPE dropdown, there are only options for grayscale Image Type (RAW18, RAW8) The option for color image, ImageType = RGB24 is not available for selection.
I posted in ascom forum and friends of mine with same code but diferente ZWO ASI cameras has RGB24 available for selection. Both cameras are Color cameras.
Can you help me ? I am completely lost...
Thanks in advance!
C# / ASCOM
ROUTINE:
private void Button_Click_1(object sender, RoutedEventArgs e)
{
string progID;
Util U = new Util();
lblStatus.Content = "Wait";
#region Camera
Console.WriteLine("\r\nCamera:");
//progID = Camera.Choose("ASCOM.Simulator.Camera");
//progID = Camera.Choose("ZWO ASI120MC-S(ID0)");
progID = "ASCOM.ASICamera2.Camera";
progID = Camera.Choose("ZWO ASI120MC-S(ID0)");
if (progID != "")
{
Camera C = new Camera(progID);
C.Connected = true;
if((bool)chkSettings.IsChecked )
{
C.SetupDialog();
}
Console.WriteLine(" Connected to " + progID);
Console.WriteLine(" Description = " + C.Description);
Console.WriteLine(" Pixel size = " + C.PixelSizeX + " * " + C.PixelSizeY);
Console.WriteLine(" Camera size = " + C.CameraXSize + " * " + C.CameraYSize);
Console.WriteLine(" Max Bin = " + C.MaxBinX + " * " + C.MaxBinY);
Console.WriteLine(" Bin = " + C.BinX + " * " + C.BinY);
Console.WriteLine(" MaxADU = " + C.MaxADU);
Console.WriteLine(" CameraState = " + C.CameraState.ToString());
Console.WriteLine(" CanAbortExposure = " + C.CanAbortExposure);
Console.WriteLine(" CanAsymmetricBin = " + C.CanAsymmetricBin);
Console.WriteLine(" CanGetCoolerPower = " + C.CanGetCoolerPower);
Console.WriteLine(" CanPulseGuide = " + C.CanPulseGuide);
Console.WriteLine(" CanSetCCDTemperature = " + C.CanSetCCDTemperature);
Console.WriteLine(" CanStopExposure = " + C.CanStopExposure);
Console.WriteLine(" CCDTemperature = " + C.CCDTemperature);
if (C.CanGetCoolerPower)
Console.WriteLine(" CoolerPower = " + C.CoolerPower);
Console.WriteLine(" ElectronsPerADU = " + C.ElectronsPerADU);
Console.WriteLine(" FullWellCapacity = " + C.FullWellCapacity);
Console.WriteLine(" HasShutter = " + C.HasShutter);
Console.WriteLine(" SensorType = " + C.SensorType);
//Console.WriteLine(" HeatSinkTemperature = " + C.HeatSinkTemperature);
if (C.CanPulseGuide)
Console.WriteLine(" IsPulseGuiding = " + C.IsPulseGuiding);
Console.Write(" Take 15 second image");
C.StartExposure(Convert.ToDouble(MyVel.Text), false);
while (!C.ImageReady)
{
Console.Write(".");
U.WaitForMilliseconds(3000);
}
lblStatus.Content = "Done!";
Console.WriteLine("\r\n Exposure complete, ready for download.");
Console.WriteLine(" CameraState = " + C.CameraState.ToString());
var tempArray = (Array)C.ImageArrayVariant;
int cols = tempArray.GetLength(0);
int rows = tempArray.GetLength(1);
int planes = 1;
if (tempArray.Rank == 3)
{
planes = tempArray.GetLength(2);
// Here we have a multi-plane (RGB) image;
if (planes != 3)
{
throw new Exception("The downloaded image has an unsupported number of colors!");
}
}
else if (tempArray.Rank > 3)
{
throw new Exception("The camera provided an unsupported image type (not mono or 3 color)!");
}
int cameraImage = new int;
Buffer.BlockCopy(tempArray, 0, cameraImage, 0, tempArray.Length * sizeof(int));
//Console.WriteLine(" LastExposureDuration = " + C.LastExposureDuration);
//Console.WriteLine(" LastExposureStartTime = " + C.LastExposureStartTime);
int imgArray = (int)C.ImageArray;
Console.WriteLine(" xxxx: " + imgArray.Length);
Console.WriteLine(" Array is " + (imgArray.GetUpperBound(0) + 1) + " by " + (imgArray.GetUpperBound(1) + 1));
int max = 0;
for(int xx=0; xx < imgArray.GetUpperBound(0) + 1; xx++)
{
for (int yy = 0; yy < imgArray.GetUpperBound(1) + 1 ; yy++)
{
//Console.WriteLine(imgArray);
if (imgArray > max) max = imgArray;
}
}
Console.WriteLine("MAX: " + max);
Console.WriteLine("SII: " + 1000);
Console.WriteLine((1000 >> 1) );
//1111111111110000
int rgb = imgArray;
Console.WriteLine("RGB: " + rgb );
Console.WriteLine(Convert.ToString(65536-1, 2));
Console.WriteLine((rgb >> 16) );
Console.WriteLine((rgb >> 16) & 0xffffff);
Console.WriteLine("----------");
Console.WriteLine((rgb >> 8));
Console.WriteLine((rgb >> 8) & 0xffffff);
Console.WriteLine("----------");
Console.WriteLine((rgb >> 0));
Console.WriteLine((rgb >> 0) & 0xffffff);
System.Windows.Media.Color color1 = System.Windows.Media.Color.FromRgb((byte)((rgb >> 16) & 0xff), (byte)((rgb >> 8) & 0xff), (byte)((rgb >> 0) & 0xff));
color1 = System.Windows.Media.Color.FromRgb(255, 255, 255);
myRect1.Fill = new SolidColorBrush(color1);
myLabel1.Content = color1.A.ToString() + " " + color1.R.ToString() + " " + color1.G.ToString() + " " + color1.B.ToString();
rgb = imgArray;
System.Windows.Media.Color color2 = System.Windows.Media.Color.FromRgb( (byte)((rgb >> 16) & 0xff), (byte)((rgb >> 8) & 0xff), (byte)((rgb >> 0) & 0xff));
myRect2.Fill = new SolidColorBrush(color2);
myLabel2.Content = color2.A.ToString() + " " + color2.R.ToString() + " " + color2.G.ToString() + " " + color2.B.ToString();
rgb = imgArray;
System.Windows.Media.Color color3 = System.Windows.Media.Color.FromRgb( (byte)((rgb >> 16) & 0xff), (byte)((rgb >> 8) & 0xff), (byte)((rgb >> 0) & 0xff));
myRect3.Fill = new SolidColorBrush(color3);
myLabel3.Content = color3.A.ToString() + " " + color3.R.ToString() + " " + color3.G.ToString() + " " + color3.B.ToString();
rgb = imgArray;
System.Windows.Media.Color color4 = System.Windows.Media.Color.FromRgb( (byte)((rgb >> 16) & 0xff), (byte)((rgb >> 8) & 0xff), (byte)((rgb >> 0) & 0xff));
myRect4.Fill = new SolidColorBrush(color4);
myLabel4.Content = color4.A.ToString() + " " + color4.R.ToString() + " " + color4.G.ToString() + " " + color4.B.ToString();
C.Connected = false;
C.Dispose();
}
#endregion
}