FACT++  1.0
void MStarguider::ProcessFrame ( const unsigned long  n,
byte img,
struct timeval *  tm 
)
virtual

Reimplemented from PixClient.

Definition at line 1127 of file MStarguider.cc.

References FilterLed::DrawCircle(), MGImage::DrawColImg(), MGImage::DrawImg(), FilterLed::Execute(), fCaos, fDimData, fDisplay, fFindStarBox, fFindStarCut, fImage, FilterLed::FindStar(), fScreenshotName, fTPointMode, Ring::GetMag(), Led::GetMag(), MCaos::GetNumDetectedLEDs(), MCaos::GetNumDetectedRings(), Ring::GetPhi(), Ring::GetX(), Led::GetX(), Ring::GetY(), Led::GetY(), IDM_kCaosFilter, IDM_kFilter, IDM_kFindStar, IDM_kStretch, Interpolate(), FilterLed::MarkPoint(), MCaos::Run(), FilterLed::SetBox(), FilterLed::SetCut(), DimService::setData(), DimService::setQuality(), DimService::setTimestamp(), FilterLed::Stretch(), DimService::updateService(), and WritePNG().

1129 {
1130  if (!Interpolate(n, img))
1131  return;
1132 
1133  if (fTPointMode==2)
1134  {
1135  fTPointMode=1;
1136  return;
1137  }
1138 
1139  byte cimg[768*576];
1140  memset(cimg, 0, 768*576);
1141 
1142  FilterLed f (img, 768, 576, 2.5); // 2.5
1143  FilterLed f2(cimg, 768, 576); // former color 0xb0
1144 
1145  if (!fTPointMode && fScreenshotName.empty() && fDisplay->IsEntryChecked(IDM_kStretch))
1146  f.Stretch();
1147 
1148  // Visual Filter, whole FOV
1149  if (!fTPointMode && fDisplay->IsEntryChecked(IDM_kFilter))
1150  {
1151  vector<Led> leds;
1152  f.Execute(leds, 768/2, 576/2);
1153  for (auto it=leds.begin(); it!=leds.end(); it++)
1154  f.MarkPoint(*it);
1155  }
1156 
1157  // Find Center of Camera for Caos and Tpoints
1158  int numleds = 0;
1159  int numrings = 0;
1160  Ring center(-1, -1);//(5, 5);
1161 
1162  if (fTPointMode || fDisplay->IsEntryChecked(IDM_kCaosFilter))
1163  {
1164  center = fCaos->Run(img);
1165  numleds = fCaos->GetNumDetectedLEDs();
1166  numrings = fCaos->GetNumDetectedRings();
1167  }
1168 
1169  //cout << "cx=" << center.GetX() << " cy=" << center.GetY() << " Nled=" << numleds << " Nrings=" << numrings << endl;
1170 
1171  // Find Star at Center---for Tpoint Procedure
1172  Led star(-1, -1);
1173  if (center.GetX()>0 && center.GetY()>0)
1174  {
1175  if (fTPointMode || fDisplay->IsEntryChecked(IDM_kFindStar))
1176  {
1177  // Set search Paremeters (FIXME: Get them from user input!)
1178  f.SetCut(fFindStarCut+1.5); // FindStar.CleaningLevel
1179  f.SetBox(fFindStarBox+12/*+80*/); // FindStar.SizeBox
1180 
1181  // Try to find the star
1182  vector<Led> leds;
1183  f.FindStar(leds, (Int_t)center.GetX(), (Int_t)center.GetY(), true);
1184 
1185  // Check whether star found
1186  if (leds.size()>0)
1187  {
1188  //cout << "Found star @ " << flush;
1189  //leds[0].Print();
1190  f2.MarkPoint(leds[0].GetX(), leds[0].GetY(), 2<<2);
1191  star = leds[0];
1192  }
1193  }
1194 
1195  // DrawZoomImage(img);
1196  // DrawCosyImage(img);
1197 
1198  // Position corresponding to the camera center (53.2, 293.6)
1199  // Draw Circles around center of Camera
1200  if (fTPointMode || fDisplay->IsEntryChecked(IDM_kCaosFilter))
1201  {
1202  f2.DrawCircle(center, 0x0a);
1203  f2.DrawCircle(center, 7.0,
1204  fDisplay->IsEntryChecked(IDM_kFindStar)?3:0xb0);
1205  //f2.DrawCircle(center, 115.0, 0x0a);
1206  //f2.DrawCircle(center, 230.0, 0x0a);
1207  //f2.DrawCircle(center, 245.0, 0x0a);
1208  }
1209  }
1210 
1211  if (fTPointMode ||
1212  fDisplay->IsEntryChecked(IDM_kCaosFilter) ||
1213  fDisplay->IsEntryChecked(IDM_kFindStar))
1214  fImage->DrawColImg(img, cimg);
1215  else
1216  fImage->DrawImg(img);
1217 
1218  if (fTPointMode && !fScreenshotName.empty())
1219  {
1220  WritePNG(fScreenshotName.c_str(), img, cimg);
1221  fScreenshotName = "";
1222  fTPointMode = 0;
1223  return;
1224  }
1225 
1226 
1227  if (star.GetX()<0 || star.GetY()<0 || fTPointMode==0)
1228  return;
1229 
1230  if (fTPointMode==1)
1231  fTPointMode=0;
1232 
1233  // Convert from Pixel to millimeter (1pix=2.6mm) [deg/pix / deg/mm = mm/pix]
1234  // Correct for abberation.
1235 
1236  //const float Dleds = 510; // 5.96344 deg
1237  //const float Dpix = 2*237.58;
1238 
1239  // The DC reflector elongates light from off axis sources
1240  // This is a correction. It is 7% for MAGIC (1:1) and
1241  // less for FACT (1:1.4). This is an estimate from a
1242  // Orbit mode observation at 0.17deg distance to the
1243  // camera center [4.90m might also not be very accurate
1244  // depending on the position of the CCD camera]
1245  const double abberation = 1.0638; //1.0713;
1246  const double sec_per_pix = 45.14; //45.311; (atan(510mm/2 / 4.90m) / 237.58) // FACT LEDs
1247 
1248  const double conv = sec_per_pix/abberation;
1249 
1250  const double dx = star.GetX()-center.GetX();
1251  const double dy = star.GetY()-center.GetY();
1252 
1253  //const double dxx = - conv * (star.GetX()-center.GetX());
1254  //const double dyy = conv * (star.GetY()-center.GetY());
1255 
1256  const double dphi = - center.GetPhi() * M_PI/180;
1257 
1258  // The sign is because the pixels are not counted in
1259  // both directions in the same direction as Zd/Az
1260  const double dxx = - conv * (dx*cos(dphi) - dy*sin(dphi));
1261  const double dyy = conv * (dx*sin(dphi) + dy*cos(dphi));
1262 
1263  double arr[11] = {
1264  dxx, dyy,
1265  double(numleds), double(numrings),
1266  center.GetX(), center.GetY(), center.GetMag(),
1267  star.GetX(), star.GetY(), star.GetMag(),
1268  center.GetPhi()
1269  };
1270 
1271  fDimData.setData(arr, 11*sizeof(double));
1272  fDimData.setQuality(0);
1273  fDimData.setTimestamp(tm->tv_sec, tm->tv_usec/1000);
1275 }
Ring Run(uint8_t *img)
Definition: MCaos.cc:86
void DrawColImg(const byte *gbuf, const byte *cbuf)
Definition: MGImage.cc:210
std::string fScreenshotName
Definition: MStarguider.h:66
void setQuality(int quality)
Definition: discpp.cxx:1256
Int_t fFindStarBox
Definition: MStarguider.h:61
Float_t fFindStarCut
Definition: MStarguider.h:60
MCaos * fCaos
Definition: MStarguider.h:48
Definition: Led.h:8
bool Interpolate(const unsigned long n, byte *img) const
void setTimestamp(int secs, int millisecs)
Definition: discpp.cxx:1263
Definition: Ring.h:10
int updateService()
Definition: discpp.cxx:1016
unsigned char byte
Definition: MGImage.h:17
MGImage * fImage
Definition: MStarguider.h:36
TGPopupMenu * fDisplay
Definition: MStarguider.h:38
int fTPointMode
Definition: MStarguider.h:63
void setData(void *data, int size)
Definition: discpp.cxx:1270
DimService fDimData
Definition: MStarguider.h:29
int32_t GetNumDetectedRings() const
Definition: MCaos.h:54
void WritePNG(const char *name, const byte *gbuf, const byte *cbuf)
Definition: MStarguider.cc:976
int32_t GetNumDetectedLEDs() const
Definition: MCaos.h:53
void DrawImg(const byte *buffer)
Definition: MGImage.cc:127

+ Here is the call graph for this function: