decoder_demo.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /** @file
  2. decoder_demo.c
  3. @brief
  4. This file is decoder demo .
  5. */
  6. /*================================================================
  7. Copyright (c) 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
  8. Quectel Wireless Solution Proprietary and Confidential.
  9. =================================================================*/
  10. /*=================================================================
  11. EDIT HISTORY FOR MODULE
  12. This section contains comments describing changes made to the module.
  13. Notice that changes are listed in reverse chronological order.
  14. WHEN WHO WHAT, WHERE, WHY
  15. ------------ ------- -------------------------------------------------------------------------------
  16. =================================================================*/
  17. /*===========================================================================
  18. * include files
  19. ===========================================================================*/
  20. #include <stdio.h>
  21. #include <string.h>
  22. #include <stdlib.h>
  23. #include "decoder_demo.h"
  24. #include "ql_api_osi.h"
  25. #include "ql_log.h"
  26. #include "ql_api_camera.h"
  27. #include "ql_api_decoder.h"
  28. #include "ql_lcd.h"
  29. /*===========================================================================
  30. * Macro Definition
  31. ===========================================================================*/
  32. #define QL_DECODER_LOG_LEVEL QL_LOG_LEVEL_INFO
  33. #define QL_DECODER_LOG(msg, ...) QL_LOG(QL_DECODER_LOG_LEVEL, "ql_DECODERDEMO", msg, ##__VA_ARGS__)
  34. #define QL_DECODER_LOG_PUSH(msg, ...) QL_LOG_PUSH("ql_DECODERDEMO", msg, ##__VA_ARGS__)
  35. #define QL_DECODER_TASK_STACK_SIZE (10*1024)
  36. #define QL_DECODER_TASK_PRIO APP_PRIORITY_NORMAL
  37. #define QL_DECODER_TASK_EVENT_CNT 5
  38. /*===========================================================================
  39. * Struct
  40. ===========================================================================*/
  41. /*===========================================================================
  42. * Enum
  43. ===========================================================================*/
  44. /*===========================================================================
  45. * Variate
  46. ===========================================================================*/
  47. /*===========================================================================
  48. * Functions
  49. ===========================================================================*/
  50. void ql_decoder_demo_thread(void *param)
  51. {
  52. uint16_t *pcamData =NULL;
  53. int iret = 0;
  54. unsigned char result[128] = {0};
  55. unsigned char version[20] = {0};
  56. ql_cam_drv_s cam;
  57. ql_decoder_type_e type = QL_DECODER_TYPE_NONE;
  58. ql_CamInit(320, 240);
  59. ql_CamGetSensorInfo(&cam);
  60. ql_CamPowerOn();
  61. ql_qr_decoder_init();
  62. if(ql_lcd_init() == QL_LCD_SUCCESS)
  63. ql_lcd_display_on();
  64. ql_CamPreview();
  65. ql_get_decoder_version(version);
  66. QL_DECODER_LOG("version=%s", version);
  67. while(1)
  68. {
  69. //ql_CamCaptureImage(&pcamData);
  70. ql_camPrint(pcamData);
  71. iret = ql_qr_image_decoder(pcamData, cam.img_width, cam.img_height);
  72. if(iret == QL_DECODER_SUCCESS)
  73. {
  74. iret = ql_qr_get_decoder_result(&type, result);
  75. if(iret == QL_DECODER_SUCCESS)
  76. {
  77. QL_DECODER_LOG("decode tyep=%d, result=%s", type, result);
  78. }
  79. else
  80. {
  81. QL_DECODER_LOG("decode failed");
  82. }
  83. }
  84. else
  85. QL_DECODER_LOG("decode failed");
  86. ql_rtos_task_sleep_ms(200);
  87. }
  88. }
  89. void ql_decoder_app_init(void)
  90. {
  91. QlDECODERStatus err = QL_OSI_SUCCESS;
  92. ql_task_t decoder_task = NULL;
  93. err = ql_rtos_task_create(&decoder_task, QL_DECODER_TASK_STACK_SIZE, QL_DECODER_TASK_PRIO, "decoder DEMO", ql_decoder_demo_thread, NULL, QL_DECODER_TASK_EVENT_CNT);
  94. if (err != QL_OSI_SUCCESS)
  95. {
  96. QL_DECODER_LOG("DECODER demo task created failed");
  97. }
  98. }