Skip to content

Commit

Permalink
Added Multi Camera Grabbing with Threads issue #10
Browse files Browse the repository at this point in the history
  • Loading branch information
inbangsa committed Aug 6, 2020
1 parent 9df25c5 commit c2da04f
Show file tree
Hide file tree
Showing 7 changed files with 396 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ option(BUILD_EXAMPLE_MULTI_CAMERA_GRABBER "Build multi-camera-grabber example" O
option(BUILD_EXAMPLE_PCICCLIENT_ASYNC_MESSAGES "Build pcicclient-async-messages example" ON)
option(BUILD_EXAMPLE_PCICCLIENT_SET_IO "Build pcicclient-set-io example" ON)
option(BUILD_EXAMPLE_TIMESTAMP "Build timestamp example" ON)
option(BUILD_EXAMPLE_MULTI_CAMERA_PARALLEL_GRABBER "Build multi-camera-parallel-grabber example" ON)

################################################
## Bring in dependent projects
Expand Down Expand Up @@ -68,6 +69,11 @@ if(TARGET ifm3d::image)
if(BUILD_EXAMPLE_TIMESTAMP)
add_subdirectory(timestamp)
endif()

if(BUILD_EXAMPLE_MULTI_CAMERA_PARALLEL_GRABBER)
add_subdirectory(multi_camera_parallel_grabber)
endif()

endif()

if(TARGET ifm3d::pcicclient)
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

ifm3d Examples
==============
This project is formerly the `examples` sub-module of the
Expand Down Expand Up @@ -75,8 +74,11 @@ What is included?
on the O3D camera by the PCIC interface.
* [ex-simpleImage_ppm_io](simpleimage/example/ex-simpleImage_ppm_io.cpp) Shows how to write your own
image container which does not depend on PCL nor OpenCV.
* [ex-multi_camera_grabber](multi_camera_grabber/ex-multi_camera_grabber.cpp) demonstrate's how to accquire frames from multiple ifm 3D camera's,
* [ex-multi_camera_grabber](multi_camera_grabber/ex-multi_camera_grabber.cpp) demonstrate's how to accquire frames from multiple ifm 3D camera's,
see the example [documentation](doc/ex-multi_camera_grabber.md) for more details.
* [ex-multi_camera_parallel_grabber](multi_camera_parallel_grabber/ex-multi_camera_parallel_grabber.cpp)
demonstrate how to accquire frames concurrently (using multithreading) from multiple ifm 3D cameras,
see the example [documentation](multi_camera_parallel_grabber/README.md) for more details.

LICENSE
-------
Expand Down
35 changes: 35 additions & 0 deletions multi_camera_parallel_grabber/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.5)

project(ex-multi_camera_parallel_grabber CXX)

# Global compiler flags
set(CMAKE_BUILD_TYPE Release) # Release or Debug
set(CMAKE_CXX_EXTENSIONS OFF) # OFF -> -std=c++14, ON -> -std=gnu++14
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED true)

if(FORCE_OPENCV3)
find_package(OpenCV 3 REQUIRED)
elseif(FORCE_OPENCV2)
find_package(OpenCV 2.4 REQUIRED)
else()
find_package(OpenCV REQUIRED)
endif()

##############################################################
## finding the ifm3d lib.
##############################################################
find_package(ifm3d 0.11.0 CONFIG
REQUIRED COMPONENTS camera framegrabber image
)

find_package(Threads)

add_executable(ex-multi_camera_parallel_grabber ex-multi_camera_parallel_grabber.cpp)
target_link_libraries(ex-multi_camera_parallel_grabber
ifm3d::camera
ifm3d::framegrabber
ifm3d::image
${CMAKE_THREAD_LIBS_INIT}
${OpenCV_LIBRARIES}
)
98 changes: 98 additions & 0 deletions multi_camera_parallel_grabber/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
ifm3d Multiple camera parallel grabber
=======================================

This document explains the setup that is needed to use this code.
The setup is consist of multiple ifm o3d cameras out of which one is in
software trigger mode and others are configured as hardware trigger mode (Positive,Negative,Positive and Negative).
This example triggers the device in software trigger mode whose IP Address must be at 0th location of the ```camera_ips``` array.
After the CAMERA0 (0 index camera) finished the Image capture it further sends the hardware trigger to the one of the device
e.g.CAMERA1 (device at index 1 in ```camera_ips```array).When CAMERA1 device finishes its capture it further trigger CAMERA2
and this way all the devices are triggered.

Setup and pin connection
------------------------

Following Images shows the setup and pin connection:

![](setup.png)

<p align="justify">
Figure 1. Setup of the camera
</p>

Above figure explains the setup of the O3D cameras required for this example.
Trigger mode in CAMERA0 is configured as a software trigger mode. Rest all other cameras are
congfigured as hardware trigger(positive edge). When the CAMERA0 finishes the Image captured it generates the soft signal Image capture finished
which through Logic layer is connected to the OUT2 pin (Gray Wire). This configuration of Logic layer on device device is
explained in section [logic Layer in O3D3xx](#Logic-Layer-in-O3D3xx). OUT2 pin of CAMERA0 is further connected to the hardware
trigger pin (white wire) of CAMERA1 as shown in above figure 1. and when CAMERA1 finishes the capture it sends the output signal to its OUT2 pin which is further
connects to CAMERA3 hardware trigger pin. This way if CAMERA0 is triggered from user application it will
trigger all other camera one after the other.

Note: Pin connection and color are explained with respect to the [ifm product](https://www.ifm.com/ch/en/product/EVC073)

#### Setting unique ip address to your ifm3d camera
This is explained in detail at [this document](https://github.com/ifm/ifm3d-examples/blob/master/doc/ex-multi_camera_grabber.md#setting-unique-ip-address-to-your-ifm-3d-camera)

#### Logic Layer in O3D3xx
The Logic Layer represents a graphical view on the digital output PIN combination of the O3D3xx device. This setup as explained above, connects the Image captured finish to
OUT2 pin, TO do this we need to configure the logic graph on the device. user can do this through iVA( ifm Vision Assistant software) or can use the JSON as shown in example code.
Following is the screenshot of the iVA which explains the how to connect the Image capture finish signal to the OUT2 PIN. IO Configuration Tab shows all
the PIN events and outputs available with O3D3xx device.

![](logic_graph.png)

<p align="justify">
Figure 2. Logic Layer in O3D3xx
</p>

##### JSON for the above logical layer
Following JSON is used in code [Line 52](ex-multi_camera_parallel_grabber.cpp#L52) will configure the logic graph shown in Figure 2 on the device.
The graph is consist of block and connectors.
```json
"{
"IOMap ": {
"OUT1 ": "RFT ",
"OUT2 ": "AQUFIN "
},
"blocks ": {
"B00001 ": {
"pos ": { "x ": 200, "y ": 200},
"properties ": {},
"type ": "PIN_EVENT_IMAGE_ACQUISITION_FINISHED "
},
"B00002 ": {
"pos ": { "x ": 200, "y ": 75},
"properties ": {},
"type ": "PIN_EVENT_READY_FOR_TRIGGER "
},
"B00003 ": {
"pos ": { "x ": 600, "y ": 75},
"properties ": { "pulse_duration ": 0},
"type ": "DIGITAL_OUT1 "
},
"B00005 ": {
"pos ": { "x ": 600, "y ": 200},
"properties ": { "pulse_duration ": 0},
"type ": "DIGITAL_OUT2 "
}
},
"connectors ":
{
"C00000 ": {
"dst ": "B00003 ",
"dstEP ": 0,
"src ": "B00002 ",
"srcEP ": 0
},
"C00001 ": {
"dst ": "B00005 ",
"dstEP ": 0,
"src ": "B00001 ",
"srcEP ": 0
}
}
}"
```
Note : Ready for Trigger is not use in example code but it is always good to use this to get the feedback on Device LED when the device is ready for trigger.

Loading

0 comments on commit c2da04f

Please sign in to comment.