Projects
domecam:swift
domecam
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 26
View file
domecam.changes
Changed
@@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Wed Oct 19 09:52:03 UTC 2022 - Matwey V. Kornilov <matwey@sai.msu.ru> + +- Version 0.1.11 + +------------------------------------------------------------------- Sun Oct 9 14:51:12 UTC 2022 - Matwey V. Kornilov <matwey@sai.msu.ru> - Version 0.1.10
View file
domecam.spec
Changed
@@ -64,7 +64,7 @@ %sysusers_generate_pre %{SOURCE1} domecamd domecamd-user.conf %cmake -%make_jobs +%cmake_build %install %cmake_install
View file
_service
Changed
@@ -3,7 +3,7 @@ <param name="url">http://curl.sai.msu.ru/hg/home/matwey/domecam/</param> <param name="scm">hg</param> <param name="versionformat">{latesttag}</param> - <param name="revision">0.1.10</param> + <param name="revision">0.1.11</param> </service> <service name="tar" mode="buildtime" /> <service name="recompress" mode="buildtime">
View file
domecam-0.1.10.obscpio/.hgtags -> domecam-0.1.11.obscpio/.hgtags
Changed
@@ -8,3 +8,4 @@ 41a20f4ebd5e57689dc34e2b7f56e18609dadf14 0.1.7 efa87880dd80510c7274207a1df55793364749f3 0.1.8 5bde06ef6c04b0a814e8bf9455fcccbda5b90cc8 0.1.9 +8e899284f1aef2a9916b0b0c75e182256db68365 0.1.10
View file
domecam-0.1.10.obscpio/CMakeLists.txt -> domecam-0.1.11.obscpio/CMakeLists.txt
Changed
@@ -1,5 +1,5 @@ cmake_minimum_required (VERSION 3.5) -project(domecam LANGUAGES C CXX VERSION 0.1.10) +project(domecam LANGUAGES C CXX VERSION 0.1.11) set(CMAKE_CXX_STANDARD 17)
View file
domecam-0.1.10.obscpio/include/executor/mean_pupil_mask.h -> domecam-0.1.11.obscpio/include/executor/mean_pupil_mask.h
Changed
@@ -20,6 +20,7 @@ protected pipeline_mixin { public: struct runner_result; + class runner_base; protected: template<class SourceMixin> class runner; public: @@ -34,13 +35,24 @@ std::array<value_type, 2> center_mean; value_type radius_mean; + + std::array<size_t, 2> hint_offset; + std::array<size_t, 2> hint_size; }; void tag_invoke(boost::json::value_from_tag, boost::json::value&, const mean_pupil_mask_executor_base::runner_result&); std::ostream& operator<<(std::ostream& stm, const mean_pupil_mask_executor_base::runner_result& s); +class mean_pupil_mask_executor_base::runner_base { +private: + static std::pair<std::size_t, std::size_t> bounding_range_hint(float center, float radius, std::size_t size_limit); +public: + static std::pair<std::array<std::size_t, 2>, std::array<std::size_t, 2>> bounding_box_hint(const std::array<float, 2>& center, float radius, std::size_t width, std::size_t height); +}; + template<class SourceMixin> class mean_pupil_mask_executor_base::runner: + protected runner_base, public SourceMixin, protected pipeline_mixin::runner_mixin< mean_pipeline<typename SourceMixin::source_type::value_type>>, @@ -61,6 +73,7 @@ public: template<class Executor, class... Args> runner(const Executor& e, Args&&... args): + runner_base(), source_mixin(e, std::forward<Args>(args)...), pipeline_mixin::runner_mixin<mean_pipeline_type>( this->source().width(), @@ -80,6 +93,10 @@ runner_result run(); private: + auto bounding_box_hint(const std::array<float, 2>& center, float radius) const { + return runner_base::bounding_box_hint(center, radius, this->source().width(), this->source().height()); + } + typename mean_pipeline_type::buffer_type accum_buffer_; std::mt19937 rng_; }; @@ -96,7 +113,9 @@ this->commit(); const auto& edge_geom = r.first.edge; - return {edge_geom.center, edge_geom.radius}; + const auto [hint_offset, hint_size] = this->bounding_box_hint(edge_geom.center, edge_geom.radius); + + return {edge_geom.center, edge_geom.radius, hint_offset, hint_size}; }
View file
domecam-0.1.10.obscpio/src/curl.cpp -> domecam-0.1.11.obscpio/src/curl.cpp
Changed
@@ -47,6 +47,8 @@ curl::curl(): curl_{do_init(), &deleter}, header_list_{nullptr, &list_deleter} { + + libcurl_error::throw_on_error(curl_easy_setopt(curl_.get(), CURLOPT_FAILONERROR, 1L)); } void curl::append_header(const char* string) { @@ -63,8 +65,7 @@ } void curl::perform() { - const CURLcode ret = curl_easy_perform(curl_.get()); - libcurl_error::throw_on_error(ret); + libcurl_error::throw_on_error(curl_easy_perform(curl_.get())); } CURL* curl::do_init() {
View file
domecam-0.1.10.obscpio/src/executor/mean_pupil_mask.cpp -> domecam-0.1.11.obscpio/src/executor/mean_pupil_mask.cpp
Changed
@@ -4,6 +4,9 @@ * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> */ +#include <algorithm> +#include <cmath> + #include <executor/mean_pupil_mask.h> #include <iofwd.h> @@ -13,18 +16,80 @@ jv = { {"center", {{"mean", value_from(r.center_mean)}}}, - {"radius", {{"mean", value_from(r.radius_mean)}}}}; + {"radius", {{"mean", value_from(r.radius_mean)}}}, + {"bounding_box_hint", { + {"offset", value_from(r.hint_offset)}, + {"size", value_from(r.hint_size)}}}}; } std::ostream& operator<<(std::ostream& stm, const mean_pupil_mask_executor_base::runner_result& s) { stm << "Statistics:" << std::endl << "Center\tX\tY\tRadius" << std::endl - << "Mean: " << std::get<0>(s.center_mean) << " " << std::get<1>(s.center_mean) << " " << s.radius_mean << std::endl; + << "Mean: " << std::get<0>(s.center_mean) << " " << std::get<1>(s.center_mean) << " " << s.radius_mean << std::endl + << "Bounding box hint: " + << std::get<0>(s.hint_size) << "x" << std::get<1>(s.hint_size) << " @ " << std::get<0>(s.hint_offset) << "," << std::get<1>(s.hint_offset) << std::endl; return stm; } +std::pair<std::size_t, std::size_t> +mean_pupil_mask_executor_base::runner_base::bounding_range_hint(float center, float radius, std::size_t size_limit) { + /* The following values have been obtained by benchmarking fftw3f. */ + constexpr static std::uint16_t sizes[] = {1, 2, 3, 4, 5, 6, 8, 9, 10, 12, + 16, 20, 25, 32, 36, 40, 42, 44, 48, 50, 52, 56, 64, 66, 70, 72, 80, 84, 90, 96, + 100, 112, 120, 128, 144, 150, 160, 162, 168, 180, 192, 200, 208, 224, 240, 245, + 256, 260, 280, 288, 300, 320, 324, 325, 336, 400, 416, 432, 448, 450, 480, 486, + 490, 512, 520, 540, 560, 576, 640, 648, 650, 672, 720, 768, 784, 792, 840, 864, + 896, 900, 1024}; + + std::pair<std::size_t, std::size_t> ret; + auto& [hint_offset, hint_size] = ret; + + const std::size_t cmr = std::llround(center - radius); + const std::size_t cpr = std::llround(center + radius); + const auto lower = (center < radius ? 0 : cmr); + const auto upper = std::min(cpr, size_limit - 1); + const auto size_min = upper - lower + 1; + + assert(size_limit > 0); + assert(size_min <= size_limit); + + /* Here, we round the size up to obtain the best FFT performance possible. Then + * the offset is chosen as an average of the allowed range. However, this + * algorithm doesn't take into account that some cameras doesn't allow + * arbitrary offset and size for ROI. + */ + + /* std::upper_bound returns first size such that (upper - lower) < size. */ + const auto it = std::upper_bound(std::cbegin(sizes), std::cend(sizes), upper - lower); + const auto better_size = (it == std::cend(sizes) ? + size_min + (size_min % 2) : // just round up to even value + static_cast<std::size_t>(*it)); + hint_size = (better_size > size_limit ? size_min : better_size); + + const auto offset_min = (upper < hint_size ? 0 : upper - hint_size + 1); + const auto offset_max = std::min(lower, size_limit - hint_size); + hint_offset = offset_min + (offset_max - offset_min) / 2; + + return ret; +} + +std::pair<std::array<std::size_t, 2>, std::array<std::size_t, 2>> +mean_pupil_mask_executor_base::runner_base::bounding_box_hint(const std::array<float, 2>& center, float radius, std::size_t width, std::size_t height) { + std::pair<std::array<std::size_t, 2>, std::array<std::size_t, 2>> ret; + auto& [offset, size] = ret; + auto& [offset_x, offset_y] = offset; + auto& [size_x, size_y] = size; + const auto& [center_x, center_y] = center; + + std::tie(offset_x, size_x) = bounding_range_hint(center_x, radius, width); + std::tie(offset_y, size_y) = bounding_range_hint(center_y, radius, height); + + return ret; +} + + mean_pupil_mask_executor_base::mean_pupil_mask_executor_base(const std::string& target_uri, std::size_t samples_number): fits_sink_mixin(target_uri), pipeline_mixin(),
View file
domecam-0.1.11.obscpio/test/mean_pupil_mask.cpp
Added
@@ -0,0 +1,186 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#include <cppunit/extensions/TestFactoryRegistry.h> +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/ui/text/TestRunner.h> +#include <cppunit/TestAssert.h> + +#include <array> +#include <numeric> + +#include <buffer.h> +#include <buffer_view.h> +#include <executor/mean_pupil_mask.h> + + +class test_bounding_box_hint_suite: public CppUnit::TestCase { +CPPUNIT_TEST_SUITE(test_bounding_box_hint_suite); +CPPUNIT_TEST(test_hint1); +CPPUNIT_TEST(test_hint2); +CPPUNIT_TEST(test_hint3); +CPPUNIT_TEST(test_hint4); +CPPUNIT_TEST(test_hint5); +CPPUNIT_TEST(test_hint6); +CPPUNIT_TEST(test_hint7); +CPPUNIT_TEST(test_hint8); +CPPUNIT_TEST(test_hint9); +CPPUNIT_TEST_SUITE_END(); + +using runner_base = mean_pupil_mask_executor_base::runner_base; + +void test_hint1() { + const std::array<float, 2> center{7.5, 7.5}; + const float radius = 7.5; + const std::size_t width = 1024; + const std::size_t height = 1024; + + const auto [offset, size] = runner_base::bounding_box_hint(center, radius, width, height); + const auto& [offset_x, offset_y] = offset; + const auto& [size_x, size_y] = size; + + CPPUNIT_ASSERT_EQUAL(std::size_t(0), offset_x); + CPPUNIT_ASSERT_EQUAL(std::size_t(0), offset_y); + CPPUNIT_ASSERT_EQUAL(std::size_t(16), size_x); + CPPUNIT_ASSERT_EQUAL(std::size_t(16), size_y); +} + +void test_hint2() { + const std::array<float, 2> center{7.5, 7.5}; + const float radius = 6.5; + const std::size_t width = 1024; + const std::size_t height = 1024; + + const auto [offset, size] = runner_base::bounding_box_hint(center, radius, width, height); + const auto& [offset_x, offset_y] = offset; + const auto& [size_x, size_y] = size; + + CPPUNIT_ASSERT_EQUAL(std::size_t(0), offset_x); + CPPUNIT_ASSERT_EQUAL(std::size_t(0), offset_y); + CPPUNIT_ASSERT_EQUAL(std::size_t(16), size_x); + CPPUNIT_ASSERT_EQUAL(std::size_t(16), size_y); +} + +void test_hint3() { + const std::array<float, 2> center{7.5, 0}; + const float radius = 6.5; + const std::size_t width = 1024; + const std::size_t height = 1024; + + const auto [offset, size] = runner_base::bounding_box_hint(center, radius, width, height); + const auto& [offset_x, offset_y] = offset; + const auto& [size_x, size_y] = size; + + CPPUNIT_ASSERT_EQUAL(std::size_t(0), offset_x); + CPPUNIT_ASSERT_EQUAL(std::size_t(0), offset_y); + CPPUNIT_ASSERT_EQUAL(std::size_t(16), size_x); + CPPUNIT_ASSERT_EQUAL(std::size_t(8), size_y); +} + +void test_hint4() { + const std::array<float, 2> center{7.5, 1023}; + const float radius = 6.5; + const std::size_t width = 1024; + const std::size_t height = 1024; + + const auto [offset, size] = runner_base::bounding_box_hint(center, radius, width, height); + const auto& [offset_x, offset_y] = offset; + const auto& [size_x, size_y] = size; + + CPPUNIT_ASSERT_EQUAL(std::size_t(0), offset_x); + CPPUNIT_ASSERT_EQUAL(std::size_t(1016), offset_y); + CPPUNIT_ASSERT_EQUAL(std::size_t(16), size_x); + CPPUNIT_ASSERT_EQUAL(std::size_t(8), size_y); +} + +void test_hint5() { + const std::array<float, 2> center{511.5, 3.5}; + const float radius = 6.5; + const std::size_t width = 1024; + const std::size_t height = 8; + + const auto [offset, size] = runner_base::bounding_box_hint(center, radius, width, height); + const auto& [offset_x, offset_y] = offset; + const auto& [size_x, size_y] = size; + + CPPUNIT_ASSERT_EQUAL(std::size_t(504), offset_x); + CPPUNIT_ASSERT_EQUAL(std::size_t(0), offset_y); + CPPUNIT_ASSERT_EQUAL(std::size_t(16), size_x); + CPPUNIT_ASSERT_EQUAL(std::size_t(8), size_y); +} + +void test_hint6() { + const std::array<float, 2> center{7.5, 8.5}; + const float radius = 7.5; + const std::size_t width = 1024; + const std::size_t height = 16; + + const auto [offset, size] = runner_base::bounding_box_hint(center, radius, width, height); + const auto& [offset_x, offset_y] = offset; + const auto& [size_x, size_y] = size; + + CPPUNIT_ASSERT_EQUAL(std::size_t(0), offset_x); + CPPUNIT_ASSERT_EQUAL(std::size_t(0), offset_y); + CPPUNIT_ASSERT_EQUAL(std::size_t(16), size_x); + CPPUNIT_ASSERT_EQUAL(std::size_t(16), size_y); +} + +void test_hint7() { + const std::array<float, 2> center{7.5, 6.5}; + const float radius = 7.5; + const std::size_t width = 1024; + const std::size_t height = 16; + + const auto [offset, size] = runner_base::bounding_box_hint(center, radius, width, height); + const auto& [offset_x, offset_y] = offset; + const auto& [size_x, size_y] = size; + + CPPUNIT_ASSERT_EQUAL(std::size_t(0), offset_x); + CPPUNIT_ASSERT_EQUAL(std::size_t(0), offset_y); + CPPUNIT_ASSERT_EQUAL(std::size_t(16), size_x); + CPPUNIT_ASSERT_EQUAL(std::size_t(16), size_y); +} + +void test_hint8() { + const std::array<float, 2> center{7.5, 11.5}; + const float radius = 7.5; + const std::size_t width = 1024; + const std::size_t height = 16; + + const auto [offset, size] = runner_base::bounding_box_hint(center, radius, width, height); + const auto& [offset_x, offset_y] = offset; + const auto& [size_x, size_y] = size; + + CPPUNIT_ASSERT_EQUAL(std::size_t(0), offset_x); + CPPUNIT_ASSERT_EQUAL(std::size_t(4), offset_y); + CPPUNIT_ASSERT_EQUAL(std::size_t(16), size_x); + CPPUNIT_ASSERT_EQUAL(std::size_t(12), size_y); +} + +void test_hint9() { + const std::array<float, 2> center{7.5, 3.5}; + const float radius = 7.5; + const std::size_t width = 1024; + const std::size_t height = 16; + + const auto [offset, size] = runner_base::bounding_box_hint(center, radius, width, height); + const auto& [offset_x, offset_y] = offset; + const auto& [size_x, size_y] = size; + + CPPUNIT_ASSERT_EQUAL(std::size_t(0), offset_x); + CPPUNIT_ASSERT_EQUAL(std::size_t(0), offset_y); + CPPUNIT_ASSERT_EQUAL(std::size_t(16), size_x); + CPPUNIT_ASSERT_EQUAL(std::size_t(12), size_y); +} +}; +CPPUNIT_TEST_SUITE_REGISTRATION(test_bounding_box_hint_suite); + +int main(int argc, char **argv) { + CppUnit::TextUi::TestRunner runner; + CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); + runner.addTest(registry.makeTest()); + return !runner.run("", false); +}
View file
domecam.obsinfo
Changed
@@ -1,3 +1,3 @@ name: domecam -version: 0.1.10 -mtime: 1665326936 +version: 0.1.11 +mtime: 1666173046
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.