La Paste
Create new paste
Pastes Archive
2023-11-13 14:20:33
copy
raw
download
$cameras = new Cameras(); $detector = new NREngine(); $storage = new Storages(); $webPath = pathinfo($_SERVER['REQUEST_URI']); $webPath = $webPath['dirname']; $baseUrl = 'http://' . $_SERVER['HTTP_HOST'] . $webPath . '/'; deb($baseUrl); $cameraId = '59'; $dateFrom = '2023-11-10'; $allCamerasData = $cameras->getAllCamerasFullData(); $cameraData = $allCamerasData[$cameraId]['CAMERA']; $cameraStorageData = $allCamerasData[$cameraId]['STORAGE']; $dateFromTs = strtotime($dateFrom . ' 00:00:00'); $dateToTs = strtotime($dateFrom . ' 23:59:59'); $minuteBetweenNow = strtotime('-1 minute', time()); $storagePath = $cameraStorageData['path']; $storagePathLastChar = substr($storagePath, 0, -1); $howlChunkPath = Storages::PATH_HOWL . '/'; $chunksList = $storage->getChannelChunks($cameraData['storageid'], $cameraData['channel']); $filteredChunks = array(); $detectionsTmp = array(); if (!empty($chunksList)) { foreach ($chunksList as $chunkTimeStamp => $chunkPath) { if (zb_isTimeStampBetween($dateFromTs, $dateToTs, $chunkTimeStamp)) { $howlChunkFullPath = str_replace($storagePath, $howlChunkPath, $chunkPath); $howlChunkFullPath = str_replace('//', '/', $howlChunkFullPath); //excluding last minute chunk - it may be unfinished now if ($chunkTimeStamp < $minuteBetweenNow) { $filteredChunks[$chunkTimeStamp] = $baseUrl . $howlChunkFullPath; } } } } // debarr($filteredChunks); if (!empty($filteredChunks)) { foreach ($filteredChunks as $eachChunk => $eachUrl) { $chunkDetections = $detector->detectObjects($eachUrl); if (isset($chunkDetections['detections'])) { if (!empty($chunkDetections['detections'])) { foreach ($chunkDetections as $io => $each) { $chunkDatetime = date("Y-m-d H:i:s", $eachChunk); $objectsList = array(); foreach ($chunkDetections['detections'] as $io => $each) { $objectsList [] = __($each['label']) . ' '; } $detectionsTmp[$eachChunk] = $objectsList; } } } } } debarr($detectionsTmp);
↑