Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multichannel grabber #32

Open
wants to merge 62 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
56a0128
multichannelGrabber: added dummyMultiChannelGrabber plugin
gegelle May 15, 2020
01d4c58
Merge branch 'master' into multichannelGrabber
gegelle Jul 8, 2020
6fca55a
implemented setParam for channel specific params multiChannelGrabber
gegelle Jul 8, 2020
ec1e57a
DummyMultiChannelGrabber:adapted setParam
gegelle Jul 10, 2020
49e8f6b
DummyMultiChannelGrabber: added ROI as a channel specific parameter
gegelle Jul 10, 2020
797ec91
DummyMultichannelGrabber: bugfix
gegelle Sep 23, 2020
b31fa21
Merge branch 'master' into multichannelGrabber
gegelle Sep 23, 2020
097cf29
DummyMultiChannelGrabber: started implementation of pixelFormat
gegelle Sep 24, 2020
5493022
DummyMultiChannelGrabber: further work done
gegelle Sep 30, 2020
d4d2359
DummyMultiChannelGrabber: any intermediate state
gegelle Oct 13, 2020
03398b7
DummyMultiChannelGrabber: small changes
gegelle Feb 18, 2021
1fce69e
DummyMultiChannelGrabber: implemeted getParameter which replaces getP…
gegelle Feb 19, 2021
6d3b68d
DummyMultiChannelGrabber: added a channel-specific parameter for a ch…
gegelle Feb 19, 2021
58fef3c
added DummyMultiChannelGrabber/translation/DummyMultiChannelGrabber_d…
gegelle May 10, 2021
f421d29
Merge branch 'master' into multichannelGrabber
magro11 May 10, 2021
4bbee51
capture images for all channels regardless of the defaultChannel
gegelle Jun 8, 2021
48c9b21
Merge branch 'master' into multichannelGrabber
magro11 Jun 18, 2021
7e68332
small adaptation for test purposes
gegelle Jun 21, 2021
006cb5c
DummyMultiChannelGrabber: adapted Plugin
gegelle Jun 30, 2021
33d9cfb
DummyMultiChannelGrabber: small fixes
gegelle Jul 1, 2021
4a6aa04
Merge branch 'master' into multichannelGrabber
gegelle Mar 11, 2022
c26ac85
Merge branch 'master' into multichannelGrabber
gegelle Jun 27, 2022
b93418a
DummyMultiChannelGrabber: Adjustments to the latest changes of the in…
gegelle Aug 2, 2022
5070186
Merge branch 'master' into multichannelGrabber
gegelle Aug 4, 2022
e95692d
Merge branch 'master' into multichannelGrabber
gegelle Sep 13, 2022
db5820d
first implementation of getValByMap
gegelle Oct 18, 2022
f4eb6c0
Multichannelgrabber: added a QMap based version of copyVal
gegelle Oct 25, 2022
f55252d
Merge branch 'master' into multichannelGrabber
gegelle Oct 25, 2022
fa0c419
Merge branch 'master' into multichannelGrabber
gegelle Dec 13, 2022
bf3914e
first work for a true freerun mode using the new newGrabberData signal
Jan 21, 2023
43c4a9f
DummyMultiChannelGrabber: added freerun mode
Jan 22, 2023
deba371
DummyMultiChannelGrabber: some adaptions to the new default parameter…
Jan 30, 2023
bc0fdb4
DummyMultiChannelGrabber: some further adaptions
Feb 26, 2023
8e8f229
Merge branch 'master' into multichannelGrabber
Feb 26, 2023
df64c42
DummyMultiChannelGrabber: renamed signal
Feb 28, 2023
3f85c10
Merge branch 'master' into multichannelGrabber
Jun 10, 2023
01bf11a
fix in variable names
Jun 10, 2023
4906ff6
fixed Warnung in CMakeLists.txt
photoniker Jun 10, 2023
248277a
implemented GaussianSpot, GaussianSpotArray to DummyMultiChannelGrabber
Jun 14, 2023
c2c8ef8
Merge branch 'multichannelGrabber' of https://github.com/itom-project…
Jun 14, 2023
29b55ac
data meta information for liveImage
photoniker Jun 17, 2023
1c5f248
cleaned up header
photoniker Jun 17, 2023
e8704ae
added checkData for updating m_data after setParams call
photoniker Jun 18, 2023
f12a9f9
updated DummyGrabber docu *.rst
photoniker Jun 20, 2023
f0f0aa2
added dataObject meta information to addInMultiChannelGrabber similia…
photoniker Jun 23, 2023
26317f3
fix in DummyMultiChannelGrabber due to modifications in addInMultiCha…
magro11 Jun 25, 2023
12daeb3
multigrabber refactoring
magro11 Jun 28, 2023
5885dfd
Merge branch 'master' into multichannelGrabber
magro11 Jul 1, 2023
84a0b85
updates concerning multi channel grabber, not finished yet
magro11 Jul 9, 2023
8a0b16d
some more improvements for DummyMultiChannelGrabber
magro11 Jul 19, 2023
69ca6a0
updates of dummyMultiChannelGrabber
magro11 Aug 2, 2023
9d69054
more work for multi channel grabber demo plugin
magro11 Aug 12, 2023
15e17c3
Merge branch 'master' into multichannelGrabber
photoniker Aug 21, 2023
ed69e5b
more steps for running DummyMultiChannelGrabber
magro11 Aug 25, 2023
b98213c
files renamed
magro11 Aug 25, 2023
c19cc7c
more work on DummyMultiChannelGrabber
magro11 Oct 9, 2023
a634f96
improvements in dummyMultiChannelGrabber
magro11 Oct 17, 2023
527e27f
next steps for MultiChannelGrabber
magro11 Oct 20, 2023
daec49e
Merge branch 'master' into multichannelGrabber
magro11 Nov 18, 2023
1a0fb7a
Merge branch 'master' into multichannelGrabber
photoniker Jan 14, 2024
3885f37
Merge branch 'master' into multichannelGrabber
photoniker Jan 14, 2024
df0526f
Merge branch 'master' into multichannelGrabber
photoniker Jan 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ if(PLUGIN_DummyGrabber)
add_subdirectory(DummyGrabber)
endif(PLUGIN_DummyGrabber)

# DummyMultiChannelGrabber
option(PLUGIN_DummyMultiChannelGrabber "Build with this plugin." ON)
if(PLUGIN_DummyMultiChannelGrabber)
add_subdirectory(DummyMultiChannelGrabber)
endif(PLUGIN_DummyMultiChannelGrabber)

# DummyMotor
option(PLUGIN_DummyMotor "Build with this plugin." ON)
if(PLUGIN_DummyMotor)
Expand Down
729 changes: 429 additions & 300 deletions DummyGrabber/DummyGrabber.cpp

Large diffs are not rendered by default.

24 changes: 20 additions & 4 deletions DummyGrabber/docs/dummyGrabber.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ Parameters

An instance of this plugin has the following parameters:

**axisDescription**: Sequence[str]
axis description
**axisOffset**: Sequence[float]
axis offset

*2 values required, All values allowed, Default: [0, 0]*
**axisScale**: Sequence[float]
axis scale

*2 values required, All values allowed, Default: [0.001, 0.001]*
**axisUnit**: Sequence[str]
axis unit
**binning**: int
Binning of different pixel, binning = x-factor * 100 + y-factor

Expand All @@ -54,7 +66,7 @@ An instance of this plugin has the following parameters:
**demoRegexpString**: str
matches strings without whitespaces

*RegExp: "^\S+$", Default: <empty str>*
*RegularExpression: "^\S+$", Default: <empty str>*
**demoWildcardString**: str
dummy filename of a bmp file, pattern: *.bmp

Expand Down Expand Up @@ -82,12 +94,16 @@ An instance of this plugin has the following parameters:
**roi**: Tuple[int,int,int,int] (rect [x0,y0,width,height])
ROI (x,y,width,height) [this replaces the values x0,x1,y0,y1]

*Height: Value range: [0:4:479], Default: [0, 0, 640, 480]*
*Height: Value range: [0:4:479], Default: [100, 40, 400, 300]*
**sizex**: int, read-only
size in x (cols) [px]

*Value range: [4:4:640], Default: 640*
*Value range: [4:4:640], Default: 400*
**sizey**: int, read-only
size in y (rows) [px]

*Value range: [4:4:480], Default: 480*
*Value range: [4:4:480], Default: 300*
**valueDescription**: str
camera chip counts
**valueUnit**: str
unit of counts
95 changes: 95 additions & 0 deletions DummyMultiChannelGrabber/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
cmake_minimum_required(VERSION 3.12...3.24)

set(target_name DummyMultiChannelGrabber)

option(BUILD_TARGET64 "Build for 64 bit target if set to ON or 32 bit if set to OFF." ON)
set(ITOM_SDK_DIR NOTFOUND CACHE PATH "path of SDK subfolder of itom root (build) directory")

#this is to automatically detect the SDK subfolder of the itom build directory.
find_path(ITOM_SDK_DIR "cmake/itom_sdk.cmake"
HINTS "C:/itom/build/itom/SDK"
"${CMAKE_CURRENT_BINARY_DIR}/../../itom/SDK"
DOC "path of SDK subfolder of itom root (build) directory")

if(NOT ITOM_SDK_DIR)
message(SEND_ERROR "ITOM_SDK_DIR is invalid. Provide itom SDK directory path first")
endif()

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${ITOM_SDK_DIR}/cmake)

include(ItomBuildMacros)
itom_init_cmake_policy(3.12)
itom_init_plugin_library(${target_name}) #Start the project, init compiler settings and set default configurations for plugins


find_package(ITOM_SDK COMPONENTS dataobject itomCommonLib itomCommonQtLib itomWidgets REQUIRED)
itom_find_package_qt(ON Core Widgets LinguistTools)

find_package(OpenCV COMPONENTS core REQUIRED)


include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${ITOM_SDK_INCLUDE_DIRS}
)

set(PLUGIN_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/dialogDummyMultiChannelGrabber.h
${CMAKE_CURRENT_SOURCE_DIR}/dockWidgetDummyMultiChannelGrabber.h
${CMAKE_CURRENT_SOURCE_DIR}/dummyMultiChannelGrabber.h
${CMAKE_CURRENT_SOURCE_DIR}/dummyMultiChannelGrabberInterface.h
${CMAKE_CURRENT_SOURCE_DIR}/cameraEmulator.h
${CMAKE_CURRENT_SOURCE_DIR}/pluginVersion.h
${CMAKE_CURRENT_BINARY_DIR}/gitVersion.h
)

set(PLUGIN_UI
${CMAKE_CURRENT_SOURCE_DIR}/dialogDummyMultiChannelGrabber.ui
${CMAKE_CURRENT_SOURCE_DIR}/dockWidgetDummyMultiChannelGrabber.ui
)

set(PLUGIN_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/dialogDummyMultiChannelGrabber.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dockWidgetDummyMultiChannelGrabber.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dummyMultiChannelGrabber.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dummyMultiChannelGrabberInterface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cameraEmulator.cpp
)

#Add version information to the plugIn-dll unter MSVC
if(MSVC)
list(APPEND PLUGIN_SOURCES ${ITOM_SDK_INCLUDE_DIR}/../pluginLibraryVersion.rc)
endif()

#################################################################
# Qt related pre-processing of the files above
# (These methods create the moc, rcc and uic process.)
#################################################################


add_library(${target_name} SHARED ${PLUGIN_SOURCES} ${PLUGIN_HEADERS} ${PLUGIN_UI} ${PLUGIN_RCC})

# Qt: enable all automoc, autouic and autorcc.
set_target_properties(${target_name} PROPERTIES AUTOMOC ON AUTORCC ON AUTOUIC ON)

target_link_libraries(${target_name} ${ITOM_SDK_LIBRARIES} ${QT5_LIBRARIES} ${VISUALLEAKDETECTOR_LIBRARIES} ${QT_LIBRARIES})



#translation
set(FILES_TO_TRANSLATE ${PLUGIN_SOURCES} ${PLUGIN_HEADERS} ${PLUGIN_UI})
itom_library_translation(QM_FILES TARGET ${target_name} FILES_TO_TRANSLATE ${FILES_TO_TRANSLATE})

itom_configure_plugin_documentation(${target_name} DummyMultiChannelGrabber)

# COPY SECTION
set(COPY_SOURCES "")
set(COPY_DESTINATIONS "")

itom_add_pluginlibrary_to_copy_list(${target_name} COPY_SOURCES COPY_DESTINATIONS)

itom_add_plugin_qm_files_to_copy_list(${target_name} QM_FILES COPY_SOURCES COPY_DESTINATIONS)
itom_post_build_copy_files(${target_name} COPY_SOURCES COPY_DESTINATIONS)
242 changes: 242 additions & 0 deletions DummyMultiChannelGrabber/cameraEmulator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
/* ********************************************************************
Plugin "DummyMultiChannelGrabber" for itom software
URL: http://www.uni-stuttgart.de/ito
Copyright (C) 2023, Institut fuer Technische Optik (ITO),
Universitaet Stuttgart, Germany

This file is part of a plugin for the measurement software itom.

This itom-plugin is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public Licence as published by
the Free Software Foundation; either version 2 of the Licence, or (at
your option) any later version.

itom and its plugins are distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
General Public Licence for more details.

You should have received a copy of the GNU Library General Public License
along with itom. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************** */

#include "cameraEmulator.h"

#include <qelapsedtimer.h>
#include <qthread.h>

//-------------------------------------------------------------------------------------
/** @func fastrand
* @brief function for pseudo random values
*
* This function delivers the noise for the image.
*/
template <typename _Tp> inline _Tp fastrand(cv::RNG& rng, _Tp maxval, float offset, float gain)
{
return cv::saturate_cast<_Tp>(offset * maxval + gain * (((ito::uint32)rng.next()) & maxval));
}

//-------------------------------------------------------------------------------------
/** @func fastrand
* @brief function for pseudo random values
*
* This function delivers the noise for the image.
*/
template <typename _Tp>
inline _Tp fastrand_mean(cv::RNG& rng, _Tp maxval, ito::uint8 numMeans, float offset, float gain)
{
ito::uint32 val = 0;

for (ito::uint8 i = 0; i < numMeans; ++i)
{
val += ((ito::uint32)rng.next()) & maxval;
}

return cv::saturate_cast<_Tp>(offset * maxval + (gain / (float)numMeans) * val);
}

//-------------------------------------------------------------------------------------
/** @func gaussFunc
* @brief function for 2d Gaussian function
*
* This function delivers a 2d dataObject with a Gaussian function
*/
template <typename _Tp> ito::RetVal gaussFunc(cv::RNG& rng, ito::DataObject &dObj, float amplitude)
{
int width = dObj.getSize(1);
int height = dObj.getSize(0);
_Tp* rowPtr;
float xval, yval;
int planeID = dObj.seekMat(0);

float yRandOffset = rng.uniform(0.f, 20.f);
float xRandOffset = rng.uniform(0.f, 20.f);
float aRandOfset = rng.uniform(-amplitude * 0.1, amplitude * 0.1);

float sigmaX = width * rng.uniform(0.09f, 0.11f);
float sigmaY = height * rng.uniform(0.09f, 0.11f);

for (int y = 0; y < height; y++)
{
rowPtr = dObj.rowPtr<_Tp>(planeID, y);
yval = (((float)y - height / 2 + yRandOffset) * ((float)y - height / 2 + yRandOffset)) /
(2.0f * sigmaY * sigmaY);

for (int x = 0; x < width; x++)
{
xval = (((float)x - width / 2 + xRandOffset) * ((float)x - width / 2 + xRandOffset)) /
(2.0f * sigmaX * sigmaX);
rowPtr[x] = (float)(amplitude - aRandOfset) * exp(-(xval + yval));
}
}

return ito::retOk;
}



//-------------------------------------------------------------------------------------
CameraEmulator::CameraEmulator() :
m_imageColorAlpha(false),
m_imageMonoBpp(8)
{

}

//-------------------------------------------------------------------------------------
void CameraEmulator::configureImageMono(const QRect& roi, int bpp)
{
int h = roi.height();
int w = roi.width();

switch (bpp)
{
case 8:
m_imageMonoBpp = 8;
m_imageMono = ito::DataObject(h, w, ito::tUInt8);
break;
case 10:
m_imageMonoBpp = 10;
m_imageMono = ito::DataObject(h, w, ito::tUInt16);
break;
case 12:
m_imageMonoBpp = 12;
m_imageMono = ito::DataObject(h, w, ito::tUInt16);
break;
case 16:
m_imageMonoBpp = 16;
m_imageMono = ito::DataObject(h, w, ito::tUInt16);
default:
break;
}
}

//-------------------------------------------------------------------------------------
void CameraEmulator::configureImageTopography(const QRect& roi, bool singlePrecision)
{
int h = roi.height();
int w = roi.width();

if (singlePrecision)
{
m_imageTopography = ito::DataObject(h, w, ito::tFloat32);
}
else
{
m_imageTopography = ito::DataObject(h, w, ito::tFloat64);
}
}

//-------------------------------------------------------------------------------------
void CameraEmulator::configureImageColor(const QRect& roi, bool alpha)
{
int h = roi.height();
int w = roi.width();
m_imageColorAlpha = alpha;

m_imageColor = ito::DataObject(h, w, ito::tRGBA32);
}

//-------------------------------------------------------------------------------------
bool CameraEmulator::grabImages(bool imgMono, bool imgFloat, bool imgColor, float exposureTimeMs)
{
bool result = true;
QElapsedTimer timer;
timer.start();

if (imgMono)
{
result &= grabMono();
}

if (imgFloat)
{
result &= grabTopography();
}

if (imgColor)
{
result &= grabColor();
}

exposureTimeMs -= timer.elapsed();

if (exposureTimeMs > 0)
{
QThread::usleep(1000 * exposureTimeMs);
}

return result;
}

//-------------------------------------------------------------------------------------
bool CameraEmulator::grabMono()
{
const unsigned int low = 0;
const unsigned int high = std::pow(m_imageMonoBpp, 2) - 1;

cv::randu(*(m_imageMono.getCvPlaneMat(0)), low, high);

return true;
}

//-------------------------------------------------------------------------------------
bool CameraEmulator::grabTopography()
{
cv::RNG& rng = cv::theRNG();

if (m_imageTopography.getType() == ito::tFloat32)
{
gaussFunc<ito::float32>(rng, m_imageTopography, 10.0);
}
else
{
gaussFunc<ito::float64>(rng, m_imageTopography, 10.0);
}

return true;
}

//-------------------------------------------------------------------------------------
bool CameraEmulator::grabColor()
{
cv::Mat* mat = m_imageColor.getCvPlaneMat(0);
ito::uint32* rowPtr;

for (int r = 0; r < mat->rows; ++r)
{
rowPtr = mat->ptr<ito::uint32>(r);

for (int c = 0; c < mat->cols; ++c)
{
rowPtr[c] = cv::randu<ito::uint32>();

if (!m_imageColorAlpha)
{
((ito::Rgba32*)rowPtr)[c].a = 255;
}
}
}

return true;
}
Loading