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

reload app while importing when temporal filter is set #326

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-16.04, ubuntu-18.04, ubuntu-20.04]
os: [ubuntu-18.04, ubuntu-20.04]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
git clone --branch 1.33.14-cmake https://github.com/ifm/xmlrpc-c.git
mkdir xmlrpc-c\build
cd xmlrpc-c\build
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=c:\deps\install ..
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=c:\deps\install -DBUILD_SHARED_LIBS=ON ..
cmake --build . --clean-first --config Release --target INSTALL

- name: Build dependency - glog
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows_vs2019.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
git clone --branch 1.33.14-cmake https://github.com/ifm/xmlrpc-c.git
mkdir xmlrpc-c\build
cd xmlrpc-c\build
cmake -G "Visual Studio 16 2019" -Ax64 -DCMAKE_INSTALL_PREFIX=c:\deps2019\install ..
cmake -G "Visual Studio 16 2019" -Ax64 -DCMAKE_INSTALL_PREFIX=c:\deps2019\install -DBUILD_SHARED_LIBS=ON ..
cmake --build . --clean-first --config Release --target INSTALL

- name: Build dependency - glog
Expand Down
10 changes: 10 additions & 0 deletions modules/camera/include/ifm3d/camera/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,16 @@ namespace ifm3d
*/
std::string device_type_;

/**
* Return json of an app with given index from camera configuration json.
*
* @param[in] index Index of application to return
* @param[in] j The current configuration
* @param[out] app Output json of the application when found or empty json
* @return True when application was found
*/
static bool getAppJSON(int index, const json& j, json& app);

/**
* Handles parsing a selected sub-tree of a potential input JSON file,
* setting the parameters as appropriate on the camera, and saving them
Expand Down
50 changes: 38 additions & 12 deletions modules/camera/src/libifm3d_camera/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,28 @@ ifm3d::Camera::FromJSON_(
}
}

bool
ifm3d::Camera::getAppJSON(int index, const json& j, json& app) /*static*/
{
bool app_found = false;
app = json({});

json curr_apps = j["ifm3d"]["Apps"];

// Just find application with current index
for (auto& a : curr_apps)
{
if (std::stoi(a["Index"].get<std::string>()) == index)
{
app = a;
app_found = true;
break;
}
}

return (app_found);
}

void
ifm3d::Camera::FromJSON(const json& j)
{
Expand Down Expand Up @@ -919,17 +941,7 @@ ifm3d::Camera::FromJSON(const json& j)
// now in `current` (which is a whole camera dump)
// we need to find the application at index `idx`.
json curr_app = json({});
json curr_apps = current["ifm3d"]["Apps"];
bool app_found = false;
for (auto& a : curr_apps)
{
if (std::stoi(a["Index"].get<std::string>()) == idx)
{
curr_app = a;
app_found = true;
break;
}
}
bool app_found = getAppJSON(idx, current, curr_app);

if (!app_found)
{
Expand Down Expand Up @@ -972,6 +984,14 @@ ifm3d::Camera::FromJSON(const json& j)
j_im.erase("TemporalFilter");
}

// When the TemporalFilterType is set for example, there are
// additional parameters. They do not exist in the basic
// application. When trying to import them, ifm3d will fail. In
// case an temporal filter is set, we have to reload the
// application.
bool reloadApp =
(std::stoi(j_im["TemporalFilterType"].get<std::string>()) != 0);

this->FromJSON_(
curr_app["Imager"],
j_im,
Expand All @@ -985,10 +1005,16 @@ ifm3d::Camera::FromJSON(const json& j)
this->pImpl->SetImagerParameter(k, v);
}
},
[this]() { this->pImpl->SaveApp(); },
[this, j_im]() { this->pImpl->SaveApp(); },
"Imager",
idx);

if (reloadApp)
{
current = this->ToJSON_(false);
app_found = getAppJSON(idx, current, curr_app);
}

if (!this->IsO3X())
{

Expand Down