ByteSize FrameMap::sp_offset_for_slot(const int index) const { if (index < argcount()) { int offset = _argument_locations->at(index); assert(offset != -1, "not a memory argument"); assert(offset >= framesize() * 4, "argument inside of frame"); return in_ByteSize(offset); } ByteSize offset = sp_offset_for_spill(index - argcount()); assert(in_bytes(offset) < framesize() * 4, "spill outside of frame"); return offset; }
bool openStorage(void * params, void * sensorparams) { USBCAMERASTORAGEPARAMS * tempparams=(USBCAMERASTORAGEPARAMS *)params; USBCAMERAPARAMS * tempsensorparams=(USBCAMERAPARAMS *)sensorparams; if(tempparams->writer.isOpened()) { tempparams->writer.release(); if(tempparams->timestampwriter.isOpen()) { tempparams->timestampwriter.close(); } } QDateTime datetime=QDateTime::currentDateTime(); QString timestamp=datetime.toString(QString("yyyyMMdd_hhmmss_zzz")); tempparams->videofilename=QString("%1\\%2-%3.%4").arg(tempparams->storagepath).arg(tempsensorparams->deviceid).arg(timestamp).arg(tempparams->extension); cv::Size framesize(tempsensorparams->width,tempsensorparams->height); if(tempparams->writer.open(tempparams->videofilename.toStdString(),CV_FOURCC('P','I','M','1'),tempparams->fps,framesize)) { tempparams->timestampwriter.setFileName(QString("%1_timestamp.log").arg(tempparams->videofilename)); if(tempparams->timestampwriter.open(QFile::WriteOnly | QFile::Text)) { return 1; } else { return 0; } } else { return 0; } }
ByteSize FrameMap::sp_offset_for_double_slot(const int index) const { ByteSize offset = sp_offset_for_slot(index); if (index >= argcount()) { assert(in_bytes(offset) + 4 < framesize() * 4, "spill outside of frame"); } return offset; }
/** * \brief main function for the focus program */ int main(int argc, char *argv[]) { int c; double exposuretime = 0.1; unsigned int cameraid = 0; unsigned int ccdid = 0; int length = 512; std::string cameratype("uvc"); while (EOF != (c = getopt(argc, argv, "de:m:c:C:l:"))) switch (c) { case 'd': debuglevel = LOG_DEBUG; break; case 'm': cameratype = std::string(optarg); break; case 'C': cameraid = atoi(optarg); break; case 'c': ccdid = atoi(optarg); break; case 'e': exposuretime = atof(optarg); break; case 'l': length = atoi(optarg); break; } // get the camera Repository repository; debug(LOG_DEBUG, DEBUG_LOG, 0, "loading module %s", cameratype.c_str()); ModulePtr module = repository.getModule(cameratype); module->open(); // get the camera DeviceLocatorPtr locator = module->getDeviceLocator(); std::vector<std::string> cameras = locator->getDevicelist(); if (0 == cameras.size()) { std::cerr << "no cameras found" << std::endl; return EXIT_FAILURE; } if (cameraid >= cameras.size()) { std::string msg = stringprintf("camera %d out of range", cameraid); debug(LOG_ERR, DEBUG_LOG, 0, "%s\n", msg.c_str()); throw std::range_error(msg); } std::string cameraname = cameras[cameraid]; CameraPtr camera = locator->getCamera(cameraname); debug(LOG_DEBUG, DEBUG_LOG, 0, "camera loaded: %s", cameraname.c_str()); // get the ccd CcdPtr ccd = camera->getCcd(ccdid); debug(LOG_DEBUG, DEBUG_LOG, 0, "get a ccd: %s", ccd->getInfo().toString().c_str()); // get a centerd length x length frame ImageSize framesize(length, length); ImageRectangle frame = ccd->getInfo().centeredRectangle(framesize); Exposure exposure(frame, exposuretime); debug(LOG_DEBUG, DEBUG_LOG, 0, "exposure prepared: %s", exposure.toString().c_str()); // retrieve an image ccd->startExposure(exposure); ImagePtr image = ccd->getImage(); // write image unlink("test.fits"); FITSout out("test.fits"); out.write(image); // apply a mask to keep the border out CircleFunction circle(ImagePoint(length/2, length/2), length/2, 0.8); mask(circle, image); unlink("masked.fits"); FITSout maskout("masked.fits"); maskout.write(image); #if 0 // compute the FOM double fom = focusFOM(image, true, Subgrid(ImagePoint(1, 0), ImageSize(1, 1))); std::cout << "FOM: " << fom << std::endl; #endif return EXIT_SUCCESS; }
//______________________________________________________________________________ Bool_t ArgusWindow::Start() { // Start Argus Window fWatchAll.Start(false); ROMEPrint::Debug("ArgusWindow::Start()\n"); // Create status bar Int_t parts[2] = {70, 30}; fStatusBar = new TGStatusBar(this, 50, 10, kHorizontalFrame); fStatusBar->SetParts(parts, sizeof(parts) / sizeof(Int_t)); fProgress = new TGHProgressBar(fStatusBar->GetBarPart(1), TGProgressBar::kStandard, 20); fProgress->SetPosition(0); fStatusBar->GetBarPart(1)->AddFrame(fProgress, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 10, 10)); if (fStatusBarSwitch) { this->AddFrame(fStatusBar, new TGLayoutHints(kLHintsBottom | kLHintsLeft | kLHintsExpandX, 0, 0, 2, 0)); } // Create horizontal frame which holds menu bar TGHorizontalFrame *hMenuFrame = new TGHorizontalFrame(this, 0, 0); AddFrame(hMenuFrame, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); { // Create menubar fMenuBar = new TGMenuBar(hMenuFrame, 1, 1, kHorizontalFrame); hMenuFrame->AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0)); { // Create popup menu fMenuFile = new TGPopupMenu(fClient->GetRoot()); fMenuFile->Associate(this); fMenuBar->AddPopup("&File", fMenuFile, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0)); if (fTabWindow) { fMenuFile->AddEntry("New Window", M_FILE_NEW_WINDOW); if (gROME->GetNumberOfNetFolders()>0) { TGPopupMenu *fMenuNetFolder = new TGPopupMenu(fClient->GetRoot()); if (AddMenuNetFolder(fMenuNetFolder)) { fMenuFile->AddPopup("&Connect NetFolder", fMenuNetFolder); fMenuNetFolder->Associate(this); } } // fMenuFile->AddEntry("Start C&ontroller", M_FILE_CONTROLLER); fMenuFile->AddEntry("E&xit", M_FILE_EXIT); } else { fMenuFile->AddEntry("C&lose", M_FILE_EXIT); } } } { // separator TGHorizontal3DLine *hline = new TGHorizontal3DLine(this); AddFrame(hline, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX)); } // Horizontal frame which holds the main canvas TGHorizontalFrame *hFrame = new TGHorizontalFrame(this); AddFrame(hFrame, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY)); // Vertical frame which holds the info frame and listtree TGVerticalFrame *vFrame = new TGVerticalFrame(hFrame); hFrame->AddFrame(vFrame, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 0, 1)); { // now analyzer controller is dockable if (fTabWindow && !gROME->IsStandAloneARGUS()) { fController = new ArgusAnalyzerController(vFrame, -1, fControllerNetFolder); fController->Associate(this); vFrame->AddFrame(fController, new TGLayoutHints (kLHintsTop | kLHintsLeft)); } if (!gROME->IsStandAloneARGUS()) { // run# TGHorizontalFrame *runFrame = new TGHorizontalFrame(vFrame); vFrame->AddFrame(runFrame, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 15, 10, 2, 2)); TGLabel *fRunLabel = new TGLabel(runFrame, "Run : "); fRunLabel->SetTextJustify(kTextLeft | kTextCenterY); runFrame->AddFrame(fRunLabel, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0)); fRunNumber = new TGLabel(runFrame, "0"); fRunNumber->SetTextJustify(kTextRight | kTextCenterY); runFrame->AddFrame(fRunNumber, new TGLayoutHints(kLHintsRight, 5, 0, 0, 0)); // evnet# TGHorizontalFrame *eventFrame = new TGHorizontalFrame(vFrame); vFrame->AddFrame(eventFrame, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 15, 10, 2, 2)); TGLabel *fEventLabel = new TGLabel(eventFrame, "Event : "); fEventLabel->SetTextJustify(kTextLeft | kTextCenterY); eventFrame->AddFrame(fEventLabel, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0)); fEventNumber = new TGLabel(eventFrame, "0"); fEventNumber->SetTextJustify(kTextLeft | kTextCenterY); eventFrame->AddFrame(fEventNumber, new TGLayoutHints(kLHintsRight, 5, 0, 0, 0)); // Year/Mon/Day TGHorizontalFrame *YearMonDayFrame = new TGHorizontalFrame(vFrame); vFrame->AddFrame(YearMonDayFrame, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 15, 10, 2, 2)); TGLabel *fYearMonDayLabel = new TGLabel(YearMonDayFrame, "Date : "); fYearMonDayLabel->SetTextJustify(kTextLeft | kTextCenterY); YearMonDayFrame->AddFrame(fYearMonDayLabel, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0)); fYearMonDay = new TGLabel(YearMonDayFrame, "1970-Jan-01"); fYearMonDay->SetTextJustify(kTextLeft | kTextCenterY); YearMonDayFrame->AddFrame(fYearMonDay, new TGLayoutHints(kLHintsRight, 5, 0, 0, 0)); // Hour/Min/Sec TGHorizontalFrame *HourMinSecFrame = new TGHorizontalFrame(vFrame); vFrame->AddFrame(HourMinSecFrame, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 15, 10, 2, 2)); TGLabel *fHourMinSecLabel = new TGLabel(HourMinSecFrame, "Time : "); fHourMinSecLabel->SetTextJustify(kTextLeft | kTextCenterY); HourMinSecFrame->AddFrame(fHourMinSecLabel, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0)); fHourMinSec = new TGLabel(HourMinSecFrame, "00:00:00"); fHourMinSec->SetTextJustify(kTextLeft | kTextCenterY); HourMinSecFrame->AddFrame(fHourMinSec, new TGLayoutHints(kLHintsRight, 5, 0, 0, 0)); } // Vertical frame which holds users info frame fUserInfoFrame = new TGVerticalFrame(vFrame); vFrame->AddFrame(fUserInfoFrame, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0)); // fControllerDock = new TGDockableFrame(vFrame, 0, kVerticalFrame); // vFrame->AddFrame(fControllerDock, new TGLayoutHints(kLHintsTop | kLHintsLeft)); // fControllerDock->EnableUndock(kTRUE); // fControllerDock->EnableHide(kTRUE); // fControllerDock->Associate(this); if (fListTreeView && fTabWindow) { // Create ListTree TGCanvas *canvas = new TGCanvas(vFrame, 120, 400); vFrame->AddFrame(canvas, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY)); fListTree = new TGListTree(canvas, kHorizontalFrame); fListTree->Connect("Clicked(TGListTreeItem*,Int_t)", "ArgusWindow", this, "OnClick(TGListTreeItem*,Int_t)"); fListTree->Connect("DoubleClicked(TGListTreeItem*,Int_t)", "ArgusWindow", this, "OnDoubleClick(TGListTreeItem*,Int_t)"); fListTree->Associate(this); } // Create the main frame const UInt_t width = static_cast<UInt_t>(640 * GetWindowScale()); const UInt_t height = static_cast<UInt_t>(480 * GetWindowScale()); if (!fListTreeView && fTabWindow) { fTab = new TGTab(hFrame, width, height); fTab->Associate(this); hFrame->AddFrame(fTab, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); } else { fMainFrame = new ROMECompositeFrame(hFrame, width, height); hFrame->AddFrame(fMainFrame, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY)); } } ROMEPrint::Debug("Creating Tabs\n"); CheckActiveFlags(); if (!CreateTabs()) { fWatchAll.Stop(); return kFALSE; } ROMEPrint::Debug("Tabs Created\n"); MapSubwindows(); TGDimension size = GetDefaultSize(); ArgusTab *tab; Int_t lastTabIndex = -1; Int_t iTab; const Int_t nTabs = fTabObjects->GetEntriesFast(); if (fListTreeView) { ArgusTab *lastTab = 0; TGDimension framesize(0,0); // first, hide all the tabs for (iTab = 0; iTab < nTabs; iTab++) { tab = GetTabObjectAt(iTab); fMainFrame->HideFrame(tab); } // show all the tabs one by one to get the maximum window size size = GetDefaultSize(); for (iTab = nTabs-1; iTab >=0; iTab--) { tab = GetTabObjectAt(iTab); if (tab->IsSwitch() && fNumberOfChildren[iTab]<=0) { fMainFrame->HideFrame(lastTab); fMainFrame->ShowFrame(tab); framesize = GetDefaultSize(); if (size.fWidth < framesize.fWidth) { size.fWidth = framesize.fWidth; } if (size.fHeight < framesize.fHeight) { size.fHeight = framesize.fHeight; } if (fTabWindow) { // we don't have listtrees for sub-windows fListTree->HighlightItem(fListTreeItem[iTab]); } lastTab = tab; lastTabIndex = iTab; } } } else { for (iTab = nTabs-1; iTab >=0; iTab--) { tab = GetTabObjectAt(iTab); if (tab->IsSwitch() && fNumberOfChildren[iTab]<=0) { fCurrentTabID = tab->GetID(); lastTabIndex = iTab; } } } Resize(size); fInitialWidth = size.fWidth; fInitialHeight = size.fHeight; // Adjust size of the sub window so that the main frame has the // same size as the parent's. This is not done if the parent window // is tab-view, because the size of the main frame is not trivial. if (!fTabWindow) { if (gROME->GetWindow()->IsListTreeView()) { TGDimension size1 = gROME->GetWindow()->GetInitialSize(); TGDimension size3 = gROME->GetWindow()->GetUserInfoFrame()->GetSize(); TGDimension size4 = GetUserInfoFrame()->GetSize(); // Height shall be the same as the parent, but width might be // different because of different width of info frame. Resize(size1.fWidth - size3.fWidth + size4.fWidth, size1.fHeight); } } gSystem->Sleep(500); MapWindow(); while (!IsMapped()) { gSystem->Sleep(20); } if (!gROME->IsStandAloneARGUS()) { // hide run# and event# if argus controller is shown/docked if (fController && (!fController->IsHidden() || !fController->IsUndocked())) { ((TGCompositeFrame*)(fRunNumber->GetParent()->GetParent()))->HideFrame((TGFrame*)(fRunNumber->GetParent())); ((TGCompositeFrame*)(fEventNumber->GetParent()->GetParent()))->HideFrame((TGFrame*)(fEventNumber->GetParent())); } } TriggerTabSelected(lastTabIndex); gSystem->Sleep(500); ROMEPrint::Debug("End of ArgusWindow::Start()\n"); fWatchAll.Stop(); return kTRUE; }
VMReg FrameMap::sp_offset2vmreg(ByteSize offset) const { int offset_in_bytes = in_bytes(offset); assert(offset_in_bytes % 4 == 0, "must be multiple of 4 bytes"); assert(offset_in_bytes / 4 < framesize() + oop_map_arg_count(), "out of range"); return VMRegImpl::stack2reg(offset_in_bytes / 4); }