ClassControllCamera.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. #include "ClassControllCamera.h"
  2. #include "ClassLogFile.h"
  3. #include <stdio.h>
  4. #include "driver/gpio.h"
  5. #include "esp_timer.h"
  6. #include "esp_log.h"
  7. #include "Helper.h"
  8. #include "CImageBasis.h"
  9. #include "server_ota.h"
  10. #define BOARD_ESP32CAM_AITHINKER
  11. #include <esp_event_loop.h>
  12. #include <esp_log.h>
  13. #include <esp_system.h>
  14. #include <nvs_flash.h>
  15. #include <sys/param.h>
  16. #include <string.h>
  17. #include "freertos/FreeRTOS.h"
  18. #include "freertos/task.h"
  19. #include "esp_camera.h"
  20. // #define DEBUG_DETAIL_ON
  21. // ESP32Cam (AiThinker) PIN Map
  22. #define CAM_PIN_PWDN (gpio_num_t) 32
  23. #define CAM_PIN_RESET -1 //software reset will be performed
  24. #define CAM_PIN_XCLK 0
  25. #define CAM_PIN_SIOD 26
  26. #define CAM_PIN_SIOC 27
  27. #define CAM_PIN_D7 35
  28. #define CAM_PIN_D6 34
  29. #define CAM_PIN_D5 39
  30. #define CAM_PIN_D4 36
  31. #define CAM_PIN_D3 21
  32. #define CAM_PIN_D2 19
  33. #define CAM_PIN_D1 18
  34. #define CAM_PIN_D0 5
  35. #define CAM_PIN_VSYNC 25
  36. #define CAM_PIN_HREF 23
  37. #define CAM_PIN_PCLK 22
  38. static const char *TAG = "example:take_picture";
  39. static camera_config_t camera_config = {
  40. .pin_pwdn = CAM_PIN_PWDN,
  41. .pin_reset = CAM_PIN_RESET,
  42. .pin_xclk = CAM_PIN_XCLK,
  43. .pin_sscb_sda = CAM_PIN_SIOD,
  44. .pin_sscb_scl = CAM_PIN_SIOC,
  45. .pin_d7 = CAM_PIN_D7,
  46. .pin_d6 = CAM_PIN_D6,
  47. .pin_d5 = CAM_PIN_D5,
  48. .pin_d4 = CAM_PIN_D4,
  49. .pin_d3 = CAM_PIN_D3,
  50. .pin_d2 = CAM_PIN_D2,
  51. .pin_d1 = CAM_PIN_D1,
  52. .pin_d0 = CAM_PIN_D0,
  53. .pin_vsync = CAM_PIN_VSYNC,
  54. .pin_href = CAM_PIN_HREF,
  55. .pin_pclk = CAM_PIN_PCLK,
  56. //XCLK 20MHz or 10MHz for OV2640 double FPS (Experimental)
  57. // .xclk_freq_hz = 20000000, // Orginalwert
  58. .xclk_freq_hz = 5000000, // Test, um die Bildfehler los zu werden !!!! ging mal mit 5000000
  59. .ledc_timer = LEDC_TIMER_0,
  60. .ledc_channel = LEDC_CHANNEL_0,
  61. .pixel_format = PIXFORMAT_JPEG, //YUV422,GRAYSCALE,RGB565,JPEG
  62. .frame_size = FRAMESIZE_VGA, //QQVGA-UXGA Do not use sizes above QVGA when not JPEG
  63. // .frame_size = FRAMESIZE_UXGA, //QQVGA-UXGA Do not use sizes above QVGA when not JPEG
  64. .jpeg_quality = 5, //0-63 lower number means higher quality
  65. .fb_count = 2 //if more than one, i2s runs in continuous mode. Use only with JPEG
  66. };
  67. #include "driver/ledc.h"
  68. CCamera Camera;
  69. #define FLASH_GPIO GPIO_NUM_4
  70. #define BLINK_GPIO GPIO_NUM_33
  71. typedef struct {
  72. httpd_req_t *req;
  73. size_t len;
  74. } jpg_chunking_t;
  75. #define LEDC_LS_CH2_GPIO (4)
  76. #define LEDC_LS_CH2_CHANNEL LEDC_CHANNEL_2
  77. #define LEDC_LS_TIMER LEDC_TIMER_1
  78. #define LEDC_LS_MODE LEDC_LOW_SPEED_MODE
  79. #define LEDC_TEST_DUTY (4000)
  80. void test(){
  81. ledc_channel_config_t ledc_channel = { };
  82. ledc_channel.channel = LEDC_LS_CH2_CHANNEL;
  83. ledc_channel.duty = 0;
  84. ledc_channel.gpio_num = FLASH_GPIO;
  85. ledc_channel.speed_mode = LEDC_LS_MODE;
  86. ledc_channel.hpoint = 0;
  87. ledc_channel.timer_sel = LEDC_LS_TIMER;
  88. ledc_channel_config(&ledc_channel);
  89. ledc_set_duty(ledc_channel.speed_mode, ledc_channel.channel, LEDC_TEST_DUTY);
  90. ledc_update_duty(ledc_channel.speed_mode, ledc_channel.channel);
  91. vTaskDelay(1000 / portTICK_PERIOD_MS);
  92. };
  93. static size_t jpg_encode_stream(void * arg, size_t index, const void* data, size_t len){
  94. jpg_chunking_t *j = (jpg_chunking_t *)arg;
  95. if(!index){
  96. j->len = 0;
  97. }
  98. if(httpd_resp_send_chunk(j->req, (const char *)data, len) != ESP_OK){
  99. return 0;
  100. }
  101. j->len += len;
  102. return len;
  103. }
  104. bool CCamera::SetBrightnessContrastSaturation(int _brightness, int _contrast, int _saturation)
  105. {
  106. bool result = false;
  107. sensor_t * s = esp_camera_sensor_get();
  108. if (_brightness > -100)
  109. _brightness = min(2, max(-2, _brightness));
  110. if (_contrast > -100)
  111. _contrast = min(2, max(-2, _contrast));
  112. // _saturation = min(2, max(-2, _saturation));
  113. // s->set_saturation(s, _saturation);
  114. if (_contrast > -100)
  115. s->set_contrast(s, _contrast);
  116. if (_brightness > -100)
  117. s->set_brightness(s, _brightness);
  118. if ((_brightness != brightness) && (_brightness > -100))
  119. result = true;
  120. if ((_contrast != contrast) && (_contrast > -100))
  121. result = true;
  122. if ((_saturation != saturation) && (_saturation > -100))
  123. result = true;
  124. if (_brightness > -100)
  125. brightness = _brightness;
  126. if (_contrast > -100)
  127. contrast = _contrast;
  128. if (_saturation > -100)
  129. saturation = _saturation;
  130. if (result && isFixedExposure)
  131. EnableAutoExposure(waitbeforepicture_org);
  132. return result;
  133. }
  134. void CCamera::SetQualitySize(int qual, framesize_t resol)
  135. {
  136. sensor_t * s = esp_camera_sensor_get();
  137. s->set_quality(s, qual);
  138. s->set_framesize(s, resol);
  139. ActualResolution = resol;
  140. ActualQuality = qual;
  141. if (resol == FRAMESIZE_QVGA)
  142. {
  143. image_height = 240;
  144. image_width = 320;
  145. }
  146. if (resol == FRAMESIZE_VGA)
  147. {
  148. image_height = 480;
  149. image_width = 640;
  150. }
  151. // No higher Mode than VGA, damit der Kameraspeicher ausreicht.
  152. /*
  153. if (resol == FRAMESIZE_SVGA)
  154. {
  155. image_height = 600;
  156. image_width = 800;
  157. }
  158. if (resol == FRAMESIZE_XGA)
  159. {
  160. image_height = 768;
  161. image_width = 1024;
  162. }
  163. if (resol == FRAMESIZE_SXGA)
  164. {
  165. image_height = 1024;
  166. image_width = 1280;
  167. }
  168. if (resol == FRAMESIZE_UXGA)
  169. {
  170. image_height = 1200;
  171. image_width = 1600;
  172. }
  173. */
  174. }
  175. void CCamera::EnableAutoExposure(int flashdauer)
  176. {
  177. LEDOnOff(true);
  178. LightOnOff(true);
  179. const TickType_t xDelay = flashdauer / portTICK_PERIOD_MS;
  180. vTaskDelay( xDelay );
  181. sensor_t * s = esp_camera_sensor_get();
  182. s->set_gain_ctrl(s, 0);
  183. s->set_exposure_ctrl(s, 0);
  184. LEDOnOff(false);
  185. LightOnOff(false);
  186. isFixedExposure = true;
  187. waitbeforepicture_org = flashdauer;
  188. }
  189. esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay)
  190. {
  191. string ftype;
  192. uint8_t *zwischenspeicher = NULL;
  193. LEDOnOff(true);
  194. #ifdef DEBUG_DETAIL_ON
  195. LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - Start");
  196. #endif
  197. if (delay > 0)
  198. {
  199. LightOnOff(true);
  200. const TickType_t xDelay = delay / portTICK_PERIOD_MS;
  201. vTaskDelay( xDelay );
  202. }
  203. #ifdef DEBUG_DETAIL_ON
  204. LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - After LightOn");
  205. #endif
  206. camera_fb_t * fb = esp_camera_fb_get();
  207. if (!fb) {
  208. ESP_LOGE(TAGCAMERACLASS, "Camera Capture Failed");
  209. LightOnOff(false);
  210. LogFile.WriteHeapInfo("Camera Capture Failed - Reinit Camera");
  211. Camera.InitCam();
  212. doReboot();
  213. return ESP_FAIL;
  214. }
  215. int _size = fb->len;
  216. zwischenspeicher = (uint8_t*) malloc(_size);
  217. for (int i = 0; i < _size; ++i)
  218. *(zwischenspeicher + i) = *(fb->buf + i);
  219. esp_camera_fb_return(fb);
  220. #ifdef DEBUG_DETAIL_ON
  221. LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - After fb_get");
  222. #endif
  223. LEDOnOff(false);
  224. if (delay > 0)
  225. LightOnOff(false);
  226. // TickType_t xDelay = 1000 / portTICK_PERIOD_MS;
  227. // vTaskDelay( xDelay ); // wait for power to recover
  228. uint8_t * buf = NULL;
  229. CImageBasis _zwImage;
  230. _zwImage.LoadFromMemory(zwischenspeicher, _size);
  231. free(zwischenspeicher);
  232. #ifdef DEBUG_DETAIL_ON
  233. LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - After LoadFromMemory");
  234. #endif
  235. stbi_uc* p_target;
  236. stbi_uc* p_source;
  237. int channels = 3;
  238. int width = image_width;
  239. int height = image_height;
  240. #ifdef DEBUG_DETAIL_ON
  241. std::string _zw = "Targetimage: " + std::to_string((int) _Image->rgb_image) + " Size: " + std::to_string(_Image->width) + ", " + std::to_string(_Image->height);
  242. _zw = _zw + " _zwImage: " + std::to_string((int) _zwImage.rgb_image) + " Size: " + std::to_string(_zwImage.width) + ", " + std::to_string(_zwImage.height);
  243. LogFile.WriteToFile(_zw);
  244. #endif
  245. for (int x = 0; x < width; ++x)
  246. for (int y = 0; y < height; ++y)
  247. {
  248. p_target = _Image->rgb_image + (channels * (y * width + x));
  249. p_source = _zwImage.rgb_image + (channels * (y * width + x));
  250. p_target[0] = p_source[0];
  251. p_target[1] = p_source[1];
  252. p_target[2] = p_source[2];
  253. }
  254. #ifdef DEBUG_DETAIL_ON
  255. LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - After Copy To Target");
  256. #endif
  257. free(buf);
  258. #ifdef DEBUG_DETAIL_ON
  259. LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - Done");
  260. #endif
  261. return ESP_OK;
  262. }
  263. esp_err_t CCamera::CaptureToFile(std::string nm, int delay)
  264. {
  265. string ftype;
  266. LEDOnOff(true); // Abgeschaltet, um Strom zu sparen !!!!!!
  267. if (delay > 0)
  268. {
  269. LightOnOff(true);
  270. const TickType_t xDelay = delay / portTICK_PERIOD_MS;
  271. vTaskDelay( xDelay );
  272. }
  273. camera_fb_t * fb = esp_camera_fb_get();
  274. if (!fb) {
  275. ESP_LOGE(TAGCAMERACLASS, "Camera Capture Failed");
  276. LEDOnOff(false);
  277. LogFile.WriteHeapInfo("Camera Capture Failed - Reinit Camera");
  278. Camera.InitCam();
  279. doReboot();
  280. return ESP_FAIL;
  281. }
  282. LEDOnOff(false);
  283. #ifdef DEBUG_DETAIL_ON
  284. printf("w %d, h %d, size %d\n", fb->width, fb->height, fb->len);
  285. #endif
  286. nm = FormatFileName(nm);
  287. #ifdef DEBUG_DETAIL_ON
  288. printf("Save Camera to : %s\n", nm.c_str());
  289. #endif
  290. ftype = toUpper(getFileType(nm));
  291. #ifdef DEBUG_DETAIL_ON
  292. printf("Filetype: %s\n", ftype.c_str());
  293. #endif
  294. uint8_t * buf = NULL;
  295. size_t buf_len = 0;
  296. bool converted = false;
  297. if (ftype.compare("BMP") == 0)
  298. {
  299. frame2bmp(fb, &buf, &buf_len);
  300. converted = true;
  301. }
  302. if (ftype.compare("JPG") == 0)
  303. {
  304. if(fb->format != PIXFORMAT_JPEG){
  305. bool jpeg_converted = frame2jpg(fb, ActualQuality, &buf, &buf_len);
  306. converted = true;
  307. if(!jpeg_converted){
  308. ESP_LOGE(TAGCAMERACLASS, "JPEG compression failed");
  309. }
  310. } else {
  311. buf_len = fb->len;
  312. buf = fb->buf;
  313. }
  314. }
  315. FILE * fp = OpenFileAndWait(nm.c_str(), "wb");
  316. if (fp == NULL) /* If an error occurs during the file creation */
  317. {
  318. fprintf(stderr, "fopen() failed for '%s'\n", nm.c_str());
  319. }
  320. else
  321. {
  322. fwrite(buf, sizeof(uint8_t), buf_len, fp);
  323. fclose(fp);
  324. }
  325. if (converted)
  326. free(buf);
  327. esp_camera_fb_return(fb);
  328. if (delay > 0)
  329. {
  330. LightOnOff(false);
  331. }
  332. return ESP_OK;
  333. }
  334. esp_err_t CCamera::CaptureToHTTP(httpd_req_t *req, int delay)
  335. {
  336. camera_fb_t * fb = NULL;
  337. esp_err_t res = ESP_OK;
  338. size_t fb_len = 0;
  339. int64_t fr_start = esp_timer_get_time();
  340. LEDOnOff(true);
  341. if (delay > 0)
  342. {
  343. LightOnOff(true);
  344. const TickType_t xDelay = delay / portTICK_PERIOD_MS;
  345. vTaskDelay( xDelay );
  346. }
  347. fb = esp_camera_fb_get();
  348. if (!fb) {
  349. ESP_LOGE(TAGCAMERACLASS, "Camera capture failed");
  350. LightOnOff(false);
  351. LogFile.WriteHeapInfo("Camera Capture Failed - Reinit Camera");
  352. Camera.InitCam();
  353. doReboot();
  354. httpd_resp_send_500(req);
  355. return ESP_FAIL;
  356. }
  357. LEDOnOff(false);
  358. res = httpd_resp_set_type(req, "image/jpeg");
  359. if(res == ESP_OK){
  360. res = httpd_resp_set_hdr(req, "Content-Disposition", "inline; filename=raw.jpg");
  361. }
  362. if(res == ESP_OK){
  363. if(fb->format == PIXFORMAT_JPEG){
  364. fb_len = fb->len;
  365. res = httpd_resp_send(req, (const char *)fb->buf, fb->len);
  366. } else {
  367. jpg_chunking_t jchunk = {req, 0};
  368. res = frame2jpg_cb(fb, 80, jpg_encode_stream, &jchunk)?ESP_OK:ESP_FAIL;
  369. httpd_resp_send_chunk(req, NULL, 0);
  370. fb_len = jchunk.len;
  371. }
  372. }
  373. esp_camera_fb_return(fb);
  374. int64_t fr_end = esp_timer_get_time();
  375. ESP_LOGI(TAGCAMERACLASS, "JPG: %uKB %ums", (uint32_t)(fb_len/1024), (uint32_t)((fr_end - fr_start)/1000));
  376. if (delay > 0)
  377. {
  378. LightOnOff(false);
  379. }
  380. return res;
  381. }
  382. void CCamera::LightOnOff(bool status)
  383. {
  384. // Init the GPIO
  385. gpio_pad_select_gpio(FLASH_GPIO);
  386. /* Set the GPIO as a push/pull output */
  387. gpio_set_direction(FLASH_GPIO, GPIO_MODE_OUTPUT);
  388. if (status)
  389. gpio_set_level(FLASH_GPIO, 1);
  390. else
  391. gpio_set_level(FLASH_GPIO, 0);
  392. }
  393. void CCamera::LEDOnOff(bool status)
  394. {
  395. // Init the GPIO
  396. gpio_pad_select_gpio(BLINK_GPIO);
  397. /* Set the GPIO as a push/pull output */
  398. gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
  399. if (!status)
  400. gpio_set_level(BLINK_GPIO, 1);
  401. else
  402. gpio_set_level(BLINK_GPIO, 0);
  403. }
  404. void CCamera::GetCameraParameter(httpd_req_t *req, int &qual, framesize_t &resol)
  405. {
  406. char _query[100];
  407. char _qual[10];
  408. char _size[10];
  409. resol = ActualResolution;
  410. qual = ActualQuality;
  411. if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
  412. {
  413. printf("Query: "); printf(_query); printf("\n");
  414. if (httpd_query_key_value(_query, "size", _size, 10) == ESP_OK)
  415. {
  416. #ifdef DEBUG_DETAIL_ON
  417. printf("Size: "); printf(_size); printf("\n");
  418. #endif
  419. if (strcmp(_size, "QVGA") == 0)
  420. resol = FRAMESIZE_QVGA; // 320x240
  421. if (strcmp(_size, "VGA") == 0)
  422. resol = FRAMESIZE_VGA; // 640x480
  423. if (strcmp(_size, "SVGA") == 0)
  424. resol = FRAMESIZE_SVGA; // 800x600
  425. if (strcmp(_size, "XGA") == 0)
  426. resol = FRAMESIZE_XGA; // 1024x768
  427. if (strcmp(_size, "SXGA") == 0)
  428. resol = FRAMESIZE_SXGA; // 1280x1024
  429. if (strcmp(_size, "UXGA") == 0)
  430. resol = FRAMESIZE_UXGA; // 1600x1200
  431. }
  432. if (httpd_query_key_value(_query, "quality", _qual, 10) == ESP_OK)
  433. {
  434. #ifdef DEBUG_DETAIL_ON
  435. printf("Quality: "); printf(_qual); printf("\n");
  436. #endif
  437. qual = atoi(_qual);
  438. if (qual > 63)
  439. qual = 63;
  440. if (qual < 0)
  441. qual = 0;
  442. }
  443. };
  444. }
  445. framesize_t CCamera::TextToFramesize(const char * _size)
  446. {
  447. if (strcmp(_size, "QVGA") == 0)
  448. return FRAMESIZE_QVGA; // 320x240
  449. if (strcmp(_size, "VGA") == 0)
  450. return FRAMESIZE_VGA; // 640x480
  451. if (strcmp(_size, "SVGA") == 0)
  452. return FRAMESIZE_SVGA; // 800x600
  453. if (strcmp(_size, "XGA") == 0)
  454. return FRAMESIZE_XGA; // 1024x768
  455. if (strcmp(_size, "SXGA") == 0)
  456. return FRAMESIZE_SXGA; // 1280x1024
  457. if (strcmp(_size, "UXGA") == 0)
  458. return FRAMESIZE_UXGA; // 1600x1200
  459. return ActualResolution;
  460. }
  461. CCamera::CCamera()
  462. {
  463. #ifdef DEBUG_DETAIL_ON
  464. printf("CreateClassCamera\n");
  465. #endif
  466. brightness = -5;
  467. contrast = -5;
  468. saturation = -5;
  469. isFixedExposure = false;
  470. ActualQuality = camera_config.jpeg_quality;
  471. ActualResolution = camera_config.frame_size;
  472. }
  473. esp_err_t CCamera::InitCam()
  474. {
  475. esp_camera_deinit();
  476. PowerResetCamera();
  477. if(CAM_PIN_PWDN != -1){
  478. // Init the GPIO
  479. gpio_pad_select_gpio(CAM_PIN_PWDN);
  480. /* Set the GPIO as a push/pull output */
  481. gpio_set_direction(CAM_PIN_PWDN, GPIO_MODE_OUTPUT);
  482. gpio_set_level(CAM_PIN_PWDN, 0);
  483. }
  484. printf("Init Camera\n");
  485. //initialize the camera
  486. esp_err_t err = esp_camera_init(&camera_config);
  487. if (err != ESP_OK) {
  488. ESP_LOGE(TAGCAMERACLASS, "Camera Init Failed");
  489. return err;
  490. }
  491. SetBrightnessContrastSaturation(brightness, contrast, saturation);
  492. SetQualitySize(ActualQuality, ActualResolution);
  493. if (isFixedExposure)
  494. EnableAutoExposure(waitbeforepicture_org);
  495. LightOnOff(false);
  496. return ESP_OK;
  497. }
  498. /////////////////////////////////////////////////////////////////////////////////////////////////
  499. /////////////////////////////////////////////////////////////////////////////////////////////////
  500. /////////////////////////////////////////////////////////////////////////////////////////////////
  501. void PowerResetCamera(){
  502. printf("Resetting camera by power down line.\n");
  503. /*
  504. gpio_config_t conf = { 0 };
  505. conf.pin_bit_mask = 1LL << GPIO_NUM_32;
  506. conf.mode = GPIO_MODE_OUTPUT;
  507. gpio_config(&conf);
  508. */
  509. gpio_pad_select_gpio(GPIO_NUM_32);
  510. /* Set the GPIO as a push/pull output */
  511. gpio_set_direction(GPIO_NUM_32, GPIO_MODE_OUTPUT);
  512. // carefull, logic is inverted compared to reset pin
  513. gpio_set_level(GPIO_NUM_32, 0); // ehemals 1 !!!!!!!!!!!!!!!!!!!!
  514. vTaskDelay(1000 / portTICK_PERIOD_MS);
  515. gpio_set_level(GPIO_NUM_32, 1); // ehemals 0 !!!!!!!!!!!!!!!!!!!!
  516. vTaskDelay(1000 / portTICK_PERIOD_MS);
  517. }