ClassFlowTakeImage.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <regex>
  5. #include "ClassFlowTakeImage.h"
  6. #include <new>
  7. #include "Helper.h"
  8. #include "ClassLogFile.h"
  9. #include "CImageBasis.h"
  10. #include "ClassControllCamera.h"
  11. #include "MainFlowControl.h"
  12. #include "esp_wifi.h"
  13. #include "esp_log.h"
  14. #include "../../include/defines.h"
  15. #include "psram.h"
  16. #include <time.h>
  17. // #define DEBUG_DETAIL_ON
  18. // #define WIFITURNOFF
  19. static const char *TAG = "TAKEIMAGE";
  20. bool ClassFlowTakeImage::takePictureWithFlash(int flash_duration)
  21. {
  22. if (rawImage == NULL) {
  23. LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "takePictureWithFlash: raw image object is unavailable");
  24. return false;
  25. }
  26. const CameraSettings &activeSettings = static_cast<const CameraSettings &>(CCstatus);
  27. if (rawImage->width != activeSettings.ImageWidth || rawImage->height != activeSettings.ImageHeight ||
  28. rawImage->channels != 3) {
  29. rawImage->CreateEmptyImage(activeSettings.ImageWidth, activeSettings.ImageHeight, 3);
  30. }
  31. if (!rawImage->ImageOkay()) {
  32. LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "takePictureWithFlash: raw image PSRAM buffer is unavailable");
  33. return false;
  34. }
  35. ESP_LOGD(TAG, "flash_duration: %d", flash_duration);
  36. if (Camera.CaptureToBasisImage(rawImage, flash_duration) != ESP_OK) return false;
  37. time(&TimeImageTaken);
  38. localtime(&TimeImageTaken);
  39. if (CCstatus.SaveAllFiles) rawImage->SaveToFile(namerawimage);
  40. return true;
  41. }
  42. void ClassFlowTakeImage::SetInitialParameter(void)
  43. {
  44. TimeImageTaken = 0;
  45. rawImage = NULL;
  46. disabled = false;
  47. namerawimage = "/sdcard/img_tmp/raw.jpg";
  48. }
  49. // auslesen der Kameraeinstellungen aus der config.ini
  50. // wird beim Start aufgerufen
  51. bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph)
  52. {
  53. Camera.getSensorDatenToCCstatus(); // Kamera >>> CCstatus
  54. std::vector<string> splitted;
  55. aktparamgraph = trim(aktparamgraph);
  56. if (aktparamgraph.size() == 0)
  57. {
  58. if (!this->GetNextParagraph(pfile, aktparamgraph))
  59. {
  60. return false;
  61. }
  62. }
  63. if (aktparamgraph.compare("[TakeImage]") != 0)
  64. {
  65. // Paragraph does not fit TakeImage
  66. return false;
  67. }
  68. while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
  69. {
  70. splitted = ZerlegeZeile(aktparamgraph);
  71. if ((toUpper(splitted[0]) == "RAWIMAGESLOCATION") && (splitted.size() > 1))
  72. {
  73. imagesLocation = "/sdcard" + splitted[1];
  74. isLogImage = true;
  75. }
  76. else if ((toUpper(splitted[0]) == "RAWIMAGESRETENTION") && (splitted.size() > 1))
  77. {
  78. if (isStringNumeric(splitted[1]))
  79. {
  80. this->imagesRetention = std::stod(splitted[1]);
  81. }
  82. }
  83. else if ((toUpper(splitted[0]) == "SAVEALLFILES") && (splitted.size() > 1))
  84. {
  85. CCstatus.SaveAllFiles = alphanumericToBoolean(splitted[1]);
  86. }
  87. else if ((toUpper(splitted[0]) == "WAITBEFORETAKINGPICTURE") && (splitted.size() > 1))
  88. {
  89. if (isStringNumeric(splitted[1]))
  90. {
  91. int _WaitBeforePicture = std::stoi(splitted[1]);
  92. CCstatus.WaitBeforePicture = (_WaitBeforePicture != 0) ? max(0, _WaitBeforePicture) : 2;
  93. }
  94. }
  95. else if ((toUpper(splitted[0]) == "CAMXCLKFREQMHZ") && (splitted.size() > 1))
  96. {
  97. if (isStringNumeric(splitted[1]))
  98. {
  99. CCstatus.CamXclkFreqMhz = clipInt(std::stoi(splitted[1]), 20, 1);
  100. }
  101. }
  102. else if ((toUpper(splitted[0]) == "CAMGAINCEILING") && (splitted.size() > 1))
  103. {
  104. std::string _ImageGainceiling = toUpper(splitted[1]);
  105. if (isStringNumeric(_ImageGainceiling))
  106. {
  107. int _ImageGainceiling_ = std::stoi(_ImageGainceiling);
  108. switch (_ImageGainceiling_)
  109. {
  110. case 1:
  111. CCstatus.ImageGainceiling = GAINCEILING_4X;
  112. break;
  113. case 2:
  114. CCstatus.ImageGainceiling = GAINCEILING_8X;
  115. break;
  116. case 3:
  117. CCstatus.ImageGainceiling = GAINCEILING_16X;
  118. break;
  119. case 4:
  120. CCstatus.ImageGainceiling = GAINCEILING_32X;
  121. break;
  122. case 5:
  123. CCstatus.ImageGainceiling = GAINCEILING_64X;
  124. break;
  125. case 6:
  126. CCstatus.ImageGainceiling = GAINCEILING_128X;
  127. break;
  128. default:
  129. CCstatus.ImageGainceiling = GAINCEILING_2X;
  130. }
  131. }
  132. else
  133. {
  134. if (_ImageGainceiling == "X4")
  135. {
  136. CCstatus.ImageGainceiling = GAINCEILING_4X;
  137. }
  138. else if (_ImageGainceiling == "X8")
  139. {
  140. CCstatus.ImageGainceiling = GAINCEILING_8X;
  141. }
  142. else if (_ImageGainceiling == "X16")
  143. {
  144. CCstatus.ImageGainceiling = GAINCEILING_16X;
  145. }
  146. else if (_ImageGainceiling == "X32")
  147. {
  148. CCstatus.ImageGainceiling = GAINCEILING_32X;
  149. }
  150. else if (_ImageGainceiling == "X64")
  151. {
  152. CCstatus.ImageGainceiling = GAINCEILING_64X;
  153. }
  154. else if (_ImageGainceiling == "X128")
  155. {
  156. CCstatus.ImageGainceiling = GAINCEILING_128X;
  157. }
  158. else
  159. {
  160. CCstatus.ImageGainceiling = GAINCEILING_2X;
  161. }
  162. }
  163. }
  164. else if ((toUpper(splitted[0]) == "CAMQUALITY") && (splitted.size() > 1))
  165. {
  166. if (isStringNumeric(splitted[1]))
  167. {
  168. int _ImageQuality = std::stoi(splitted[1]);
  169. CCstatus.ImageQuality = clipInt(_ImageQuality, 63, 6);
  170. }
  171. }
  172. else if ((toUpper(splitted[0]) == "CAMBRIGHTNESS") && (splitted.size() > 1))
  173. {
  174. if (isStringNumeric(splitted[1]))
  175. {
  176. int _ImageBrightness = std::stoi(splitted[1]);
  177. CCstatus.ImageBrightness = clipInt(_ImageBrightness, 2, -2);
  178. }
  179. }
  180. else if ((toUpper(splitted[0]) == "CAMCONTRAST") && (splitted.size() > 1))
  181. {
  182. if (isStringNumeric(splitted[1]))
  183. {
  184. int _ImageContrast = std::stoi(splitted[1]);
  185. CCstatus.ImageContrast = clipInt(_ImageContrast, 2, -2);
  186. }
  187. }
  188. else if ((toUpper(splitted[0]) == "CAMSATURATION") && (splitted.size() > 1))
  189. {
  190. if (isStringNumeric(splitted[1]))
  191. {
  192. int _ImageSaturation = std::stoi(splitted[1]);
  193. CCstatus.ImageSaturation = clipInt(_ImageSaturation, 2, -2);
  194. }
  195. }
  196. else if ((toUpper(splitted[0]) == "CAMSHARPNESS") && (splitted.size() > 1))
  197. {
  198. if (isStringNumeric(splitted[1]))
  199. {
  200. int _ImageSharpness = std::stoi(splitted[1]);
  201. if (CCstatus.CamSensor_id == OV2640_PID)
  202. {
  203. CCstatus.ImageSharpness = clipInt(_ImageSharpness, 2, -2);
  204. }
  205. else
  206. {
  207. CCstatus.ImageSharpness = clipInt(_ImageSharpness, 3, -3);
  208. }
  209. }
  210. }
  211. else if ((toUpper(splitted[0]) == "CAMAUTOSHARPNESS") && (splitted.size() > 1))
  212. {
  213. CCstatus.ImageAutoSharpness = alphanumericToBoolean(splitted[1]);
  214. }
  215. else if ((toUpper(splitted[0]) == "CAMSPECIALEFFECT") && (splitted.size() > 1))
  216. {
  217. std::string _ImageSpecialEffect = toUpper(splitted[1]);
  218. if (isStringNumeric(_ImageSpecialEffect))
  219. {
  220. int _ImageSpecialEffect_ = std::stoi(_ImageSpecialEffect);
  221. CCstatus.ImageSpecialEffect = clipInt(_ImageSpecialEffect_, 6, 0);
  222. }
  223. else
  224. {
  225. if (_ImageSpecialEffect == "NEGATIVE")
  226. {
  227. CCstatus.ImageSpecialEffect = 1;
  228. }
  229. else if (_ImageSpecialEffect == "GRAYSCALE")
  230. {
  231. CCstatus.ImageSpecialEffect = 2;
  232. }
  233. else if (_ImageSpecialEffect == "RED")
  234. {
  235. CCstatus.ImageSpecialEffect = 3;
  236. }
  237. else if (_ImageSpecialEffect == "GREEN")
  238. {
  239. CCstatus.ImageSpecialEffect = 4;
  240. }
  241. else if (_ImageSpecialEffect == "BLUE")
  242. {
  243. CCstatus.ImageSpecialEffect = 5;
  244. }
  245. else if (_ImageSpecialEffect == "RETRO")
  246. {
  247. CCstatus.ImageSpecialEffect = 6;
  248. }
  249. else
  250. {
  251. CCstatus.ImageSpecialEffect = 0;
  252. }
  253. }
  254. }
  255. else if ((toUpper(splitted[0]) == "CAMWBMODE") && (splitted.size() > 1))
  256. {
  257. std::string _ImageWbMode = toUpper(splitted[1]);
  258. if (isStringNumeric(_ImageWbMode))
  259. {
  260. int _ImageWbMode_ = std::stoi(_ImageWbMode);
  261. CCstatus.ImageWbMode = clipInt(_ImageWbMode_, 4, 0);
  262. }
  263. else
  264. {
  265. if (_ImageWbMode == "SUNNY")
  266. {
  267. CCstatus.ImageWbMode = 1;
  268. }
  269. else if (_ImageWbMode == "CLOUDY")
  270. {
  271. CCstatus.ImageWbMode = 2;
  272. }
  273. else if (_ImageWbMode == "OFFICE")
  274. {
  275. CCstatus.ImageWbMode = 3;
  276. }
  277. else if (_ImageWbMode == "HOME")
  278. {
  279. CCstatus.ImageWbMode = 4;
  280. }
  281. else
  282. {
  283. CCstatus.ImageWbMode = 0;
  284. }
  285. }
  286. }
  287. else if ((toUpper(splitted[0]) == "CAMAWB") && (splitted.size() > 1))
  288. {
  289. CCstatus.ImageAwb = alphanumericToBoolean(splitted[1]);
  290. }
  291. else if ((toUpper(splitted[0]) == "CAMAWBGAIN") && (splitted.size() > 1))
  292. {
  293. CCstatus.ImageAwbGain = alphanumericToBoolean(splitted[1]);
  294. }
  295. else if ((toUpper(splitted[0]) == "CAMAEC") && (splitted.size() > 1))
  296. {
  297. CCstatus.ImageAec = alphanumericToBoolean(splitted[1]);
  298. }
  299. else if ((toUpper(splitted[0]) == "CAMAEC2") && (splitted.size() > 1))
  300. {
  301. CCstatus.ImageAec2 = alphanumericToBoolean(splitted[1]);
  302. }
  303. else if ((toUpper(splitted[0]) == "CAMAELEVEL") && (splitted.size() > 1))
  304. {
  305. if (isStringNumeric(splitted[1]))
  306. {
  307. int _ImageAeLevel = std::stoi(splitted[1]);
  308. if (CCstatus.CamSensor_id == OV2640_PID)
  309. {
  310. CCstatus.ImageAeLevel = clipInt(_ImageAeLevel, 2, -2);
  311. }
  312. else
  313. {
  314. CCstatus.ImageAeLevel = clipInt(_ImageAeLevel, 5, -5);
  315. }
  316. }
  317. }
  318. else if ((toUpper(splitted[0]) == "CAMAECVALUE") && (splitted.size() > 1))
  319. {
  320. if (isStringNumeric(splitted[1]))
  321. {
  322. int _ImageAecValue = std::stoi(splitted[1]);
  323. CCstatus.ImageAecValue = clipInt(_ImageAecValue, 1200, 0);
  324. }
  325. }
  326. else if ((toUpper(splitted[0]) == "CAMAGC") && (splitted.size() > 1))
  327. {
  328. CCstatus.ImageAgc = alphanumericToBoolean(splitted[1]);
  329. }
  330. else if ((toUpper(splitted[0]) == "CAMAGCGAIN") && (splitted.size() > 1))
  331. {
  332. if (isStringNumeric(splitted[1]))
  333. {
  334. int _ImageAgcGain = std::stoi(splitted[1]);
  335. CCstatus.ImageAgcGain = clipInt(_ImageAgcGain, 30, 0);
  336. }
  337. }
  338. else if ((toUpper(splitted[0]) == "CAMBPC") && (splitted.size() > 1))
  339. {
  340. CCstatus.ImageBpc = alphanumericToBoolean(splitted[1]);
  341. }
  342. else if ((toUpper(splitted[0]) == "CAMWPC") && (splitted.size() > 1))
  343. {
  344. CCstatus.ImageWpc = alphanumericToBoolean(splitted[1]);
  345. }
  346. else if ((toUpper(splitted[0]) == "CAMRAWGMA") && (splitted.size() > 1))
  347. {
  348. CCstatus.ImageRawGma = alphanumericToBoolean(splitted[1]);
  349. }
  350. else if ((toUpper(splitted[0]) == "CAMLENC") && (splitted.size() > 1))
  351. {
  352. CCstatus.ImageLenc = alphanumericToBoolean(splitted[1]);
  353. }
  354. else if ((toUpper(splitted[0]) == "CAMHMIRROR") && (splitted.size() > 1))
  355. {
  356. CCstatus.ImageHmirror = alphanumericToBoolean(splitted[1]);
  357. }
  358. else if ((toUpper(splitted[0]) == "CAMVFLIP") && (splitted.size() > 1))
  359. {
  360. CCstatus.ImageVflip = alphanumericToBoolean(splitted[1]);
  361. }
  362. else if ((toUpper(splitted[0]) == "CAMDCW") && (splitted.size() > 1))
  363. {
  364. CCstatus.ImageDcw = alphanumericToBoolean(splitted[1]);
  365. }
  366. else if ((toUpper(splitted[0]) == "CAMDENOISE") && (splitted.size() > 1))
  367. {
  368. if (isStringNumeric(splitted[1]))
  369. {
  370. int _ImageDenoiseLevel = std::stoi(splitted[1]);
  371. if (CCstatus.CamSensor_id == OV2640_PID)
  372. {
  373. CCstatus.ImageDenoiseLevel = 0;
  374. }
  375. else
  376. {
  377. CCstatus.ImageDenoiseLevel = clipInt(_ImageDenoiseLevel, 8, 0);
  378. }
  379. }
  380. }
  381. else if ((toUpper(splitted[0]) == "CAMZOOM") && (splitted.size() > 1))
  382. {
  383. CCstatus.ImageZoomEnabled = alphanumericToBoolean(splitted[1]);
  384. }
  385. else if ((toUpper(splitted[0]) == "CAMZOOMOFFSETX") && (splitted.size() > 1))
  386. {
  387. if (isStringNumeric(splitted[1]))
  388. {
  389. int _ImageZoomOffsetX = std::stoi(splitted[1]);
  390. if (CCstatus.CamSensor_id == OV2640_PID)
  391. {
  392. CCstatus.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 480, -480);
  393. }
  394. else if (CCstatus.CamSensor_id == OV3660_PID)
  395. {
  396. CCstatus.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 704, -704);
  397. }
  398. else if (CCstatus.CamSensor_id == OV5640_PID)
  399. {
  400. CCstatus.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 960, -960);
  401. }
  402. }
  403. }
  404. else if ((toUpper(splitted[0]) == "CAMZOOMOFFSETY") && (splitted.size() > 1))
  405. {
  406. if (isStringNumeric(splitted[1]))
  407. {
  408. int _ImageZoomOffsetY = std::stoi(splitted[1]);
  409. if (CCstatus.CamSensor_id == OV2640_PID)
  410. {
  411. CCstatus.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 360, -360);
  412. }
  413. else if (CCstatus.CamSensor_id == OV3660_PID)
  414. {
  415. CCstatus.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 528, -528);
  416. }
  417. else if (CCstatus.CamSensor_id == OV5640_PID)
  418. {
  419. CCstatus.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 720, -720);
  420. }
  421. }
  422. }
  423. else if ((toUpper(splitted[0]) == "CAMZOOMSIZE") && (splitted.size() > 1))
  424. {
  425. if (isStringNumeric(splitted[1]))
  426. {
  427. int _ImageZoomSize = std::stoi(splitted[1]);
  428. if (CCstatus.CamSensor_id == OV2640_PID)
  429. {
  430. CCstatus.ImageZoomSize = clipInt(_ImageZoomSize, 29, 0);
  431. }
  432. else if (CCstatus.CamSensor_id == OV3660_PID)
  433. {
  434. CCstatus.ImageZoomSize = clipInt(_ImageZoomSize, 43, 0);
  435. }
  436. else if (CCstatus.CamSensor_id == OV5640_PID)
  437. {
  438. CCstatus.ImageZoomSize = clipInt(_ImageZoomSize, 59, 0);
  439. }
  440. }
  441. }
  442. else if ((toUpper(splitted[0]) == "LEDINTENSITY") && (splitted.size() > 1))
  443. {
  444. if (isStringNumeric(splitted[1]))
  445. {
  446. int ledintensity = std::stoi(splitted[1]);
  447. CCstatus.ImageLedIntensity = Camera.SetLEDIntensity(ledintensity);
  448. }
  449. }
  450. else if ((toUpper(splitted[0]) == "DEMO") && (splitted.size() > 1))
  451. {
  452. CCstatus.DemoMode = alphanumericToBoolean(splitted[1]);
  453. if (CCstatus.DemoMode == true)
  454. {
  455. Camera.useDemoMode();
  456. }
  457. }
  458. }
  459. if (Camera.ApplySettings(CCstatus) != ESP_OK)
  460. {
  461. LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Unable to apply configured camera settings");
  462. return false;
  463. }
  464. delete rawImage;
  465. rawImage = new (std::nothrow) CImageBasis("rawImage");
  466. if (rawImage == NULL) {
  467. LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Unable to allocate raw image object");
  468. return false;
  469. }
  470. rawImage->CreateEmptyImage(CCstatus.ImageWidth, CCstatus.ImageHeight, 3);
  471. if (!rawImage->ImageOkay()) {
  472. LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Unable to allocate raw image PSRAM buffer");
  473. delete rawImage;
  474. rawImage = NULL;
  475. return false;
  476. }
  477. return true;
  478. }
  479. ClassFlowTakeImage::ClassFlowTakeImage(std::vector<ClassFlow *> *lfc) : ClassFlowImage(lfc, TAG)
  480. {
  481. imagesLocation = "/log/source";
  482. imagesRetention = 5;
  483. SetInitialParameter();
  484. }
  485. string ClassFlowTakeImage::getHTMLSingleStep(string host)
  486. {
  487. string result;
  488. result = "Raw Image: <br>\n<img src=\"" + host + "/img_tmp/raw.jpg\">\n";
  489. return result;
  490. }
  491. // wird bei jeder Auswertrunde aufgerufen
  492. bool ClassFlowTakeImage::doFlow(string zwtime)
  493. {
  494. const bool sharedMemoryLeaseAcquired = psram_init_shared_memory_for_take_image_step();
  495. if (!sharedMemoryLeaseAcquired) {
  496. LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Shared PSRAM image lease unavailable; STBI will use independent PSRAM allocations");
  497. }
  498. string logPath = CreateLogFolder(zwtime);
  499. const CameraSettings &activeSettings = static_cast<const CameraSettings &>(CCstatus);
  500. int flash_duration = static_cast<int>(activeSettings.WaitBeforePicture * 1000);
  501. #ifdef DEBUG_DETAIL_ON
  502. LogFile.WriteHeapInfo("ClassFlowTakeImage::doFlow - Before takePictureWithFlash");
  503. #endif
  504. if (Camera.RestoreCommittedSettingsIfNeeded() != ESP_OK)
  505. {
  506. if (sharedMemoryLeaseAcquired) psram_deinit_shared_memory_for_take_image_step();
  507. LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Unable to restore committed camera settings");
  508. return false;
  509. }
  510. #ifdef WIFITURNOFF
  511. esp_wifi_stop(); // save power during image capture
  512. #endif
  513. const bool captured = takePictureWithFlash(flash_duration);
  514. #ifdef WIFITURNOFF
  515. esp_wifi_start();
  516. #endif
  517. #ifdef DEBUG_DETAIL_ON
  518. LogFile.WriteHeapInfo("ClassFlowTakeImage::doFlow - After takePictureWithFlash");
  519. #endif
  520. if (!captured) {
  521. if (sharedMemoryLeaseAcquired) psram_deinit_shared_memory_for_take_image_step();
  522. LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Image capture failed; aborting this flow round");
  523. return false;
  524. }
  525. LogImage(logPath, "raw", NULL, NULL, zwtime, rawImage);
  526. RemoveOldLogs();
  527. #ifdef DEBUG_DETAIL_ON
  528. LogFile.WriteHeapInfo("ClassFlowTakeImage::doFlow - After RemoveOldLogs");
  529. #endif
  530. if (sharedMemoryLeaseAcquired) psram_deinit_shared_memory_for_take_image_step();
  531. return true;
  532. }
  533. esp_err_t ClassFlowTakeImage::SendRawJPG(httpd_req_t *req)
  534. {
  535. const bool previewCapture = CFstatus.previewCapturePending;
  536. const CameraSettings &activeSettings = previewCapture
  537. ? static_cast<const CameraSettings &>(CFstatus)
  538. : static_cast<const CameraSettings &>(CCstatus);
  539. int flash_duration = static_cast<int>(activeSettings.WaitBeforePicture * 1000);
  540. time(&TimeImageTaken);
  541. localtime(&TimeImageTaken);
  542. return Camera.CaptureToHTTP(req, flash_duration, previewCapture);
  543. }
  544. time_t ClassFlowTakeImage::getTimeImageTaken(void)
  545. {
  546. return TimeImageTaken;
  547. }
  548. ClassFlowTakeImage::~ClassFlowTakeImage(void)
  549. {
  550. delete rawImage;
  551. }