Mech-Eye API 2.5.0
API reference documentation for Mech-Eye Industrial 3D Camera
All Classes Functions Variables Typedefs Enumerations Enumerator Pages
CameraEvent.h
1/*******************************************************************************
2 * BSD 3-Clause License
3 *
4 * Copyright (c) 2016-2025, Mech-Mind Robotics
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright notice, this
11 * list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 *
17 * 3. Neither the name of the copyright holder nor the names of its
18 * contributors may be used to endorse or promote products derived from
19 * this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * Info: https://www.mech-mind.com/
33 *
34 ******************************************************************************/
35
36#pragma once
37#include <functional>
38#include "Camera.h"
39
40namespace mmind {
41
42namespace eye {
47{
48 int eventId{0};
49 std::string eventName{};
50 int64_t timestamp{0};
51 int64_t frameId{0};
52};
53
60class MMIND_API_EXPORT CameraEvent
61{
62public:
68 enum Event {
69 CAMERA_EVENT_NONE = 0x0000,
70 CAMERA_EVENT_DISCONNECTED = 0x0001,
71 CAMERA_EVENT_EXPOSURE_END =
72 0x900e,
83 CAMERA_EVENT_ALL = 0xFFFF,
84 };
85
86 using EventCallback = std::function<void(Event event, void* pUser)>;
87
104 [[deprecated(
105 "Please use the following method instead: @ref "
106 "registerCameraEventCallback(Camera& camera, Event event, const "
107 "CameraEventCallback& callback).")]] static ErrorStatus
108 registerCameraEventCallback(Camera& camera, EventCallback callback, void* pUser,
109 unsigned int events);
110
117 std::function<void(const EventData* eventData, const void* extraPayload)>;
118
141 [[deprecated(
142 "Please use the following method instead: @ref "
143 "registerCameraEventCallback(Camera& camera, uint16_t event, const "
144 "CameraEventCallback& callback).")]] static ErrorStatus
146
166 [[deprecated(
167 "Please use the following method instead: @ref "
168 "unregisterCameraEventCallback(Camera& camera, uint16_t event).")]] static ErrorStatus
170
175 {
176 std::string eventName{};
177 uint16_t eventId{0x0000};
178
179 EventInfo() = default;
180 EventInfo(const std::string& eventName, uint16_t eventId)
181 : eventName(eventName), eventId(eventId)
182 {
183 }
184 };
185
196 static ErrorStatus getSupportedEvents(const Camera& camera, std::vector<EventInfo>& eventInfos);
197
202 {
203 std::string name;
204 enum class Type {
205 _UInt32,
206 _Int32,
207 _Int64,
208 _Float,
209 _Double,
210 _Bool,
211 _String,
212 };
213 Type type;
215 {
216 uint32_t uint32Value;
217 int32_t int32Value;
218 int64_t int64Value;
219 float floatValue;
220 double doubleValue;
221 bool boolValue;
222 std::string stringValue;
223 };
225 };
226
227 using Payload = std::vector<PayloadMember>;
228
249 static ErrorStatus registerCameraEventCallback(Camera& camera, uint16_t event,
250 const CameraEventCallback& callback);
251
269 static ErrorStatus unregisterCameraEventCallback(Camera& camera, uint16_t event);
270};
271
272} // namespace eye
273
274} // namespace mmind
The camera event related. Use CameraEvent::getSupportedEvents to get supported events....
Definition CameraEvent.h:61
static ErrorStatus registerCameraEventCallback(Camera &camera, uint16_t event, const CameraEventCallback &callback)
Registers a callback function to be executed when the specified Event occurs on the specified Camera ...
std::function< void(const EventData *eventData, const void *extraPayload)> CameraEventCallback
callback function for a camera event.
static ErrorStatus unregisterCameraEventCallback(Camera &camera, uint16_t event)
Cancels the registration of a callback function for the specified event and Camera object.
static ErrorStatus unregisterCameraEventCallback(Camera &camera, Event event)
Cancels the registration of a callback function for the specified event and Camera object.
static ErrorStatus getSupportedEvents(const Camera &camera, std::vector< EventInfo > &eventInfos)
Get supported events by the camera.
static ErrorStatus registerCameraEventCallback(Camera &camera, Event event, const CameraEventCallback &callback)
Registers a callback function to be executed when the specified Event occurs on the specified Camera ...
Event
The defined camera event.
Definition CameraEvent.h:68
static ErrorStatus registerCameraEventCallback(Camera &camera, EventCallback callback, void *pUser, unsigned int events)
Registers a camera event of interest.
Operates the camera. Use Camera::connect to connect an available camera, and then call the correspond...
Definition Camera.h:55
Describes the event information.
Describes the data member of the event's payload.
Describes the types of errors.
Definition ErrorStatus.h:12
Represents data associated with a camera event.
Definition CameraEvent.h:47
std::string eventName
Event name, supported by Cameras with firmware version >= 2.5.0.
Definition CameraEvent.h:49
int eventId
Event ID, defined in CameraEvent::Event.
Definition CameraEvent.h:48
int64_t frameId
The ID of the image frame where the event occurred.
Definition CameraEvent.h:51
int64_t timestamp
The timestamp of the event occurrence.
Definition CameraEvent.h:50