char CameraInfo() { tPvCameraInfoEx List[5]; unsigned long numCamera; numCamera=PvCameraListEx(List,5,NULL,sizeof(tPvCameraInfoEx)); if(numCamera==1) return List[0].CameraName[6]; else return List[0].ModelName[6]; }
bool OmniCamera::connect(void) { if(isConnected()) return true; tPvCameraInfoEx info[1]; unsigned long frameSize = 0; //PvLinkCallbackRegister(CameraEventCB,ePvLinkAdd,NULL); //PvLinkCallbackRegister(CameraEventCB,ePvLinkRemove,NULL); if(!PvInitialize()) { while(!PvCameraCount()) Sleep(250); unsigned long numCameras = PvCameraListEx(info, 1, NULL, sizeof(tPvCameraInfoEx));; if ((numCameras == 1) && (info[0].PermittedAccess & ePvAccessMaster)) { _camera.UID = info[0].UniqueId; if(!PvCameraOpen(_camera.UID, ePvAccessMaster, &(_camera.handle))) { if(!PvAttrUint32Get(_camera.handle,"TotalBytesPerFrame",&frameSize)) { _camera.frame.ImageBuffer = new char[frameSize]; unsigned long format=0; PvAttrEnumSet(_camera.handle,"PixelFormat","Bayer8"); char text[100]; PvAttrEnumGet(_camera.handle,"PixelFormat",text,sizeof(text),&format); printf("format %d %s\n",format,text); if(_camera.frame.ImageBuffer) { _camera.frame.ImageBufferSize = frameSize; PvAttrUint32Get(_camera.handle,"Width",&_width); PvAttrUint32Get(_camera.handle,"Height",&_height); PvCaptureStart(_camera.handle); PvAttrEnumSet(_camera.handle, "AcquisitionMode", "Continuous"); PvCommandRun(_camera.handle, "AcquisitionStart"); _connected = true; return true; } } } } } _connected = false; return false; }
// // idlPvCameraListEx // // List the Prosilica or AVT cameras currently visible to the system. // 1. Fill up the internal list of structures // 2. Transfer the list to IDL, element by element. // // command line arguments // argv[0]: IN/FLAG debug // argv[1]: IN Maximum number of cameras to list unsigned long idlPvCameraListEx (int argc, char *argv[]) { unsigned long maxncameras; unsigned long ncameras; // number of visible cameras unsigned long nentries; // number of valid entries in the info table debug = *(IDL_INT *) argv[0]; maxncameras = *(unsigned long *) argv[1]; CHECKINDEX(maxncameras); nentries = PvCameraListEx(info, maxncameras, &ncameras, sizeof(tPvCameraInfoEx)); return nentries; }
// get the first camera found // return value: true == success, false == fail bool CameraGet() { tPvUint32 count,connected; tPvCameraInfoEx list; //regardless if connected > 1, we only set UID of first camera in list count = PvCameraListEx(&list,1,&connected, sizeof(tPvCameraInfoEx)); if(count == 1) { GCamera.UID = list.UniqueId; printf("Got camera %s\n",list.SerialNumber); return true; } else { printf("CameraGet: Failed to find a camera\n"); return false; } }
/* * Method: ListCameras() * Purpose: list all the cameras already visible * Comments: none */ void CMainWindow::ListCameras() { tPvCameraInfoEx lInfos[kMaxPossibleCameras]; tPvUint32 lCount; // list all the cameras currently connected if(PvCameraListEx(lInfos,kMaxPossibleCameras,&lCount,sizeof(tPvCameraInfoEx))) { // and loop over all the cameras found and add them to the tree for(tPvUint32 lIndex=0;lIndex<lCount;lIndex++) { CTreeItemData *lItem = new CTreeItemData; if(lItem) { wxString lString; wxTreeItemId lChild; // copy the camera info in the tree item memcpy(&lItem->iData,&lInfos[lIndex],sizeof(tPvCameraInfoEx)); // make the string to be displayed lString = wxString(lItem->iData.SerialNumber,wxConvUTF8); lString += _T(" ("); lString += wxString(lItem->iData.CameraName,wxConvUTF8); lString += _T(")"); // then, insert the item lChild = iTree->AppendItem(iRoot,lString,-1,-1,lItem); // and make sure the root is expanded iTree->Expand(iRoot); // and select the newly added item iTree->SelectItem(lChild,true); } } } }