Browse Source

Merge pull request 'Map ROI: kernel command from a click on the monitoring map' (#29) from feature/map-roi into master

master
ClaudeAI 41 minutes ago
parent
commit
f598b06324
  1. 1
      lib/App/common/dataBinder_structures.h
  2. 13
      lib/App/common/deviceNodePTZCamControl.cpp
  3. 20
      lib/App/common/deviceNodePresetCamControl.cpp
  4. 20
      lib/App/common/deviceNodeStaticCamControl.cpp
  5. 99
      lib/App/mojo/mojoKernel.cpp
  6. 2
      lib/App/mojo/mojoKernel.h
  7. 17
      lib/components/object/objectSystemAnchor.cpp
  8. 1
      lib/components/object/objectSystemAnchor.h

1
lib/App/common/dataBinder_structures.h

@ -405,6 +405,7 @@ typedef struct S_DBC_RESOURCE_DATA
#define CMD_KRN_COMPOSE_SESSION_VIDEOS 239 #define CMD_KRN_COMPOSE_SESSION_VIDEOS 239
#define CMD_KRNL_DELNODE 240 #define CMD_KRNL_DELNODE 240
#define CMD_KRNL_RELOAD_MEDIAMTX_SERVICE 241 #define CMD_KRNL_RELOAD_MEDIAMTX_SERVICE 241
#define CMD_KRNL_MAP_ROI 242 // monitoring map click: "<format>;<lat|y>;<lon|x>" (0 WGS84, 1 local)
#define CMD_KRNL_RESET_SITE 245 #define CMD_KRNL_RESET_SITE 245
#define CMD_KRNL_PURGE_SESSION 246 #define CMD_KRNL_PURGE_SESSION 246
#define CMD_KRNL_SET_SESSION_HZL 247 #define CMD_KRNL_SET_SESSION_HZL 247

13
lib/App/common/deviceNodePTZCamControl.cpp

@ -59,7 +59,18 @@ bool deviceNodePTZCamControl::dispatchEvent(EVENT_CONTAINER * E)
case EVT_ROI_ACTIVE:{ case EVT_ROI_ACTIVE:{
if ( !m_bCameraAIControled ) { if ( !m_bCameraAIControled ) {
TARGET_DATA *tDATA = (TARGET_DATA *)E->m_pEvtData; TARGET_DATA *tDATA = (TARGET_DATA *)E->m_pEvtData;
if( tDATA ) lookAt(E->m_db_id, tDATA->system_target);
if( tDATA ){
if( E->m_eClass == EVT_CLASS_SYSTEM ){
// Map ROI (kernel): no preferred camera
if( 1 ){ // ToDo: camera setting - only when the point passes the camera's test (range, pan limits, FOV)
if( testFOV( tDATA->system_target ) ) lookAt(E->m_db_id, tDATA->system_target);
} else { // every camera turns to it (lookAt clamps pan/tilt/zoom to the camera's limits)
lookAt(E->m_db_id, tDATA->system_target);
};
} else {
lookAt(E->m_db_id, tDATA->system_target);
};
};
} }
break; break;
}; };

20
lib/App/common/deviceNodePresetCamControl.cpp

@ -58,6 +58,26 @@ bool deviceNodePresetCamControl::dispatchEvent(EVENT_CONTAINER * E)
}; };
switch (E->m_eClass) switch (E->m_eClass)
{ {
case EVT_CLASS_SYSTEM:
{
// Map ROI (kernel): no preferred camera
TARGET_DATA * tDATA = (TARGET_DATA *) E->m_pEvtData;
if (E->m_eType == EVT_ROI_ACTIVE && tDATA != NULL)
{
if (1) // ToDo: camera setting - only when the point passes the camera's test (range, pan limits, FOV)
{
if (testFOV(tDATA->system_target))
{
lookAt(E->m_db_id, tDATA->system_target);
};
}
else // every camera acts on it
{
lookAt(E->m_db_id, tDATA->system_target);
};
};
break;
};
case EVT_CLASS_SENSOR_CLD: case EVT_CLASS_SENSOR_CLD:
case EVT_CLASS_SENSOR_LGS: case EVT_CLASS_SENSOR_LGS:
case EVT_CLASS_SENSOR_LFS: case EVT_CLASS_SENSOR_LFS:

20
lib/App/common/deviceNodeStaticCamControl.cpp

@ -90,6 +90,26 @@ bool deviceNodeStaticCamControl::dispatchEvent(EVENT_CONTAINER * E)
}; };
switch (E->m_eClass) switch (E->m_eClass)
{ {
case EVT_CLASS_SYSTEM:
{
// Map ROI (kernel): no preferred camera
TARGET_DATA * tDATA = (TARGET_DATA *) E->m_pEvtData;
if (E->m_eType == EVT_ROI_ACTIVE && tDATA != NULL)
{
if (1) // ToDo: camera setting - only when the point passes the camera's test (range, pan limits, FOV)
{
if (testFOV(tDATA->system_target))
{
makeSnap(E->m_db_id);
};
}
else // every camera acts on it
{
makeSnap(E->m_db_id);
};
};
break;
};
case EVT_CLASS_SENSOR_CLD: case EVT_CLASS_SENSOR_CLD:
case EVT_CLASS_SENSOR_LGS: case EVT_CLASS_SENSOR_LGS:
case EVT_CLASS_SENSOR_LFS: case EVT_CLASS_SENSOR_LFS:

99
lib/App/mojo/mojoKernel.cpp

@ -13,6 +13,7 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// //
#include <cmath>
#include "mojoKernel.h" #include "mojoKernel.h"
static int getLocalReportPeriod(void); static int getLocalReportPeriod(void);
@ -972,6 +973,10 @@ void mojoKernel::m_fThreadProc(void){
case CMD_KRNL_SYSTEM_TASK:{ case CMD_KRNL_SYSTEM_TASK:{
break; break;
}; };
case CMD_KRNL_MAP_ROI:{
mapROI(tCMD->PARAM);
break;
};
case NODE_FORCE_FINISH_ALARM:{ case NODE_FORCE_FINISH_ALARM:{
stopSession(); stopSession();
break; break;
@ -1267,6 +1272,79 @@ void mojoKernel::validateFilters()
}; };
} }
/*
CMD_KRNL_MAP_ROI: a click on the monitoring map (Mojo_Web doApplicationOperation 15).
PARAM "<format>;<a>;<b>":
- format 0: WGS84, a = lat, b = lon (degrees) -> system coordinates through the site anchor (UTM, meters);
- format 1: local binding (bitmap map), a = y, b = x in map units: the map shows a node at
anchor + its local coordinates, so system = map - anchor.
The point is sent as EVT_ROI_ACTIVE (EVT_CLASS_SYSTEM) like a sensor's ROI: it is an event of the
report (dispatchEvent) and every camera that can see it (testFOV) looks at it.
*/
bool mojoKernel::mapROI(const char * param)
{
char tB[256];
int tFormat = -1;
double tA = 0, tC = 0;
if (param == NULL || sscanf(param, "%d;%lf;%lf", &tFormat, &tA, &tC) != 3 || (tFormat != 0 && tFormat != 1) || ! std::isfinite(tA) || ! std::isfinite(tC))
{
snprintf(tB, sizeof(tB), "Map ROI: wrong parameter [%.64s]", param ? param : "");
LOG_ERROR(tB);
return false;
};
if (m_pSystemAnchor == NULL)
{
LOG_ERROR("Map ROI: no system anchor!");
return false;
};
bool tLocal = (tFormat == 1);
if (tLocal != m_pSystemAnchor->beLocal())
{
// the map type was changed after the start: the anchor still uses the other system
snprintf(tB, sizeof(tB), "Map ROI: the map is %s, the site anchor is %s - ignored (restart needed)", tLocal ? "local" : "WGS84", m_pSystemAnchor->beLocal() ? "local" : "WGS84");
LOG_ERROR(tB);
return false;
};
TARGET_DATA * tData = (TARGET_DATA *) malloc(sizeof(TARGET_DATA)); // freed with the event
if (tData == NULL)
{
return false;
};
memset(tData, 0, sizeof(TARGET_DATA));
tData->source_position.lat = m_pSystemAnchor->getLat();
tData->source_position.lon = m_pSystemAnchor->getLon();
tData->source_position.alt = m_pSystemAnchor->getAlt();
if (tLocal)
{
tData->system_target.x = (C3D_FLOAT) (tC - m_pSystemAnchor->getX());
tData->system_target.y = (C3D_FLOAT) (tA - m_pSystemAnchor->getY());
tData->system_target.z = 0;
// as the sensors do in a local system
tData->global_target.lat = tData->system_target.y;
tData->global_target.lon = tData->system_target.x;
tData->global_target.alt = tData->system_target.z;
}
else
{
tData->global_target.lat = (C3D_FLOAT) tA;
tData->global_target.lon = (C3D_FLOAT) tC;
tData->global_target.alt = m_pSystemAnchor->getZ(); // no height on the map: the site's ground level
m_pSystemAnchor->convertToSystem(tData->global_target, tData->system_target);
};
snprintf(tB, sizeof(tB), "Map ROI: %s %.7f %.7f -> system x:%.2f y:%.2f z:%.2f", tLocal ? "local" : "WGS84", tA, tC, tData->system_target.x, tData->system_target.y, tData->system_target.z);
LOG(tB);
startSession();
EVENT_CONTAINER * bEVT = createBasicEvent(m_nServerNodeID, EVT_CLASS_SYSTEM, EVT_ROI_ACTIVE, NULL, NULL, tData);
if (bEVT == NULL)
{
LOG_ERROR("Map ROI: event creation failure!");
free(tData);
return false;
};
m_pEventHeap->broadcast(bEVT);
return true;
}
bool mojoKernel::dispatchEvent(EVENT_CONTAINER * Evt) bool mojoKernel::dispatchEvent(EVENT_CONTAINER * Evt)
{ {
if (Evt == NULL) if (Evt == NULL)
@ -1308,6 +1386,27 @@ bool mojoKernel::dispatchEvent(EVENT_CONTAINER * Evt)
case EVT_CLASS_SYSTEM: case EVT_CLASS_SYSTEM:
switch (Evt->m_eType) switch (Evt->m_eType)
{ {
case EVT_ROI_ACTIVE:
{
// Map ROI (mapROI): an event of the report like a sensor's ROI, the cameras look at the point
preserveSession();
TARGET_DATA * tDATA = (TARGET_DATA *) Evt->m_pEvtData;
if (tDATA != NULL)
{
DBC_EVT_RECORD tRecord;
memset(&tRecord, 0, sizeof(DBC_EVT_RECORD));
tRecord.node_id = Evt->m_nSourceNodeID;
tRecord.type = Evt->m_eType;
strncpy(tRecord.uuid, Evt->m_UUID, 64);
tRecord.ts_s = Evt->m_UMSTS / 1000;
tRecord.ts_ms = Evt->m_UMSTS % 1000;
tRecord.lat = tDATA->global_target.lat;
tRecord.lon = tDATA->global_target.lon;
tRecord.alt = tDATA->global_target.alt;
Evt->m_db_id = m_pDBC->addEvent(&tRecord);
};
break;
};
case EVT_LRF_START_SESSION: case EVT_LRF_START_SESSION:
case EVT_LRF_END_SESSION_TO: case EVT_LRF_END_SESSION_TO:
case EVT_LRF_END_SESSION_MA: case EVT_LRF_END_SESSION_MA:

2
lib/App/mojo/mojoKernel.h

@ -119,6 +119,8 @@ class mojoKernel : public kernelPrototype
void stopSession(bool forced = true); void stopSession(bool forced = true);
bool mapROI(const char * param); // CMD_KRNL_MAP_ROI
void preserveSession() void preserveSession()
{ {
m_bSessionMustPreserve = true; m_bSessionMustPreserve = true;

17
lib/components/object/objectSystemAnchor.cpp

@ -350,7 +350,22 @@ bool systemAnchor::convertToSystem(basicPosition * SP, C3D_WGS84_LOC POS, C3D_DE
tDec.z = POS.alt; tDec.z = POS.alt;
m_SCC.LatLonToUTMXY(POS.lat, POS.lon, SP->getUTMZone(), tDec.x, tDec.y); m_SCC.LatLonToUTMXY(POS.lat, POS.lon, SP->getUTMZone(), tDec.x, tDec.y);
LOC.x = tDec.x - getX(); LOC.x = tDec.x - getX();
LOC.y = tDec.y - getX();
LOC.y = tDec.y - getY();
LOC.z = tDec.z - getZ();
return true;
}
bool systemAnchor::convertToSystem(C3D_WGS84_LOC POS, C3D_DECART & LOC)
{
if (m_bUseJustLocalDiffCoords)
{
return false; // no geographic position in a local system
}
C3D_DECART tDec;
tDec.z = POS.alt;
m_SCC.LatLonToUTMXY(POS.lat, POS.lon, utmZone, tDec.x, tDec.y);
LOC.x = tDec.x - getX();
LOC.y = tDec.y - getY();
LOC.z = tDec.z - getZ(); LOC.z = tDec.z - getZ();
return true; return true;
} }

1
lib/components/object/objectSystemAnchor.h

@ -39,6 +39,7 @@ class systemAnchor : public position3D
bool convertToSystem(basicPosition * SP, C3D_WGS84_LOC POS, C3D_DECART & LOC); bool convertToSystem(basicPosition * SP, C3D_WGS84_LOC POS, C3D_DECART & LOC);
bool convertToSystem(basicPosition * SP, C3D_SPH_DEGREES POS, C3D_DECART & LOC); bool convertToSystem(basicPosition * SP, C3D_SPH_DEGREES POS, C3D_DECART & LOC);
bool convertToSystem(basicPosition * SP, C3D_SPH_RADIANS POS, C3D_DECART & LOC); bool convertToSystem(basicPosition * SP, C3D_SPH_RADIANS POS, C3D_DECART & LOC);
bool convertToSystem(C3D_WGS84_LOC POS, C3D_DECART & LOC); // in the anchor's own UTM zone (no source node)
bool convertToGlobal(basicPosition * SP, C3D_SPH_DEGREES POS, C3D_WGS84_LOC & LOC); bool convertToGlobal(basicPosition * SP, C3D_SPH_DEGREES POS, C3D_WGS84_LOC & LOC);
bool convertToGlobal(basicPosition * SP, C3D_SPH_RADIANS POS, C3D_WGS84_LOC & LOC); bool convertToGlobal(basicPosition * SP, C3D_SPH_RADIANS POS, C3D_WGS84_LOC & LOC);

Loading…
Cancel
Save