// +build ignore #include "takephoto.h" // 主函数入口, 测试拍照 int main(int argc,char *argv[]) { int ret = 0; unsigned long stime, wtime, etime; HKImgMark imgMark = { 0 }; char filename[MAX_PATH_CHARS] = { 0 }; int timeout = 5*60; if(HK_GetSysUsbfsMemCurrentSize() < 200) ret = HK_SetSysUsbfsMemSize(200); if(0 != ret) { sw_log_error("Failed to set system usbfs's memory size, ret=%d!!", ret); return ret; } sw_log_info("Get HK camera count: %d", HK_GetCameraCount()); sw_log_info("Photo taking..."); for(int i = 0; i < 9; i++) { sprintf(filename, "test%d.jpg", i+1); xgettickcount(&stime); ret = HK_TakePhoto(IMG_TYPE_JPG, filename, timeout, &imgMark); xgettickcount(&etime); wtime = etime - stime; if(0 == ret) sw_log_info("+++ Take a photo: \"%s\", time: %lums, exposure time: %fus, camera sn: %s, camera model: %s +++", filename, wtime, imgMark.imgExposureTime, imgMark.camSerialNum, imgMark.camModelName); else sw_log_error("+++ Failed to take a photo, ret=%d, time: %lums!! +++", ret, wtime); sw_thrd_delay(1000); // 轮询拍照测试时, 给系统预留一定的相机释放时间 } return 0; }