int main(int argc, char* argv[]) { // initialize PvAPI if(PvInitialize() == ePvErrSuccess) { //IMPORTANT. Initialize camera structure. See tPvFrame in PvApi.h for more info. memset(&GCamera,0,sizeof(tCamera)); // the only command line argument accepted is the IP@ of the camera to be open if(argc>1) { unsigned long IP = inet_addr(argv[1]); if(IP) { // open the camera if(CameraOpen(IP)) { ListAttributes(); // unsetup the camera CameraClose(); } else printf("Failed to open the camera (maybe not found?)\n"); } else printf("a valid IP address must be entered\n"); } else { // wait for a camera to be plugged WaitForCamera(); if(CameraGrab()) { // open the camera if(CameraOpen()) { ListAttributes(); // unsetup the camera CameraClose(); } else printf("failed to open the camera\n"); } else printf("failed to grab a camera!\n"); } // uninitialize the API PvUnInitialize(); } else printf("failed to initialize the API\n"); return 0; }
int main(int argc, char* argv[]) { // initialise the Prosilica API if(!PvInitialize()) { memset(&GCamera,0,sizeof(tCamera)); // the only command line argument accepted is the IP@ of the camera to be open if(argc>1) { unsigned long IP = inet_addr(argv[1]); if(IP) { // open the camera if(CameraOpen(IP)) { ListAttributes(); // unsetup the camera CameraClose(); } else printf("Failed to open the camera (maybe not found?)\n"); } else printf("a valid IP address must be entered\n"); } else { // wait for a camera to be plugged WaitForCamera(); if(CameraGrab()) { // open the camera if(CameraOpen()) { ListAttributes(); // unsetup the camera CameraClose(); } else printf("failed to open the camera\n"); } else printf("failed to grab a camera!\n"); } // uninitialise the API PvUnInitialize(); } else printf("failed to initialise the API\n"); return 0; }
int CaptureSensorFace(char *Buffer, BOOL Sign,int* ImageSize) { int sizein = 0; int sizeout = 0; static unsigned char CapFailCnt=0; if( cameraflag <0) { CapFailCnt=0; cameraflag=CameraOpen(0); DelayMS(10); SetCameraLed(&videoIn,2,1); SetFaceExtactParams(); } if(cameraflag<0 || hFaceExtact <= 0)// || (FaceInit == 0 && FaceTest==0)) { printf(" Open Face Camera Failed or Init face DB failed \n"); return 0; } sizein = FACE_IMG_W * FACE_IMG_H; sizeout=read(videoIn.fd,(void *)Buffer,sizein); if((sizeout<=0) || (!((sizeout >0)&&chech_jpeg((void *)Buffer,sizeout,FACE_IMG_H,FACE_IMG_W)))) { CapFailCnt++; if(CapFailCnt>3) { CloseCamera(&videoIn); cameraflag=-1; } printf(" check jpg failed \n"); return 0; } #if 0 // save jpg file FILE * fj=NULL; fj=fopen("/mnt/ramdisk/fa.jpg","wb"); if(sizeout == fwrite(Buffer,1, sizeout,fj)) ; // printf("write fa.jpg ok \n"); fclose(fj); sync(); #endif *ImageSize=sizeout; return TRUE; }
int FaceExtactDBInit(void) { int ret=-1; FaceTest=0; if(cameraflag <= 0) { ret=CameraOpen(0); if(ret<0) { printf(" Init camera falied \n"); FaceInit=0; return 0; } } printf(" Open Camera Success \n"); hFaceExtact=ZKFaceInit(FOR_EXTRACT); if(hFaceExtact == NULL) { FaceInit=0; printf(" zk face db init Error ! \n"); } else { printf("PARAM_IMAGE_FILE_GRAY=%s\n", (char *)ZKFaceGetParam(FaceHandle, PARAM_IMAGE_FILE_GRAY)); printf(" Handle: %d Image quality=%d \n",(int)hFaceExtact,gOptions.VideQuality); ZKFaceSetParam(hFaceExtact, PARAM_IMAGE_ROTATION, PARAM_IMAGE_ROTATIOV_90); ZKFaceSetParam(hFaceExtact, PARAM_FACE_QUALITY_THRESHOLD, gOptions.VideQuality); ZKFaceSetParam(hFaceExtact, PARAM_IMAGE_FLIP, PARAM_IMAGE_FLIP_X); ZKFaceSetParam(hFaceExtact, PARAM_IMAGE_FILE_GRAY, (int)""); ZKFaceSetParam(hFaceExtact, 101, 20); ZKFaceSetParam(hFaceExtact, 1200, 4); } spcaSetGlobalGain(&videoIn, gOptions.VideoGain); spcaSetExposoure(&videoIn, gOptions.FaceExposoure); ChangeExposal(0); return (int)hFaceExtact; }
DLLEXPORT int primOpenCamera(void) { int cameraNum; int desiredFrameWidth; int ok; int desiredFrameHeight; cameraNum = interpreterProxy->stackIntegerValue(2); desiredFrameWidth = interpreterProxy->stackIntegerValue(1); desiredFrameHeight = interpreterProxy->stackIntegerValue(0); if (interpreterProxy->failed()) { return 0; } ok = CameraOpen(cameraNum, desiredFrameWidth, desiredFrameHeight); if (ok == 0) { interpreterProxy->success(0); return 0; } interpreterProxy->pop(3); return 0; }
int main(int argc, char* argv[]) { // initialise the Prosilica API if(!PvInitialize()) { // the only command line argument accepted is the IP@ of the camera to be open if(argc>1) { unsigned long IP = inet_addr(argv[1]); if(IP) { tPvHandle Handle; // open the camera if((Handle = CameraOpen(IP)) != NULL) { // seek the best packet size CameraAdjust(Handle); // close the camera CameraClose(Handle); } else printf("Failed to open the camera (maybe not found?)\n"); } else printf("a valid IP address must be entered\n"); } else printf("usage : AdjustPacket <IP@>\n"); // uninitialise the API PvUnInitialize(); } else printf("failed to initialise the API\n"); return 0; }
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_COMMAND:{ int wmId = LOWORD(wParam); int wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_EXIT: DestroyWindow(hWnd); break; case ID_CAMERA_OPEN: CameraOpen(); break; case ID_CAMERA_CLOSE: CameraClose(); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break;} case WM_PAINT:{ PAINTSTRUCT ps; HDC hdc = BeginPaint(hWnd, &ps); EndPaint(hWnd, &ps); break;} case WM_CLOSE: DestroyWindow(hWnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }