iot_camera.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #include "iot_camera.h"
  2. #include "iot_fs.h"
  3. /**摄像头初始化
  4. *@param cameraParam: 初始化参数
  5. *@return TRUE: 成功
  6. * FALSE: 失败
  7. **/
  8. BOOL iot_camera_init(T_AMOPENAT_CAMERA_PARAM *cameraParam)
  9. {
  10. return IVTBL(InitCamera)(cameraParam);
  11. }
  12. /**打开摄像头
  13. *@param videoMode: 是否视频模式
  14. *@return TRUE: 成功
  15. * FALSE: 失败
  16. **/
  17. BOOL iot_camera_poweron(BOOL videoMode)
  18. {
  19. return IVTBL(CameraPoweron)(videoMode);
  20. }
  21. /**关闭摄像头
  22. *@return TRUE: 成功
  23. * FALSE: 失败
  24. **/
  25. BOOL iot_camera_poweroff(void)
  26. {
  27. IVTBL(CameraPowerOff)();
  28. return TRUE;
  29. }
  30. /**开始预览
  31. *@param previewParam: 预览参数
  32. *@return TRUE: 成功
  33. * FALSE: 失败
  34. **/
  35. BOOL iot_camera_preview_open(T_AMOPENAT_CAM_PREVIEW_PARAM *previewParam)
  36. {
  37. return IVTBL(CameraPreviewOpen)(previewParam);
  38. }
  39. /**退出预览
  40. *@return TRUE: 成功
  41. * FALSE: 失败
  42. **/
  43. BOOL iot_camera_preview_close(void)
  44. {
  45. return IVTBL(CameraPreviewClose)();
  46. }
  47. /**拍照
  48. *@param fileName: 保存图片的文件名
  49. *@param captureParam: 预览参数
  50. *@return TRUE: 成功
  51. * FALSE: 失败
  52. **/
  53. BOOL iot_camera_capture(char *fileName, T_AMOPENAT_CAM_CAPTURE_PARAM *captureParam)
  54. {
  55. INT32 fd;
  56. if (!fileName)
  57. {
  58. return FALSE;
  59. }
  60. iot_fs_delete_file(fileName);
  61. fd = iot_fs_create_file(fileName);
  62. if (fd < 0)
  63. {
  64. return FALSE;
  65. }
  66. if(!IVTBL(CameraCapture)(captureParam))
  67. {
  68. iot_fs_close_file(fd);
  69. return FALSE;
  70. }
  71. if (!IVTBL(CameraSavePhoto)(fd))
  72. {
  73. iot_fs_close_file(fd);
  74. return FALSE;
  75. }
  76. iot_fs_close_file(fd);
  77. return TRUE;
  78. }
  79. /**设置camera寄存器
  80. *@param initRegTable_p: cam寄存器表
  81. *@param len: cam寄存器长度
  82. *@return TRUE: 成功
  83. * FALSE: 失败
  84. **/
  85. BOOL iot_camera_WriteReg(PAMOPENAT_CAMERA_REG initRegTable_p, int len)
  86. {
  87. return IVTBL(CameraWriteReg)(initRegTable_p, len);
  88. }