📄 cmapitest.c
字号:
/* * cmAPITest - API Test file */#include <stdlib.h>#include <stdio.h>#include <cmAPI.h>#include <cmJpgHdr.h>#include <cm2bmp.h>#include <cmRgbHeader.h>#include <windows.h> // for the bitmap sizesunsigned char buffer[640*480*3];unsigned char buffer_out[640*480*3+sizeof (BITMAPFILEHEADER)+sizeof (BITMAPINFOHEADER)];int bufferlen = 0;int buffer_outlen = 0;int mydebug = 0;int main(int argc, char *argv[]){ unsigned int cameraID;
int status = 0; ImageType_t type; int width; int height; if (argc < 3) { printf ("USAGE: cmAPITest com outputfile [debug]\n"); printf ("Revision 1.4"); return 1; } if (argc > 3) { mydebug = atoi(argv[3]); } if (mydebug > 0) { printf ("\nAPI Revision %s\n", cmRevisionGet());
} cmDebugLevelSet (mydebug); cmApiSet (CM_TAG_IMAGE_TIMEOUT, 1); if (cmInit (argv[1], "api1670.ini") < 0) { printf ("\nError calling cmInit"); } status = cmIdGet (&cameraID); if (status < 0) { printf ("\nError retrieving camera ID\n"); } else { if (mydebug > 0) { printf ("\nCamera ID = 0x%4x\n", cameraID); } } cmImageTypeGet (&type); cmImageSizeGet (&width, &height); if (mydebug > 0) { printf ("type = %d w = %d, h = %d\n", type, width, height); } /* Tell campera to take an image */ status = cmImageSnap (NULL); if (status < 0) { printf ("\nError taking still image \n"); cmDestroy(); return 1; }#if 0 status = cmImageVid (); if (status < 0) { printf ("\nError enabling video \n"); cmDestroy(); return 1; }#endif /* retrieve data in jpeg format */ status = cmImageGet (buffer, &bufferlen); if (status < 0) { printf ("\nError reading image\n"); cmDestroy(); return 1; } if ((type == CM_TYPE_JPEG422) || (type == CM_TYPE_JPEG444) || (type == CM_TYPE_JPEGGREY)) { cmJpgHdrBuild (buffer, bufferlen, buffer_out, &buffer_outlen, type, width, height); } else { unsigned char *buf_p; buf_p = buffer + 1; // adjust for counting the SOP bufferlen = bufferlen - 1; cm2bmp (buffer, bufferlen, buffer_out, &buffer_outlen, type, width, height); //cm2bmp (buffer, bufferlen, buffer_out, &buffer_outlen, type, width, height); } /* write to a file */ cmWrite2File (buffer_out, buffer_outlen, argv[2]); cmAbort ();
cmDestroy();
return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -