ClassFlowTakeImage.cpp 20 KB

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