Skip to content

Commit f669f72

Browse files
Merge branch 'ai_server' of github.com:connortechnology/zoneminder into ai_server
2 parents 28044f4 + 15fe5bc commit f669f72

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

src/zm_monitor.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2582,12 +2582,17 @@ std::pair<int, std::string> Monitor::Analyse_MxAccl(std::shared_ptr<ZMPacket> pa
25822582
packet->ai_frame = av_frame_ptr(av_frame_alloc());
25832583
ai_image->PopulateFrame(packet->ai_frame.get());
25842584
packet->detections = detections;
2585+
last_detections = detections;
25852586
}
25862587
} else { // skipping
2587-
if (last_detection_count>0) {
2588+
if (last_detection_count >0 and last_detections.size()) {
2589+
Image *ai_image = new Image(packet->in_frame.get(), packet->in_frame->width, packet->in_frame->height); //copies
2590+
ai_image->draw_boxes(last_detections, LabelSize(), LabelSize());
2591+
packet->ai_image = ai_image;
2592+
// Populate ai_frame as well
2593+
packet->ai_frame = av_frame_ptr(av_frame_alloc());
2594+
ai_image->PopulateFrame(packet->ai_frame.get());
25882595
last_detection_count --;
2589-
//TODO last_detection shouldn't be AI specific
2590-
//quadra_yolo->draw_last_roi(packet);
25912596
}
25922597
} // end if skip_frame
25932598
} // end if has input_frame/hw_frame

src/zm_mx_accl.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ bool MxAccl::setup(
8585
// Load and launch module_
8686
Debug(1, "MxAccl: Loading model %s", model_file.c_str());
8787

88-
std::vector<int> device_ids = {0};
88+
std::vector<int> device_ids = {-1};
8989
std::array<bool, 2> use_model_shape = {false, false};
9090

9191
std::string model_file_lower = model_file;
@@ -224,20 +224,16 @@ int MxAccl::send_frame(MxAccl::Job *job, AVFrame *avframe) {
224224

225225
job->m_width_rescale = ((float)input_width / (float)avframe->width);
226226
job->m_height_rescale = ((float)input_height / (float)avframe->height);
227-
Debug(1, "Locking");
228227
job->lock();
229228
{
230229
std::lock_guard<std::mutex> lck(mutex_);
231-
Debug(1, "Have Locking");
232230
send_queue.push_back(job);
233231
condition_.notify_all();
234232
}
235-
Debug(1, "Waiting for inference");
236233
job->wait();
237234
endtime = std::chrono::system_clock::now();
238235
Debug(1, "waiting took: %.3f seconds", FPSeconds(endtime - starttime).count());
239236
job->unlock();
240-
Debug(4, "Done Waiting");
241237

242238
endtime = std::chrono::system_clock::now();
243239
if (endtime - starttime > Milliseconds(60)) {
@@ -292,7 +288,7 @@ bool MxAccl::in_callback_func(vector<const MX::Types::FeatureMap *> dst, int cha
292288
Job *job = nullptr;
293289
{
294290
std::unique_lock<std::mutex> lck(mutex_);
295-
while (!send_queue.size() and ! zm_terminate) {
291+
while (!send_queue.size() and !zm_terminate) {
296292
Debug(1, "MxAccl waiting, queue size %zu", send_queue.size());
297293
condition_.wait(lck);
298294
}
@@ -316,13 +312,10 @@ bool MxAccl::in_callback_func(vector<const MX::Types::FeatureMap *> dst, int cha
316312
Debug(1, "in_callback took: %.3f seconds", FPSeconds(endtime - starttime).count());
317313
}
318314
{
319-
Debug(1, "Locking");
320315
std::lock_guard<std::mutex> lck(mutex_);
321-
Debug(1, "Pushing");
322316
receive_queue.push_back(job);
323317
}
324-
Debug(1, "Notifying");
325-
condition_.notify_one();
318+
condition_.notify_all();
326319
return true;
327320
}
328321

web/skins/classic/views/console.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@
111111
$maxWidth = 0;
112112
$maxHeight = 0;
113113
$zoneCount = 0;
114-
$total_capturing_bandwidth=0;
114+
$total_capturing_bandwidth = 0;
115+
$total_fps = 0;
116+
$total_analysis_fps = 0;
115117

116118
$status_counts = array();
117119
for ( $i = 0; $i < count($displayMonitors); $i++ ) {
@@ -430,11 +432,13 @@
430432
if ( isset($monitor['AnalysisFPS'])) {
431433
// and ($monitor['Analysing'] != 'None')) {
432434
$fps_string .= '/' . $monitor['AnalysisFPS'];
435+
$total_analysis_fps += $monitor['AnalysisFPS'];
433436
}
434437
if ($fps_string) $fps_string .= ' fps';
435438
if (!empty($monitor['CaptureBandwidth']))
436439
$fps_string .= ' ' . human_filesize($monitor['CaptureBandwidth']).'/s';
437440
$total_capturing_bandwidth += $monitor['CaptureBandwidth'];
441+
$total_fps += $monitor['CaptureFPS'];
438442
echo $fps_string;
439443
echo '</div>';
440444
} # end if offline
@@ -471,7 +475,8 @@
471475
<td class="colId"><?php echo translate('Total').":".count($displayMonitors) ?></td>
472476
<?php } ?>
473477
<td class="colName"></td>
474-
<td class="colFunction"><?php echo human_filesize($total_capturing_bandwidth ).'/s' ?></td>
478+
<td class="colFunction"><?php echo human_filesize($total_capturing_bandwidth ).'/s '.
479+
$total_fps.' fps / '.$total_analysis_fps.' fps' ?></td>
475480
<?php if ( count($Servers) ) { ?>
476481
<td class="colServer"></td>
477482
<?php } ?>

web/skins/classic/views/monitor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,7 @@ class="nav-link<?php echo ($tab == $name ? ' active' : '') . ' ' . (($name == 'z
10871087
$od_options['quadra'] = 'NetInt Quadra';
10881088
if (defined('HAVE_MEMX'))
10891089
$od_options['memx'] = 'MemryX Local MX3';
1090-
if (defined('HAVE_MEMX'))
1090+
if (defined('HAVE_MX_ACCL'))
10911091
$od_options['mx_accl'] = 'MemryX MxAccl';
10921092

10931093
echo htmlSelect('newMonitor[ObjectDetection]', $od_options, $monitor->ObjectDetection(), [ 'data-on-change-this'=>'ObjectDetection_onChange']);

0 commit comments

Comments
 (0)