Projects
domecam:swift
domecam
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 21
View file
domecam.changes
Changed
@@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Tue Apr 12 18:42:11 UTC 2022 - Matwey V. Kornilov <matwey@sai.msu.ru> + +- Version 0.1.6 + +------------------------------------------------------------------- Wed Feb 2 08:46:24 UTC 2022 - Matwey V. Kornilov <matwey@sai.msu.ru> - Version 0.1.5
View file
domecam.spec
Changed
@@ -20,7 +20,7 @@ Version: 0 Release: 0 Summary: Tools for DomeCam equipment -License: GPL-3.0-only +License: GPL-3.0-or-later Group: Productivity/Scientific/Astronomy URL: https://curl.sai.msu.ru/hg/home/matwey/domecam Source: %{name}-%{version}.tar.xz @@ -94,12 +94,14 @@ %files %defattr(-,root,root) +%license LICENSE.txt %{_bindir}/domecam %{_bindir}/domecam-replay %{_bindir}/carriage %{_bindir}/serial_io %files -n domecamd +%license LICENSE.txt %defattr(-,root,root) %{_sysusersdir}/domecamd-user.conf %config(noreplace) %{_sysconfdir}/domecamd.conf
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.5</param> + <param name="revision">0.1.6</param> </service> <service name="tar" mode="buildtime" /> <service name="recompress" mode="buildtime">
View file
domecam-0.1.5.obscpio/src/executor.cpp
Deleted
@@ -1,1209 +0,0 @@ -#include <chrono> -#include <iomanip> -#include <iostream> -#include <iterator> -#include <ostream> -#include <type_traits> -#include <utility> - -#include <boost/accumulators/accumulators.hpp> -#include <boost/accumulators/statistics/error_of_mean.hpp> -#include <boost/accumulators/statistics/moment.hpp> -#include <boost/accumulators/statistics/min.hpp> -#include <boost/accumulators/statistics/max.hpp> -#include <boost/accumulators/statistics/stats.hpp> -#include <boost/io/ios_state.hpp> - -#include <curl.h> -#include <executor.h> -#include <pipeline.h> -#include <quadfit.h> -#include <source.h> - -namespace { - -template<class T> -struct pipeline_mixin { - typedef T pipeline_type; -protected: - pipeline_type pipeline_; -public: - template<class... Args> - pipeline_mixin(Args&&... args): - pipeline_(std::forward<Args>(args)...) {} -}; - - -template<template<class> class Runner, class Executor, class ResultType = void> -struct runner_visitor { -private: - const Executor& e_; -public: - typedef ResultType result_type; - - explicit runner_visitor(const Executor& e): e_(e) {} - - template<class T> result_type operator()(const fits::image<T>& im) const { - Runner<T> r{e_, im}; - - return r.run(); - }; -}; - - -struct pupil_minix_base { - std::size_t frame_num_; - pupil_geometry geometry_; - std::mt19937 rng_; - - pupil_minix_base(): - frame_num_(0), geometry_() {} - - template<class T, class V = typename std::enable_if<!buffer_traits<T>::has_position>::type> - static inline std::size_t frame_num(const T&, std::size_t n) noexcept { - return n; - } - - template<class T, class V = typename std::enable_if<buffer_traits<T>::has_position>::type> - static inline auto frame_num(const T& b, std::size_t) noexcept -> - decltype(buffer_traits<T>::position(b)) { - return buffer_traits<T>::position(b); - } -}; - -} // namespace - - -executor_result::abstract_impl::~abstract_impl() = default; - -template<class T> -class executor_result::wrap_impl: - public executor_result::abstract_impl { -public: - wrap_impl(const T&); - wrap_impl(T&&); - - wrap_impl(const wrap_impl<T>&) = delete; - wrap_impl(wrap_impl<T>&&) = delete; - wrap_impl<T>& operator=(const wrap_impl<T>&) = delete; - wrap_impl<T>& operator=(wrap_impl<T>&&) = delete; - ~wrap_impl() override final = default; - - std::ostream& print(std::ostream& stm) const override final; -private: - T data_; -}; - -template<class T> -executor_result::wrap_impl<T>::wrap_impl(const T& data): - data_{data} {} - -template<class T> -executor_result::wrap_impl<T>::wrap_impl(T&& data): - data_{std::move(data)} {} - -template<class T> -std::ostream& executor_result::wrap_impl<T>::print(std::ostream& stm) const { - return stm << data_; -} - -executor_result::executor_result(): - impl_{nullptr} {} - -template<class T> -executor_result::executor_result(const T& data): - impl_{new wrap_impl<T>{data}} {} - -template<class T> -executor_result::executor_result(T&& data): - impl_{new wrap_impl<T>{std::move(data)}} {} - -std::ostream& executor_result::print(std::ostream& stm) const { - return impl_ ? impl_->print(stm) : stm; -} - - -executor::executor() = default; - -executor::~executor() = default; - - -struct camera_executor::camera_source_mixin { -public: - typedef camera_source<std::uint16_t> source_type; -protected: - source_type source_; -public: - camera_source_mixin(const camera_executor& e, camera& c); -}; - -camera_executor::camera_source_mixin::camera_source_mixin(const camera_executor& e, camera& c): - source_(c, e.frames_number_, std::chrono::seconds(5), 20) {} - - -camera_executor::camera_executor(std::size_t frames_number): - executor(), - frames_number_(frames_number) {} - -camera_executor::~camera_executor() = default; - - -carriage_executor::runner::runner(abstract_carriage& c): - c_(c) { - - c_.reset(); - c_.current(carriage::current_level::minimal); - - const boost::io::ios_flags_saver ifs(std::cerr); - - std::cerr << "Ident: 0x" << std::hex << std::setfill('0') << std::setw(4) << c_.ident() << std::endl; - std::cerr << "Status: 0x" << std::hex << std::setfill('0') << std::setw(4) << static_cast<std::uint16_t>(c_.status()) << std::endl; - std::cerr << "Absolute: " << std::dec << c_.absolute() << std::endl; - std::cerr << "Relative: " << std::dec << c_.relative() << std::endl; - std::cerr << "Speed: " << std::dec << c_.speed() << std::endl; - std::cerr << "Accel: " << std::dec << c_.accel() << std::endl; - std::cerr << "Path: " << std::dec << c_.path() << std::endl; - std::cerr << "Sync mask: 0x" << std::hex << c_.sync_mask() << std::endl; - std::cerr << "User data: 0x" << std::hex << c_.user_data() << std::endl; -} - -void carriage_executor::runner::run() { -} - -carriage_executor::carriage_executor(): - executor() {} - -executor_result carriage_executor::run(camera& c) const { - carriage carriage_{c}; - - return run(carriage_); -} - -executor_result carriage_executor::run(abstract_carriage& c) const { - runner r{c}; - - r.run(); - - return {}; -} - - -struct scan_executor::scan_source_mixin { -public: - typedef scan_source<std::uint16_t> source_type; -protected: - source_type source_; -public: - scan_source_mixin(const scan_executor& e, camera& c); -}; -
View file
domecam-0.1.5.obscpio/.hgtags -> domecam-0.1.6.obscpio/.hgtags
Changed
@@ -3,3 +3,4 @@ c6d84807bd19c436ecb724d327e00372983620f1 0.1.2 02ff28d26953387cf82a03f8fd1c65efd070aae1 0.1.3 bed3c493a6fd64ba8f0929b8ad56ab51144628f6 0.1.4 +8e510d8d9774e21cdbf83dd82d7b029285889ae4 0.1.5
View file
domecam-0.1.5.obscpio/CMakeLists.txt -> domecam-0.1.6.obscpio/CMakeLists.txt
Changed
@@ -1,5 +1,5 @@ cmake_minimum_required (VERSION 3.5) -project(domecam LANGUAGES C CXX VERSION 0.1.5) +project(domecam LANGUAGES C CXX VERSION 0.1.6) set(CMAKE_CXX_STANDARD 11)
View file
domecam-0.1.6.obscpio/LICENSE.txt
Added
@@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice;
View file
domecam-0.1.5.obscpio/exe/carriage.cpp -> domecam-0.1.6.obscpio/exe/carriage.cpp
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #include <atomic> #include <iomanip> #include <iostream>
View file
domecam-0.1.5.obscpio/exe/domecam-replay.cpp -> domecam-0.1.6.obscpio/exe/domecam-replay.cpp
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #include <atomic> #include <chrono> #include <iostream> @@ -15,8 +21,11 @@ int do_run(const boost::program_options::variables_map& va) override; public: static constexpr const char input_filename_opt[] = "input_filename"; + static constexpr const char mean_filename_opt[] = "mean_filename"; static constexpr const char grad_filename_opt[] = "grad_filename"; static constexpr const char binary_filename_opt[] = "binary_filename"; + static constexpr const char pupil_mask_filename_opt[] = "pupil_mask_filename"; + static constexpr const char mean_pupil_mask_filename_opt[] = "mean_pupil_mask_filename"; static constexpr const char pupil_opt[] = "pupil"; static constexpr const char pupil_samples_opt[] = "samples"; static constexpr const char force_initial_opt[] = "force_initial"; @@ -25,8 +34,11 @@ }; constexpr const char application::input_filename_opt[]; +constexpr const char application::mean_filename_opt[]; constexpr const char application::grad_filename_opt[]; constexpr const char application::binary_filename_opt[]; +constexpr const char application::pupil_mask_filename_opt[]; +constexpr const char application::mean_pupil_mask_filename_opt[]; constexpr const char application::pupil_opt[]; constexpr const char application::pupil_samples_opt[]; constexpr const char application::force_initial_opt[]; @@ -38,8 +50,11 @@ opts_.add_options() (input_filename_opt, po::value<std::string>()->required(), "Input filename") + (mean_filename_opt, po::value<std::string>(), "Mean output filename") (grad_filename_opt, po::value<std::string>(), "Gradient output filename") (binary_filename_opt, po::value<std::string>(), "Binary output filename") + (pupil_mask_filename_opt, po::value<std::string>(), "Pupil mask output filename") + (mean_pupil_mask_filename_opt, po::value<std::string>(), "Mean pupil mask output filename") (pupil_opt, "Do entrance pupil image processing") (pupil_samples_opt, po::value<std::size_t>()->default_value(60), "Number of pupil edge sampling points") (force_initial_opt, "Force initial geometry reestimation for each frame") @@ -63,7 +78,11 @@ std::cout << "Format: " << vi.width() << " x " << vi.height() << " x " << vi.depth() << std::endl; const auto time_begin = std::chrono::steady_clock::now(); - if (va.count(grad_filename_opt)) { + if (va.count(mean_filename_opt)) { + const auto& output_filename = va[mean_filename_opt].as<std::string>(); + mean_raw_replay_executor e(output_filename); + std::cerr << e.run(vi); + } else if (va.count(grad_filename_opt)) { const auto& output_filename = va[grad_filename_opt].as<std::string>(); grad_replay_executor e(output_filename); std::cerr << e.run(vi); @@ -71,6 +90,14 @@ const auto& output_filename = va[binary_filename_opt].as<std::string>(); binary_replay_executor e(output_filename); std::cerr << e.run(vi); + } else if (va.count(pupil_mask_filename_opt)) { + const auto& output_filename = va[pupil_mask_filename_opt].as<std::string>(); + pupil_mask_replay_executor e(output_filename, va[pupil_samples_opt].as<std::size_t>(), va.count(force_initial_opt) > 0); + std::cerr << e.run(vi); + } else if (va.count(mean_pupil_mask_filename_opt)) { + const auto& output_filename = va[mean_pupil_mask_filename_opt].as<std::string>(); + mean_pupil_mask_replay_executor e(output_filename, va[pupil_samples_opt].as<std::size_t>()); + std::cerr << e.run(vi); } else if (va.count(pupil_opt)) { pupil_replay_executor e(va[pupil_samples_opt].as<std::size_t>(), va.count(force_initial_opt) > 0); std::cerr << e.run(vi);
View file
domecam-0.1.5.obscpio/exe/domecam.cpp -> domecam-0.1.6.obscpio/exe/domecam.cpp
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #include <iostream> #include <application.h>
View file
domecam-0.1.5.obscpio/exe/domecamd/consumer.cpp -> domecam-0.1.6.obscpio/exe/domecamd/consumer.cpp
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #include <chrono> #include <exception> #include <functional>
View file
domecam-0.1.5.obscpio/exe/domecamd/main.cpp -> domecam-0.1.6.obscpio/exe/domecamd/main.cpp
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #include <iostream> #include <thread>
View file
domecam-0.1.5.obscpio/exe/domecamd/scheduler.cpp -> domecam-0.1.6.obscpio/exe/domecamd/scheduler.cpp
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #include <exe/domecamd/scheduler.h> scheduler::task::task(const std::string& id, std::unique_ptr<executor>&& e, const optional_camera_settings& camera_settings):
View file
domecam-0.1.5.obscpio/exe/serial_io.cpp -> domecam-0.1.6.obscpio/exe/serial_io.cpp
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #include <atomic> #include <iostream> #include <string>
View file
domecam-0.1.5.obscpio/include/application.h -> domecam-0.1.6.obscpio/include/application.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _APPLICATION_H #define _APPLICATION_H
View file
domecam-0.1.5.obscpio/include/binary.h -> domecam-0.1.6.obscpio/include/binary.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _BINARY_H #define _BINARY_H @@ -84,9 +90,9 @@ std::size_t height_; allocator_type alloc_; +public: using detail::binary_base<value_type, Align>::estimate_threshold; -public: binary_mask(std::size_t width, std::size_t height, const allocator_type& alloc = allocator_type()): width_(width), height_(height), @@ -94,6 +100,7 @@ } inline buffer_type operator() (buffer_view<value_type, Align> b) const; + inline buffer_type operator() (buffer_view<value_type, Align> b, const value_type& threshold) const; inline const std::size_t width() const { return width_; } inline const std::size_t height() const { return height_; } @@ -111,31 +118,33 @@ private: allocator_type alloc_; +public: using detail::binary_base<value_type, Align>::estimate_threshold; - template<class OutputIterator> - OutputIterator proc(buffer_view<value_type, Align> b, std::size_t count, OutputIterator output) const; - -public: explicit binary_index(const allocator_type& alloc = allocator_type()): alloc_(alloc) { } inline buffer_type operator() (buffer_view<value_type, Align> b) const; + inline buffer_type operator() (buffer_view<value_type, Align> b, const value_type& threshold) const; }; template<class T, std::size_t Align, class Allocator> typename binary_mask<T, Align, Allocator>::buffer_type binary_mask<T, Align, Allocator>::operator() (buffer_view<T, Align> b) const { + return operator() (b, estimate_threshold(b)); +} + +template<class T, std::size_t Align, class Allocator> +typename binary_mask<T, Align, Allocator>::buffer_type +binary_mask<T, Align, Allocator>::operator() (buffer_view<value_type, Align> b, const value_type& threshold) const { buffer_type ret{b.size(), alloc_}; assert(width_ * height_ == b.size()); - const auto thresh = estimate_threshold(b); - for (std::size_t i = 0; i < b.size(); ++i) { - ret.data()[i] = (b.data()[i] < thresh ? + ret.data()[i] = (b.data()[i] < threshold ? static_cast<result_type>(0) : static_cast<result_type>(255)); } @@ -144,28 +153,21 @@ } template<class T, std::size_t Align, class Allocator> -template<class OutputIterator> -OutputIterator -binary_index<T, Align, Allocator>::proc(buffer_view<T, Align> b, std::size_t count, OutputIterator output) const { - const auto thresh = estimate_threshold(b); - - std::size_t j = 0; - for (result_type i = 0; i < b.size() && j < count; ++i) { - if (b.data()[i] >= thresh) { - *output++ = i; - ++j; - } - } - - return output; +typename binary_index<T, Align, Allocator>::buffer_type +binary_index<T, Align, Allocator>::operator() (buffer_view<T, Align> b) const { + return operator() (b, estimate_threshold(b)); } template<class T, std::size_t Align, class Allocator> typename binary_index<T, Align, Allocator>::buffer_type -binary_index<T, Align, Allocator>::operator() (buffer_view<T, Align> b) const { +binary_index<T, Align, Allocator>::operator() (buffer_view<T, Align> b, const value_type& threshold) const { + using sequence_iterator = boost::counting_iterator<std::size_t>; + buffer_type ret{b.size(), alloc_}; - const auto end = proc(b, ret.size(), ret.begin()); + const auto end = std::copy_if(sequence_iterator(0), sequence_iterator(b.size()), ret.begin(), [&b, &threshold] (std::size_t i) { + return !(b.data()[i] < threshold); + }); ret.resize(end - ret.begin()); return ret;
View file
domecam-0.1.5.obscpio/include/buffer.h -> domecam-0.1.6.obscpio/include/buffer.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _BUFFER_H #define _BUFFER_H
View file
domecam-0.1.5.obscpio/include/buffer_view.h -> domecam-0.1.6.obscpio/include/buffer_view.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _BUFFER_VIEW_H #define _BUFFER_VIEW_H
View file
domecam-0.1.5.obscpio/include/camera.h -> domecam-0.1.6.obscpio/include/camera.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _CAMERA_H #define _CAMERA_H
View file
domecam-0.1.5.obscpio/include/camera_settings.h -> domecam-0.1.6.obscpio/include/camera_settings.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _CAMERA_SETTINGS_H #define _CAMERA_SETTINGS_H
View file
domecam-0.1.5.obscpio/include/carriage.h -> domecam-0.1.6.obscpio/include/carriage.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _CARRIAGE_H #define _CARRIAGE_H
View file
domecam-0.1.5.obscpio/include/convert.h -> domecam-0.1.6.obscpio/include/convert.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _CONVERT_H #define _CONVERT_H
View file
domecam-0.1.5.obscpio/include/curl.h -> domecam-0.1.6.obscpio/include/curl.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _CURL_H #define _CURL_H
View file
domecam-0.1.5.obscpio/include/device.h -> domecam-0.1.6.obscpio/include/device.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _DEVICE_H #define _DEVICE_H
View file
domecam-0.1.5.obscpio/include/edge_entropy.h -> domecam-0.1.6.obscpio/include/edge_entropy.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _EDGE_ENTROPY_H #define _EDGE_ENTROPY_H
View file
domecam-0.1.5.obscpio/include/edge_select.h -> domecam-0.1.6.obscpio/include/edge_select.h
Changed
@@ -1,41 +1,88 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _EDGE_SELECT_H #define _EDGE_SELECT_H #include <array> +#include <cassert> +#include <cmath> // std::sqrt #include <iterator> +#include <limits> #include <memory> #include <type_traits> -#include <limits> #include <buffer.h> #include <buffer_view.h> namespace detail { -template<class T> const T& clamp(const T& x, const T& low, const T& high) { - return (x >= low ? (x <= high ? x : high) : low); +template<class T> +typename std::enable_if<std::is_floating_point<T>::value, T>::type leg(const T hypot, const T other_leg) { + const auto c = other_leg / hypot; + return hypot * std::sqrt(static_cast<T>(1) - c*c); } -template<class T> long long lfloor(const T& x) { - return (x >= static_cast<T>(0) - ? static_cast<long long>(x) - : static_cast<long long>(x*(static_cast<T>(1)+std::numeric_limits<T>::epsilon()))-1 - ); +template<class T> +typename std::enable_if<std::is_integral<T>::value, double>::type leg(const T hypot, const T other_leg) { + return leg(static_cast<double>(hypot), static_cast<double>(other_leg)); +} + +template<class T> +typename std::enable_if<std::is_signed<T>::value, T>::type diff_or_zero(const T x, const T y) { + return std::max(x - y, static_cast<T>(0)); +} + +template<class T> +typename std::enable_if<std::is_unsigned<T>::value, T>::type diff_or_zero(const T x, const T y) { + return (x > y ? x - y : static_cast<T>(0)); +} + +template<class T> +typename std::enable_if<std::is_signed<T>::value, T>::type abs_diff(const T x, const T y) { + return std::abs(x - y); +} + +template<class T> +typename std::enable_if<std::is_unsigned<T>::value, T>::type abs_diff(const T x, const T y) { + return (x > y ? x - y : y - x); } -template<class T> long long lceil(const T& x) { +template<class T> +typename std::enable_if<std::is_floating_point<T>::value, std::size_t>::type ulceil(const T x) { return (x <= static_cast<T>(0) - ? static_cast<long long>(x) - : static_cast<long long>(x*(static_cast<T>(1)-std::numeric_limits<T>::epsilon()))+1 + ? static_cast<std::size_t>(x) + : static_cast<std::size_t>(x*(static_cast<T>(1)-std::numeric_limits<T>::epsilon()))+1 + ); +} + +template<class T> +typename std::enable_if<std::is_integral<T>::value, std::size_t>::type ulceil(const T x) { + return static_cast<std::size_t>(x); +} + +template<class T> +typename std::enable_if<std::is_floating_point<T>::value, std::size_t>::type ulfloor(const T x) { + return (x >= static_cast<T>(0) + ? static_cast<std::size_t>(x) + : static_cast<std::size_t>(x*(static_cast<T>(1)+std::numeric_limits<T>::epsilon()))-1 ); } -template<class Iterator, class OutputIt> OutputIt x_copy(Iterator first, Iterator last, OutputIt output, - typename std::enable_if< - std::is_same< - typename std::iterator_traits<Iterator>::value_type, - typename std::iterator_traits<OutputIt>::value_type - >::value>::type* = nullptr) { +template<class T> +typename std::enable_if<std::is_integral<T>::value, std::size_t>::type ulfloor(const T x) { + return static_cast<std::size_t>(x); +} + + +template<class Iterator, class OutputIt> +typename std::enable_if<std::is_same< + typename std::iterator_traits<Iterator>::value_type, + typename std::iterator_traits<OutputIt>::value_type>::value, + OutputIt>::type x_copy(Iterator first, Iterator last, OutputIt output) { if (output == first) return output + (last - first); @@ -43,88 +90,150 @@ return std::copy(first, last, output); } -template<class Iterator, class OutputIt> OutputIt x_copy(Iterator first, Iterator last, OutputIt output, - typename std::enable_if< - !std::is_same< - typename std::iterator_traits<Iterator>::value_type, - typename std::iterator_traits<OutputIt>::value_type - >::value>::type* = nullptr) { +template<class Iterator, class OutputIt> +typename std::enable_if<!std::is_same< + typename std::iterator_traits<Iterator>::value_type, + typename std::iterator_traits<OutputIt>::value_type>::value, + OutputIt>::type x_copy(Iterator first, Iterator last, OutputIt output) { return std::copy(first, last, output); } } // detail -template<class T, std::size_t Align, class Allocator = std::allocator<T>> -class edge_select { -public: - using value_type = T; - using result_type = value_type; - using allocator_type = Allocator; - using buffer_type = buffer<value_type, Align, allocator_type>; +class edge_select_base { private: std::size_t size_; std::size_t width_; std::size_t height_; - allocator_type alloc_; -private: - static std::size_t project(const long long& val, const long long& max) { - const long long min{0}; - return detail::clamp(val, min, max); +protected: + template<class S> + static std::size_t project_min(const S center, const S radius, const std::size_t limit) { + return std::min(limit, detail::ulceil(detail::diff_or_zero(center, radius))); + } + + template<class S> + std::size_t project_x_min(const S center, const S radius) const { + return project_min(center, radius, width_); + } + + template<class S> + std::size_t project_y_min(const S center, const S radius) const { + return project_min(center, radius, height_); + } + + template<class S> + static std::size_t project_inner_min(const S center, const S radius, const std::size_t limit) { + return std::min(limit, detail::ulfloor(detail::diff_or_zero(center + 1, radius))); + } + + template<class S> + std::size_t project_x_inner_min(const S center, const S radius) const { + return project_inner_min(center, radius, width_); + } + + template<class S> + std::size_t project_y_inner_min(const S center, const S radius) const { + return project_inner_min(center, radius, height_); } - std::size_t project_x(const long long& x) const { - const long long max{static_cast<long long>(width_) - 1}; + template<class S> + static std::size_t project_inner_max(const S center, const S radius, const std::size_t limit) { + return std::min(limit, detail::ulceil(std::max(center + radius, static_cast<S>(0)))); + } + + template<class S> + std::size_t project_x_inner_max(const S center, const S radius) const { + return project_inner_max(center, radius, width_); + } + + template<class S> + std::size_t project_y_inner_max(const S center, const S radius) const { + return project_inner_max(center, radius, height_); + } - return project(x, max); + template<class S> + static std::size_t project_max(const S center, const S radius, const std::size_t limit) { + return std::min(limit, detail::ulfloor(std::max(center + radius + 1, static_cast<S>(0)))); } - std::size_t project_y(const long long& y) const {
View file
domecam-0.1.6.obscpio/include/element_wise.h
Added
@@ -0,0 +1,72 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _ELEMENT_WISE_H +#define _ELEMENT_WISE_H + +#include <cassert> +#include <functional> + +#include <buffer.h> +#include <buffer_view.h> + + +template<class Op, std::size_t Align> +class element_wise: + private Op { +public: + using op_type = Op; + using first_argument_type = typename op_type::first_argument_type; + using second_argument_type = typename op_type::second_argument_type; + using result_type = typename op_type::result_type; + using value_type = first_argument_type; +public: + template<class... Args> + element_wise(Args&&... args): + Op(std::forward<Args>(args)...) {} + + template<class Allocator> + inline buffer<result_type, Align, Allocator>& operator() (buffer<first_argument_type, Align, Allocator>& lhs, buffer_view<second_argument_type, Align> rhs) const { + static_assert(std::is_same<result_type, first_argument_type>::value, "Only in-place operations are allowed"); + + const auto n = lhs.size(); + + assert(lhs.size() == rhs.size()); + + for (std::size_t i = 0; i < n; ++i) { + lhs.data()[i] = Op::operator() (lhs.data()[i], rhs.data()[i]); + } + + return lhs; + } + + template<class Allocator> + inline buffer<result_type, Align, Allocator>& operator() (buffer<first_argument_type, Align, Allocator>& lhs, second_argument_type rhs) const { + static_assert(std::is_same<result_type, first_argument_type>::value, "Only in-place operations are allowed"); + + const auto n = lhs.size(); + + for (std::size_t i = 0; i < n; ++i) { + lhs.data()[i] = Op::operator() (lhs.data()[i], rhs); + } + + return lhs; + } +}; + +template<class T, std::size_t Align> +using element_plus = element_wise<std::plus<T>, Align>; + +template<class T, std::size_t Align> +using element_minus = element_wise<std::minus<T>, Align>; + +template<class T, std::size_t Align> +using element_multiplies = element_wise<std::multiplies<T>, Align>; + +template<class T, std::size_t Align> +using element_divides = element_wise<std::divides<T>, Align>; + +#endif // _ELEMENT_WISE_H
View file
domecam-0.1.5.obscpio/include/error.h -> domecam-0.1.6.obscpio/include/error.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _ERROR_H #define _ERROR_H
View file
domecam-0.1.5.obscpio/include/exe/domecamd/consumer.h -> domecam-0.1.6.obscpio/include/exe/domecamd/consumer.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _EXE_DOMECAMD_CONSUMER_H #define _EXE_DOMECAMD_CONSUMER_H
View file
domecam-0.1.5.obscpio/include/exe/domecamd/scheduler.h -> domecam-0.1.6.obscpio/include/exe/domecamd/scheduler.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _EXE_DOMECAMD_SCHEDULER_H #define _EXE_DOMECAMD_SCHEDULER_H
View file
domecam-0.1.6.obscpio/include/executor
Added
+(directory)
View file
domecam-0.1.5.obscpio/include/executor.h -> domecam-0.1.6.obscpio/include/executor.h
Changed
@@ -1,337 +1,21 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _EXECUTOR_H #define _EXECUTOR_H -#include <cstdint> -#include <random> - -#include <camera.h> -#include <carriage.h> // abstract_carriage -#include <fits.h> - - -class executor_result { -private: - class abstract_impl { - public: - virtual ~abstract_impl() = 0; - virtual std::ostream& print(std::ostream& stm) const = 0; - }; - - template<class T> class wrap_impl; -public: - executor_result(); - template<class T> executor_result(const T&); - template<class T> executor_result(T&&); - - executor_result(const executor_result&) = delete; - executor_result(executor_result&&) = default; - executor_result& operator=(const executor_result&) = delete; - executor_result& operator=(executor_result&&) = default; - ~executor_result() = default; - - std::ostream& print(std::ostream& stm) const; -private: - std::unique_ptr<abstract_impl> impl_; -}; - -inline std::ostream& operator<<(std::ostream& stm, const executor_result& r) { - return r.print(stm); -} - - -class executor { -public: - executor(); - - virtual executor_result run(camera& c) const = 0; - virtual ~executor() = 0; -}; - -class camera_executor: - public executor { -protected: - const std::size_t frames_number_; - - struct camera_source_mixin; -public: - explicit camera_executor(std::size_t frames_number); - - virtual executor_result run(camera& c) const = 0; - virtual ~camera_executor() = 0; -}; - -class carriage_executor: - public executor { -protected: - /* used in exe/carriage.cpp */ - class runner { - protected: - abstract_carriage& c_; - public: - runner(abstract_carriage& c); - - virtual void run(); - }; -public: - carriage_executor(); - - virtual executor_result run(camera& c) const override; - virtual executor_result run(abstract_carriage& c) const; - virtual ~carriage_executor() = default; -}; - -class scan_executor: - public camera_executor { -protected: - struct scan_source_mixin; -public: - explicit scan_executor(std::size_t frames_number); - - virtual executor_result run(camera& c) const = 0; - virtual ~scan_executor() = 0; -}; - -class replay_executor { -protected: - template<class T> struct fits_source_mixin; -public: - virtual executor_result run(const fits::variant_image& vi) const = 0; - virtual ~replay_executor() = 0; -}; - -class fits_sink_executor { -private: - const std::string uri_; - - struct fits_sink_mixin_base; -protected: - template<class T, std::size_t Align> struct fits_sink_mixin; -public: - explicit fits_sink_executor(const std::string& uri); -}; - -class raw_executor: - public camera_executor, - private fits_sink_executor { -private: - struct runner; -public: - raw_executor(const std::string& uri, std::size_t frames_number); - - virtual executor_result run(camera& c) const override; - virtual ~raw_executor() override = default; -}; - -class raw_scan_executor: - public scan_executor, - private fits_sink_executor { -private: - struct runner; -public: - raw_scan_executor(const std::string& uri, std::size_t frames_number); - - virtual executor_result run(camera& c) const override; - virtual ~raw_scan_executor() override = default; -}; - -class gain_executor: - public camera_executor, - private fits_sink_executor { -private: - const double exp_scale_; - const camera::exposure_time_type exp_bias_; - - struct runner; -public: - gain_executor(const std::string& uri, std::size_t pairs_number, double exp_scale, double exp_bias); - - virtual executor_result run(camera& c) const override; - virtual ~gain_executor() override = default; -}; - -struct grad_executor_base: - protected fits_sink_executor { - - template<class T> struct grad_mixin; - - explicit grad_executor_base(const std::string& uri); -}; - -class grad_executor: - public camera_executor, - private grad_executor_base { -private: - struct runner; -public: - grad_executor(const std::string& uri, std::size_t frames_number); - - virtual executor_result run(camera& c) const override; - virtual ~grad_executor() override = default; -}; - -class grad_replay_executor: - public replay_executor, - private grad_executor_base { -private: - template<class T> struct runner; -public: - explicit grad_replay_executor(const std::string& uri); - - virtual executor_result run(const fits::variant_image& vi) const override; - virtual ~grad_replay_executor() override = default; -}; - -struct binary_executor_base: - protected fits_sink_executor { - - template<class T> struct binary_mixin; - - explicit binary_executor_base(const std::string& uri); -}; - -class binary_executor: - public camera_executor,
View file
domecam-0.1.6.obscpio/include/executor/binary.h
Added
@@ -0,0 +1,83 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _EXECUTOR_BINARY_H +#define _EXECUTOR_BINARY_H + +#include <executorfwd.h> +#include <executor/fits_sink_mixin.h> +#include <executor/pipeline_mixin.h> +#include <pipeline.h> + + +struct binary_executor_base: + protected fits_sink_mixin, + protected pipeline_mixin { +protected: + template<class SourceMixin> class runner; +public: + explicit binary_executor_base(const std::string& target_uri); +}; + +template<class SourceMixin> +class binary_executor_base::runner: + public SourceMixin, + protected pipeline_mixin::runner_mixin< + binary_pipeline<typename SourceMixin::source_type::value_type>>, + protected fits_sink_mixin::runner_mixin< + typename binary_pipeline<typename SourceMixin::source_type::value_type>::result_type::value_type, + binary_pipeline<typename SourceMixin::source_type::value_type>::result_type::align> { +private: + using source_mixin = SourceMixin; + using source_type = typename source_mixin::source_type; + using pipeline_type = binary_pipeline<typename source_type::value_type>; + +public: + template<class Executor, class... Args> + runner(const Executor& e, Args&&... args): + source_mixin(e, std::forward<Args>(args)...), + pipeline_mixin::runner_mixin<pipeline_type>( + this->source().width(), + this->source().height()), + fits_sink_mixin::runner_mixin< + typename pipeline_type::result_type::value_type, + pipeline_type::result_type::align>(e, this->source()) {} + + void run(); +}; + +template<class SourceMixin> +void binary_executor_base::runner<SourceMixin>::run() { + this->for_each([this] (const typename source_type::result_type& b) { + this->append_frame(this->apply(b)); + }); + + this->commit(); +} + +class binary_executor: + public camera_executor, + public binary_executor_base { +public: + binary_executor(const std::string& target_uri, std::size_t frames_number); + + virtual executor_result run(camera& c) const override; + virtual ~binary_executor() override = default; +}; + +class binary_replay_executor: + public replay_executor, + public binary_executor_base { +private: + template<class T> using runner_type = runner<source_mixin<T>>; +public: + explicit binary_replay_executor(const std::string& target_uri); + + virtual executor_result run(const fits::variant_image& vi) const override; + virtual ~binary_replay_executor() override = default; +}; + +#endif // _EXECUTOR_BINARY_H
View file
domecam-0.1.6.obscpio/include/executor/carriage.h
Added
@@ -0,0 +1,41 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _EXECUTOR_CARRIAGE_H +#define _EXECUTOR_CARRIAGE_H + +#include <executorfwd.h> + + +class carriage_track_executor: + public carriage_executor { +private: + const std::uint16_t axis_; + const abstract_carriage::direction direction_; + + struct runner; +public: + carriage_track_executor(std::uint16_t axis, abstract_carriage::direction d); + + virtual executor_result run(abstract_carriage& c) const override; + virtual ~carriage_track_executor() override = default; +}; + +class carriage_run_executor: + public carriage_executor { +private: + const std::uint16_t axis_; + const std::int16_t absolute_pos_; + + struct runner; +public: + explicit carriage_run_executor(std::uint16_t axis, std::int16_t absolute_pos); + + virtual executor_result run(abstract_carriage& c) const override; + virtual ~carriage_run_executor() override = default; +}; + +#endif // _EXECUTOR_CARRIAGE_H
View file
domecam-0.1.6.obscpio/include/executor/edge.h
Added
@@ -0,0 +1,131 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _EXECUTOR_EDGE_H +#define _EXECUTOR_EDGE_H + +#include <ostream> + +#include <executorfwd.h> +#include <executor/pupil.h> + + +struct edge_executor_base: + public pupil_executor_base { +public: + struct runner_result; + class runner_base; +protected: + template<class SourceMixin> class runner; +public: + edge_executor_base(std::size_t samples, bool force_initial, float loss_factor); +private: + const float loss_factor_; +}; + + +struct edge_executor_base::runner_result { + using value_type = float; + + value_type entropy_mean; + value_type entropy_error; + value_type focus; +}; + +std::ostream& operator<<(std::ostream& stm, const edge_executor_base::runner_result& s); + +class edge_executor_base::runner_base: + protected pupil_mixin_base { +public: + using value_type = edge_executor_base::runner_result::value_type; + + runner_base(const edge_executor_base& e, std::size_t depth); +protected: + void run_once(value_type edge_entropy, value_type position); + runner_result statistics() const noexcept; +protected: + const edge_executor_base& e_; +private: + std::vector<value_type> positions_; + std::vector<value_type> entropies_; +}; + +template<class SourceMixin> +class edge_executor_base::runner: + public SourceMixin, + public runner_base, + protected pipeline_mixin::runner_mixin< + edge_pipeline<typename SourceMixin::source_type::value_type>> { +private: + using source_mixin = SourceMixin; + using source_type = typename source_mixin::source_type; + using pipeline_type = edge_pipeline<typename source_type::value_type>; + using value_type = typename pipeline_type::value_type; +public: + template<class Executor, class... Args> + runner(const Executor& e, Args&&... args): + source_mixin(e, std::forward<Args>(args)...), + runner_base{e, this->source().depth()}, + pipeline_mixin::runner_mixin<pipeline_type>( + this->source().width(), + this->source().height(), + e.samples_) {} + + void run_once(const typename source_type::result_type& b); + runner_result run(); +}; + +template<class SourceMixin> +void edge_executor_base::runner<SourceMixin>::run_once(const typename source_type::result_type& b) { + const auto& init_geometry = (e_.force_initial_ || frame_num_ == 0 ? nullptr : &geometry_); + const auto& r = this->apply(b, rng_, init_geometry); + const auto& edge_entropy = r.first; + const auto& position = frame_num(b, frame_num_++); + geometry_ = r.second; + + runner_base::run_once(edge_entropy, position); +} + +template<class SourceMixin> +edge_executor_base::runner_result edge_executor_base::runner<SourceMixin>::run() { + this->for_each([this] (const typename source_type::result_type& b) { this->run_once(b); }); + + return statistics(); +} + +class edge_executor: + public camera_executor, + public edge_executor_base { +public: + edge_executor(std::size_t frames_number, std::size_t samples, bool force_initial, float loss_factor); + + virtual executor_result run(camera& c) const override; + virtual ~edge_executor() override = default; +}; + +class edge_scan_executor: + public scan_executor, + public edge_executor_base { +public: + edge_scan_executor(std::size_t frames_number, std::size_t samples, bool force_initial, float loss_factor); + + virtual executor_result run(camera& c) const override; + virtual ~edge_scan_executor() override = default; +}; + +class edge_replay_executor: + public replay_executor, + public edge_executor_base { +private: + template<class T> using runner_type = runner<source_mixin<T>>; +public: + edge_replay_executor(std::size_t samples, bool force_initial, float loss_factor); + + virtual executor_result run(const fits::variant_image& vi) const override; + virtual ~edge_replay_executor() override = default; +}; + +#endif // _EXECUTOR_EDGE_H
View file
domecam-0.1.6.obscpio/include/executor/fits_sink_mixin.h
Added
@@ -0,0 +1,143 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _EXECUTOR_FITS_SINK_MIXIN_H +#define _EXECUTOR_FITS_SINK_MIXIN_H + +#include <memory> +#include <string> + +#include <curl.h> +#include <fits.h> +#include <source.h> + + +class fits_sink_mixin { +private: + const std::string target_uri_; + + struct runner_mixin_base; +protected: + template<class T, std::size_t Align> struct runner_mixin; +public: + explicit fits_sink_mixin(const std::string& target_uri); + + const std::string& target_uri() const { + return target_uri_; + } +}; + +struct fits_sink_mixin::runner_mixin_base { +public: + runner_mixin_base(const fits_sink_mixin& e, std::size_t capacity); + + virtual void shrink_to_fit() = 0; + + void flush(); + void commit(); + + inline fits& get_fits(); + + std::size_t frame_num() const { + return frame_num_; + } +private: + struct impl; + struct impl_file; + struct impl_http; + + std::unique_ptr<impl> pimpl_; +protected: + std::size_t frame_num_; +}; + +struct fits_sink_mixin::runner_mixin_base::impl { + virtual fits& get_fits() = 0; + virtual void commit() {}; + virtual ~impl() = 0; +}; + +fits& fits_sink_mixin::runner_mixin_base::get_fits() { + return pimpl_->get_fits(); +} + +template<class T, std::size_t Align> +struct fits_sink_mixin::runner_mixin: + public runner_mixin_base { +protected: + fits::image<T> image_; + + void append_frame(buffer_view<T, Align> b); + void shrink_to_fit() override; +public: + runner_mixin(const fits_sink_mixin& e, std::size_t width, std::size_t height, std::size_t depth); + runner_mixin(const fits_sink_mixin& e, std::size_t width, std::size_t height, std::size_t depth, const camera_source_base& s); + runner_mixin(const fits_sink_mixin& e, std::size_t width, std::size_t height, std::size_t depth, const scan_source_base& s); + runner_mixin(const fits_sink_mixin& e, std::size_t width, std::size_t height, std::size_t depth, const fits_source_base& s); + template<class Source> + runner_mixin(const fits_sink_mixin& e, const Source& s); + + bool full() const { + return frame_num_ == image_.depth(); + } +}; + +template<class T, std::size_t Align> +void fits_sink_mixin::runner_mixin<T, Align>::append_frame(buffer_view<T, Align> b) { + image_.write_frame(b, frame_num_); + // if not thrown, then + ++frame_num_; +} + +template<class T, std::size_t Align> +void fits_sink_mixin::runner_mixin<T, Align>::shrink_to_fit() { + const auto width = image_.width(); + const auto height = image_.height(); + + image_.resize(width, height, frame_num_); +} + +template<class T, std::size_t Align> +fits_sink_mixin::runner_mixin<T, Align>::runner_mixin(const fits_sink_mixin& e, std::size_t width, std::size_t height, std::size_t depth): + runner_mixin_base(e, sizeof(T) * width * height * depth + 28800), + image_(get_fits().template create_image<T>(width, height, depth)) {} + +template<class T, std::size_t Align> +fits_sink_mixin::runner_mixin<T, Align>::runner_mixin(const fits_sink_mixin& e, std::size_t width, std::size_t height, std::size_t depth, const camera_source_base& source): + runner_mixin(e, width, height, depth) { + + /* Key updating after image creation */ + auto& f = get_fits(); + const auto& s = source.settings(); + f.update_key("EXPTIME", std::chrono::duration_cast<std::chrono::duration<float>>(s.exposure_time()).count()); + f.update_key("FRATE", s.frame_rate()); + f.update_key("XBINNING", std::get<0>(s.binning())); + f.update_key("YBINNING", std::get<1>(s.binning())); +} + +template<class T, std::size_t Align> +fits_sink_mixin::runner_mixin<T, Align>::runner_mixin(const fits_sink_mixin& e, std::size_t width, std::size_t height, std::size_t depth, const scan_source_base& s): + runner_mixin(e, width, height, depth, static_cast<const camera_source_base&>(s)) { + + /* Key updating after image creation */ + auto& f = get_fits(); + f.update_key("CARSPEED", s.load_speed()); + f.update_key("CARMASK", s.mask()); + f.update_key("CARSPE", s.steps_per_exposure()); +} + +template<class T, std::size_t Align> +fits_sink_mixin::runner_mixin<T, Align>::runner_mixin(const fits_sink_mixin& e, std::size_t width, std::size_t height, std::size_t depth, const fits_source_base&): + runner_mixin(e, width, height, depth) { +} + +template<class T, std::size_t Align> +template<class Source> +fits_sink_mixin::runner_mixin<T, Align>::runner_mixin(const fits_sink_mixin& e, const Source& s): + runner_mixin(e, s.width(), s.height(), s.depth(), s) { +} + +#endif // _EXECUTOR_FITS_SINK_MIXIN_H
View file
domecam-0.1.6.obscpio/include/executor/gain.h
Added
@@ -0,0 +1,29 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _EXECUTOR_GAIN_H +#define _EXECUTOR_GAIN_H + +#include <executorfwd.h> +#include <executor/fits_sink_mixin.h> + + +class gain_executor: + public camera_executor, + private fits_sink_mixin { +private: + const double exp_scale_; + const camera::exposure_time_type exp_bias_; + + struct runner; +public: + gain_executor(const std::string& target_uri, std::size_t pairs_number, double exp_scale, double exp_bias); + + virtual executor_result run(camera& c) const override; + virtual ~gain_executor() override = default; +}; + +#endif // _EXECUTOR_GAIN_H
View file
domecam-0.1.6.obscpio/include/executor/grad.h
Added
@@ -0,0 +1,84 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _EXECUTOR_GRAD_H +#define _EXECUTOR_GRAD_H + +#include <executorfwd.h> +#include <executor/fits_sink_mixin.h> +#include <executor/pipeline_mixin.h> +#include <pipeline.h> + + +class grad_executor_base: + protected fits_sink_mixin, + protected pipeline_mixin { +protected: + template<class SourceMixin> class runner; +public: + explicit grad_executor_base(const std::string& target_uri); +}; + +template<class SourceMixin> +class grad_executor_base::runner: + public SourceMixin, + protected pipeline_mixin::runner_mixin< + gradient_pipeline<typename SourceMixin::source_type::value_type>>, + protected fits_sink_mixin::runner_mixin< + typename gradient_pipeline<typename SourceMixin::source_type::value_type>::result_type::value_type, + gradient_pipeline<typename SourceMixin::source_type::value_type>::result_type::align> { +private: + using source_mixin = SourceMixin; + using source_type = typename source_mixin::source_type; + using pipeline_type = gradient_pipeline<typename source_type::value_type>; + +public: + template<class Executor, class... Args> + runner(const Executor& e, Args&&... args): + source_mixin(e, std::forward<Args>(args)...), + pipeline_mixin::runner_mixin<pipeline_type>( + this->source().width(), + this->source().height()), + fits_sink_mixin::runner_mixin< + typename pipeline_type::result_type::value_type, + pipeline_type::result_type::align>(e, this->source()) {} + + void run(); +}; + +template<class SourceMixin> +void grad_executor_base::runner<SourceMixin>::run() { + this->for_each([this] (const typename source_type::result_type& b) { + this->append_frame(this->apply(b)); + }); + + this->commit(); +} + +class grad_executor: + public camera_executor, + public grad_executor_base { +public: + grad_executor(const std::string& target_uri, std::size_t frames_number); + + virtual executor_result run(camera& c) const override; + virtual ~grad_executor() override = default; +}; + +class grad_replay_executor: + public replay_executor, + public grad_executor_base { +private: + template<class T> + using runner_type = runner<source_mixin<T>>; +public: + explicit grad_replay_executor(const std::string& target_uri); + + virtual executor_result run(const fits::variant_image& vi) const override; + virtual ~grad_replay_executor() override = default; +}; + +#endif // _EXECUTOR_GRAD_H
View file
domecam-0.1.6.obscpio/include/executor/mean_pupil_mask.h
Added
@@ -0,0 +1,110 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _EXECUTOR_MEAN_PUPIL_MASK_H +#define _EXECUTOR_MEAN_PUPIL_MASK_H + +#include <random> + +#include <executorfwd.h> +#include <executor/fits_sink_mixin.h> +#include <executor/pipeline_mixin.h> +#include <pipeline.h> + + +class mean_pupil_mask_executor_base: + protected fits_sink_mixin, + protected pipeline_mixin { +protected: + template<class SourceMixin> class runner; +public: + explicit mean_pupil_mask_executor_base(const std::string& target_uri, std::size_t samples); +private: + const std::size_t samples_; +}; + +template<class SourceMixin> +class mean_pupil_mask_executor_base::runner: + public SourceMixin, + protected pipeline_mixin::runner_mixin< + mean_pipeline<typename SourceMixin::source_type::value_type>>, + protected pipeline_mixin::runner_mixin< + pupil_mask_pipeline< + typename mean_pipeline<typename SourceMixin::source_type::value_type>::value_type>>, + protected fits_sink_mixin::runner_mixin< + typename pupil_mask_pipeline< + typename mean_pipeline<typename SourceMixin::source_type::value_type>::value_type>::buffer_type::value_type, + pupil_mask_pipeline< + typename mean_pipeline<typename SourceMixin::source_type::value_type>::value_type>::buffer_type::align> { +private: + using source_mixin = SourceMixin; + using source_type = typename source_mixin::source_type; + using mean_pipeline_type = mean_pipeline<typename source_type::value_type>; + using pupil_mask_pipeline_type = pupil_mask_pipeline<typename mean_pipeline_type::value_type>; + +public: + template<class Executor, class... Args> + runner(const Executor& e, Args&&... args): + source_mixin(e, std::forward<Args>(args)...), + pipeline_mixin::runner_mixin<mean_pipeline_type>( + this->source().width(), + this->source().height()), + pipeline_mixin::runner_mixin<pupil_mask_pipeline_type>( + this->source().width(), + this->source().height(), e.samples_), + fits_sink_mixin::runner_mixin< + typename pupil_mask_pipeline_type::buffer_type::value_type, + pupil_mask_pipeline_type::buffer_type::align>(e, this->source().width(), this->source().height(), 1, this->source()), + accum_buffer_{this->source().width() * this->source().height(), + pipeline_mixin::runner_mixin<mean_pipeline_type>::pipeline_.make_allocator()} { + + accum_buffer_.clear(); + } + + void run(); + +private: + typename mean_pipeline_type::buffer_type accum_buffer_; + std::mt19937 rng_; +}; + +template<class SourceMixin> +void mean_pupil_mask_executor_base::runner<SourceMixin>::run() { + this->for_each([this] (const typename source_type::result_type& b) { + pipeline_mixin::runner_mixin<mean_pipeline_type>::apply(accum_buffer_, + static_cast<buffer_view<typename source_type::value_type, mean_pipeline_type::mempool_type::align>>(b)); + }); + + const auto& r = pipeline_mixin::runner_mixin<pupil_mask_pipeline_type>::apply(accum_buffer_, rng_, nullptr); + this->append_frame(r.second); + this->commit(); +} + + +class mean_pupil_mask_executor: + public camera_executor, + public mean_pupil_mask_executor_base { +public: + mean_pupil_mask_executor(const std::string& target_uri, std::size_t frames_number, std::size_t samples); + + virtual executor_result run(camera& c) const override; + virtual ~mean_pupil_mask_executor() override = default; +}; + +class mean_pupil_mask_replay_executor: + public replay_executor, + public mean_pupil_mask_executor_base { +private: + template<class T> + using runner_type = runner<source_mixin<T>>; +public: + explicit mean_pupil_mask_replay_executor(const std::string& target_uri, std::size_t samples); + + virtual executor_result run(const fits::variant_image& vi) const override; + virtual ~mean_pupil_mask_replay_executor() override = default; +}; + +#endif // _EXECUTOR_MEAN_PUPIL_MASK_H
View file
domecam-0.1.6.obscpio/include/executor/mean_raw.h
Added
@@ -0,0 +1,106 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _EXECUTOR_MEAN_H +#define _EXECUTOR_MEAN_H + +#include <executorfwd.h> +#include <executor/fits_sink_mixin.h> +#include <executor/pipeline_mixin.h> +#include <pipeline.h> + + +class mean_raw_executor_base: + protected fits_sink_mixin, + protected pipeline_mixin { +protected: + template<class SourceMixin> class runner; +public: + explicit mean_raw_executor_base(const std::string& target_uri); +}; + +template<class SourceMixin> +class mean_raw_executor_base::runner: + public SourceMixin, + protected pipeline_mixin::runner_mixin< + mean_pipeline<typename SourceMixin::source_type::value_type>>, + protected fits_sink_mixin::runner_mixin< + typename mean_pipeline<typename SourceMixin::source_type::value_type>::result_type::value_type, + mean_pipeline<typename SourceMixin::source_type::value_type>::result_type::align> { +private: + using source_mixin = SourceMixin; + using source_type = typename source_mixin::source_type; + using pipeline_type = mean_pipeline<typename source_type::value_type>; + +protected: + void run_once(const typename source_type::result_type& b); + +public: + template<class Executor, class... Args> + runner(const Executor& e, Args&&... args): + source_mixin(e, std::forward<Args>(args)...), + pipeline_mixin::runner_mixin<pipeline_type>( + this->source().width(), + this->source().height()), + fits_sink_mixin::runner_mixin< + typename pipeline_type::result_type::value_type, + pipeline_type::result_type::align>(e, this->source().width(), this->source().height(), 1, this->source()), + accum_buffer_{this->source().width() * this->source().height(), this->pipeline_.make_allocator()}, + count_{0} { + + accum_buffer_.clear(); + } + + void run(); + +private: + typename pipeline_type::buffer_type accum_buffer_; + std::size_t count_; +}; + +template<class SourceMixin> +void mean_raw_executor_base::runner<SourceMixin>::run_once(const typename source_type::result_type& b) { + this->apply(accum_buffer_, + static_cast<buffer_view<typename source_type::value_type, pipeline_type::mempool_type::align>>(b)); + ++count_; +} + +template<class SourceMixin> +void mean_raw_executor_base::runner<SourceMixin>::run() { + this->for_each([this] (const typename source_type::result_type& b) { + this->run_once(b); + }); + + this->apply(accum_buffer_, static_cast<typename pipeline_type::buffer_type::value_type>(count_)); + this->append_frame(accum_buffer_); + this->commit(); +} + + +class mean_raw_executor: + public camera_executor, + public mean_raw_executor_base { +public: + mean_raw_executor(const std::string& target_uri, std::size_t frames_number); + + virtual executor_result run(camera& c) const override; + virtual ~mean_raw_executor() override = default; +}; + +class mean_raw_replay_executor: + public replay_executor, + public mean_raw_executor_base { +private: + template<class T> + using runner_type = runner<source_mixin<T>>; +public: + explicit mean_raw_replay_executor(const std::string& target_uri); + + virtual executor_result run(const fits::variant_image& vi) const override; + virtual ~mean_raw_replay_executor() override = default; +}; + +#endif // _EXECUTOR_MEAN_H
View file
domecam-0.1.6.obscpio/include/executor/pipeline_mixin.h
Added
@@ -0,0 +1,36 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _EXECUTOR_PIPELINE_MIXIN_H +#define _EXECUTOR_PIPELINE_MIXIN_H + +#include <utility> + + +class pipeline_mixin { +protected: + template<class Pipeline> class runner_mixin; +public: +}; + +template<class Pipeline> +class pipeline_mixin::runner_mixin { + typedef Pipeline pipeline_type; +protected: + pipeline_type pipeline_; +public: + template<class... Args> + runner_mixin(Args&&... args): + pipeline_(std::forward<Args>(args)...) {} + + template<class... Args> + auto apply(Args&&... args) const -> + decltype(pipeline_(std::forward<Args>(args)...)) { + return pipeline_(std::forward<Args>(args)...); + } +}; + +#endif // _EXECUTOR_PIPELINE_MIXIN_H
View file
domecam-0.1.6.obscpio/include/executor/pupil.h
Added
@@ -0,0 +1,179 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _EXECUTOR_PUPIL_H +#define _EXECUTOR_PUPIL_H + +#include <ostream> +#include <random> +#include <type_traits> + +#include <boost/accumulators/accumulators.hpp> +#include <boost/accumulators/statistics/error_of_mean.hpp> +#include <boost/accumulators/statistics/moment.hpp> +#include <boost/accumulators/statistics/min.hpp> +#include <boost/accumulators/statistics/max.hpp> +#include <boost/accumulators/statistics/stats.hpp> + +#include <executorfwd.h> +#include <executor/pipeline_mixin.h> +#include <pipeline.h> +#include <pupil_geom.h> + + +class pupil_executor_base: + protected pipeline_mixin { +public: + struct runner_result; + class runner_base; +protected: + struct pupil_mixin_base; + template<class SourceMixin> class runner; +public: + pupil_executor_base(std::size_t samples, bool force_initial); +protected: + const std::size_t samples_; + const bool force_initial_; +}; + +struct pupil_executor_base::runner_result { + using value_type = float; + + std::array<value_type, 2> center_mean; + value_type radius_mean; + std::array<value_type, 2> center_error; + value_type radius_error; + std::array<value_type, 2> drift; +}; + +std::ostream& operator<<(std::ostream& stm, const pupil_executor_base::runner_result& s); + +struct pupil_executor_base::pupil_mixin_base { + std::size_t frame_num_; + pupil_geometry geometry_; + std::mt19937 rng_; + + pupil_mixin_base(): + frame_num_{0}, + geometry_{} {} + + template<class T, class V = typename std::enable_if<!buffer_traits<T>::has_position>::type> + static inline std::size_t frame_num(const T&, std::size_t n) noexcept { + return n; + } + + template<class T, class V = typename std::enable_if<buffer_traits<T>::has_position>::type> + static inline auto frame_num(const T& b, std::size_t) noexcept -> + decltype(buffer_traits<T>::position(b)) { + return buffer_traits<T>::position(b); + } +}; + +class pupil_executor_base::runner_base: + protected pupil_mixin_base { +public: + using value_type = pupil_executor_base::runner_result::value_type; + + runner_base(); +protected: + void run_once(const pupil_geometry& geometry, value_type position); + runner_result statistics() const noexcept; +private: + boost::accumulators::accumulator_set<value_type, boost::accumulators::stats< + boost::accumulators::tag::error_of<boost::accumulators::tag::mean>> + > pupil_x_acc_, pupil_y_acc_; + boost::accumulators::accumulator_set<value_type, boost::accumulators::stats< + boost::accumulators::tag::error_of<boost::accumulators::tag::mean>> + > pupil_radius_acc_; + boost::accumulators::accumulator_set<value_type, boost::accumulators::stats< + boost::accumulators::tag::mean, + boost::accumulators::tag::moment<2>, + boost::accumulators::tag::min, + boost::accumulators::tag::max> + > position_acc_; + boost::accumulators::accumulator_set<value_type, boost::accumulators::stats< + boost::accumulators::tag::mean> + > pupil_x_position_acc_, pupil_y_position_acc_; +}; + +template<class SourceMixin> +class pupil_executor_base::runner: + public SourceMixin, + public runner_base, + protected pipeline_mixin::runner_mixin< + pupil_pipeline<typename SourceMixin::source_type::value_type>> { +private: + using source_mixin = SourceMixin; + using source_type = typename source_mixin::source_type; + using pipeline_type = pupil_pipeline<typename source_type::value_type>; + using value_type = typename pipeline_type::value_type; +public: + template<class Executor, class... Args> + runner(const Executor& e, Args&&... args): + source_mixin(e, std::forward<Args>(args)...), + runner_base{}, + pipeline_mixin::runner_mixin<pipeline_type>( + this->source().width(), + this->source().height(), + e.samples_), + e_{e} {} + + void run_once(const typename source_type::result_type& b); + runner_result run(); +private: + const pupil_executor_base& e_; +}; + +template<class SourceMixin> +void pupil_executor_base::runner<SourceMixin>::run_once(const typename source_type::result_type& b) { + const auto& init_geometry = (e_.force_initial_ || frame_num_ == 0 ? nullptr : &geometry_); + + std::tie(geometry_, std::ignore) = this->apply(b, rng_, init_geometry); + const auto& position = frame_num(b, frame_num_++); + + runner_base::run_once(geometry_, position); +} + +template<class SourceMixin> +pupil_executor_base::runner_result pupil_executor_base::runner<SourceMixin>::run() { + this->for_each([this] (const typename source_type::result_type& b) { this->run_once(b); }); + + return statistics(); +} + +class pupil_executor: + public camera_executor, + public pupil_executor_base { +public: + pupil_executor(std::size_t frames_number, std::size_t samples, bool force_initial); + + virtual executor_result run(camera& c) const override; + virtual ~pupil_executor() override = default; +}; + +class pupil_scan_executor: + public scan_executor, + public pupil_executor_base { +public: + pupil_scan_executor(std::size_t frames_number, std::size_t samples, bool force_initial); + + virtual executor_result run(camera& c) const override; + virtual ~pupil_scan_executor() override = default; +}; + +class pupil_replay_executor: + public replay_executor, + public pupil_executor_base { +private: + template<class T> using runner_type = runner<source_mixin<T>>; +public: + pupil_replay_executor(std::size_t samples, bool force_initial); + + virtual executor_result run(const fits::variant_image& vi) const override; + virtual ~pupil_replay_executor() override = default; +}; + +#endif // _EXECUTOR_PUPIL_H
View file
domecam-0.1.6.obscpio/include/executor/pupil_mask.h
Added
@@ -0,0 +1,94 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _EXECUTOR_PUPIL_MASK_H +#define _EXECUTOR_PUPIL_MASK_H + +#include <executorfwd.h> +#include <executor/fits_sink_mixin.h> +#include <executor/pipeline_mixin.h> +#include <executor/pupil.h> + + +class pupil_mask_executor_base: + protected fits_sink_mixin, + public pupil_executor_base { +protected: + template<class T> class runner; +public: + pupil_mask_executor_base(const std::string& target_uri, std::size_t samples, bool force_initial); +}; + +template<class SourceMixin> +class pupil_mask_executor_base::runner: + public SourceMixin, + protected pupil_mixin_base, + protected pipeline_mixin::runner_mixin< + pupil_mask_pipeline<typename SourceMixin::source_type::value_type>>, + protected fits_sink_mixin::runner_mixin< + typename pupil_mask_pipeline<typename SourceMixin::source_type::value_type>::buffer_type::value_type, + pupil_mask_pipeline<typename SourceMixin::source_type::value_type>::buffer_type::align> { +private: + using source_mixin = SourceMixin; + using source_type = typename source_mixin::source_type; + using pipeline_type = pupil_mask_pipeline<typename source_type::value_type>; + using value_type = typename pipeline_type::value_type; +public: + template<class Executor, class... Args> + runner(const Executor& e, Args&&... args): + source_mixin(e, std::forward<Args>(args)...), + pupil_mixin_base{}, + pipeline_mixin::runner_mixin<pipeline_type>( + this->source().width(), + this->source().height(), + e.samples_), + fits_sink_mixin::runner_mixin< + typename pipeline_type::buffer_type::value_type, + pipeline_type::buffer_type::align>(e, this->source()), + e_{e} {} + + void run_once(const typename source_type::result_type& b); + void run(); +private: + const pupil_mask_executor_base& e_; +}; + +template<class SourceMixin> +void pupil_mask_executor_base::runner<SourceMixin>::run_once(const typename source_type::result_type& b) { + const auto& init_geometry = (e_.force_initial_ || frame_num_ == 0 ? nullptr : &geometry_); + const auto& r = this->apply(b, rng_, init_geometry); + geometry_ = r.first; + this->append_frame(r.second); +} + +template<class SourceMixin> +void pupil_mask_executor_base::runner<SourceMixin>::run() { + this->for_each([this] (const typename source_type::result_type& b) { this->run_once(b); }); +} + +class pupil_mask_executor: + public camera_executor, + public pupil_mask_executor_base { +public: + pupil_mask_executor(const std::string& target_uri, std::size_t frames_number, std::size_t samples, bool force_initial); + + virtual executor_result run(camera& c) const override; + virtual ~pupil_mask_executor() override = default; +}; + +class pupil_mask_replay_executor: + public replay_executor, + public pupil_mask_executor_base { +private: + template<class T> using runner_type = runner<source_mixin<T>>; +public: + pupil_mask_replay_executor(const std::string& target_uri, std::size_t samples, bool force_initial); + + virtual executor_result run(const fits::variant_image& vi) const override; + virtual ~pupil_mask_replay_executor() override = default; +}; + +#endif // _EXECUTOR_PUPIL_MASK_H
View file
domecam-0.1.6.obscpio/include/executor/raw.h
Added
@@ -0,0 +1,72 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _EXECUTOR_RAW_H +#define _EXECUTOR_RAW_H + +#include <executorfwd.h> +#include <executor/fits_sink_mixin.h> + + +class raw_executor_base: + protected fits_sink_mixin { +protected: + template<class SourceMixin> class runner; +public: + explicit raw_executor_base(const std::string& target_uri); +}; + +template<class SourceMixin> +class raw_executor_base::runner: + public SourceMixin, + private fits_sink_mixin::runner_mixin< + typename SourceMixin::source_type::value_type, + SourceMixin::source_type::align> { +private: + using source_mixin = SourceMixin; + using source_type = typename source_mixin::source_type; + +public: + template<class Executor, class... Args> + runner(const Executor& e, Args&&... args): + source_mixin(e, std::forward<Args>(args)...), + fits_sink_mixin::runner_mixin< + typename source_type::value_type, + source_type::align>(e, this->source()) {} + + void run(); +}; + +template<class SourceMixin> +void raw_executor_base::runner<SourceMixin>::run() { + this->for_each([this] (const typename source_type::result_type& b) { + this->append_frame(b); + }); + + this->commit(); +} + +class raw_executor: + public camera_executor, + public raw_executor_base { +public: + raw_executor(const std::string& target_uri, std::size_t frames_number); + + virtual executor_result run(camera& c) const override; + virtual ~raw_executor() override = default; +}; + +class raw_scan_executor: + public scan_executor, + public raw_executor_base { +public: + raw_scan_executor(const std::string& target_uri, std::size_t frames_number); + + virtual executor_result run(camera& c) const override; + virtual ~raw_scan_executor() override = default; +}; + +#endif // _EXECUTOR_RAW_H
View file
domecam-0.1.6.obscpio/include/executor/source_mixin.h
Added
@@ -0,0 +1,34 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _EXECUTOR_SOURCE_MIXIN_H +#define _EXECUTOR_SOURCE_MIXIN_H + + +template<class Source> +class source_mixin { +public: + using source_type = Source; + + template<class... Args> + source_mixin(Args&&... args): + source_(std::forward<Args&&>(args)...) { + } + + const source_type& source() const { + return source_; + } +protected: + template<class F> + void for_each(F&& f) { + source_.for_each(std::forward<F&&>(f)); + } + +private: + source_type source_; +}; + +#endif // _EXECUTOR_SOURCE_MIXIN_H
View file
domecam-0.1.6.obscpio/include/executor_result.h
Added
@@ -0,0 +1,81 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _EXECUTOR_RESULT_H +#define _EXECUTOR_RESULT_H + +#include <memory> + + +class executor_result { +private: + class abstract_impl { + public: + virtual ~abstract_impl() = 0; + virtual std::ostream& print(std::ostream& stm) const = 0; + }; + + template<class T> class wrap_impl; +public: + executor_result(); + template<class T> executor_result(const T&); + template<class T> executor_result(T&&); + + executor_result(const executor_result&) = delete; + executor_result(executor_result&&) = default; + executor_result& operator=(const executor_result&) = delete; + executor_result& operator=(executor_result&&) = default; + ~executor_result() = default; + + std::ostream& print(std::ostream& stm) const; +private: + std::unique_ptr<abstract_impl> impl_; +}; + +template<class T> +class executor_result::wrap_impl final: + public executor_result::abstract_impl { +public: + wrap_impl(const T&); + wrap_impl(T&&); + + wrap_impl(const wrap_impl<T>&) = delete; + wrap_impl(wrap_impl<T>&&) = delete; + wrap_impl<T>& operator=(const wrap_impl<T>&) = delete; + wrap_impl<T>& operator=(wrap_impl<T>&&) = delete; + ~wrap_impl() override final = default; + + std::ostream& print(std::ostream& stm) const override final; +private: + T data_; +}; + +template<class T> +executor_result::wrap_impl<T>::wrap_impl(const T& data): + data_{data} {} + +template<class T> +executor_result::wrap_impl<T>::wrap_impl(T&& data): + data_{std::move(data)} {} + +template<class T> +std::ostream& executor_result::wrap_impl<T>::print(std::ostream& stm) const { + return stm << data_; +} + +template<class T> +executor_result::executor_result(const T& data): + impl_{new wrap_impl<T>{data}} {} + +template<class T> +executor_result::executor_result(T&& data): + impl_{new wrap_impl<T>{std::move(data)}} {} + +inline std::ostream& operator<<(std::ostream& stm, const executor_result& r) { + return r.print(stm); +} + +#endif // _EXECUTOR_RESULT_H
View file
domecam-0.1.6.obscpio/include/executorfwd.h
Added
@@ -0,0 +1,150 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _EXECUTORFWD_H +#define _EXECUTORFWD_H + +#include <camera.h> +#include <carriage.h> +#include <executor_result.h> +#include <executor/source_mixin.h> +#include <fits.h> +#include <mempool.h> +#include <source.h> + + +class executor { +public: + executor(); + + virtual executor_result run(camera& c) const = 0; + virtual ~executor() = 0; +}; + + +class camera_executor: + public executor { +protected: + class source_mixin; +public: + explicit camera_executor(std::size_t frames_number); + + virtual executor_result run(camera& c) const = 0; + virtual ~camera_executor() = 0; +protected: + const std::size_t frames_number_; +}; + +class camera_executor::source_mixin: + public ::source_mixin<camera_source<std::uint16_t>> { +public: + source_mixin(const camera_executor& e, camera& c); +}; + + +class carriage_executor: + public executor { +protected: + class runner; +public: + carriage_executor(); + + virtual executor_result run(camera& c) const override; + virtual executor_result run(abstract_carriage& c) const; + virtual ~carriage_executor() = default; +}; + +class carriage_executor::runner { +public: + runner(abstract_carriage& c); + + virtual void run(); +protected: + abstract_carriage& c_; +}; + + +class scan_executor: + public camera_executor { +protected: + class source_mixin; +public: + explicit scan_executor(std::size_t frames_number); + + virtual executor_result run(camera& c) const = 0; + virtual ~scan_executor() = 0; +}; + +class scan_executor::source_mixin: + public ::source_mixin<scan_source<std::uint16_t>> { +public: + source_mixin(const scan_executor& e, camera& c); +}; + + +class replay_executor { +private: + class mempool_mixin; + +protected: + template<class T> class source_mixin; + + template<template<class> class Runner, class Executor, class ResultType = void> class runner_visitor; +public: + virtual executor_result run(const fits::variant_image& vi) const = 0; + virtual ~replay_executor() = 0; +}; + +class replay_executor::mempool_mixin { +public: + using mempool_type = mempool<32>; + + explicit mempool_mixin(std::size_t size); + + template<class T> + typename mempool_type::allocator<T> make_allocator() { + return pool_.make_allocator<T>(); + } +private: + mempool_type pool_; +}; + +template<class T> +class replay_executor::source_mixin: + private mempool_mixin, + public ::source_mixin<fits_source< + T, mempool_mixin::mempool_type::align, + typename mempool_mixin::mempool_type::template allocator<T>>> { +private: + using value_type = T; + using allocator_type = typename mempool_type::template allocator<value_type>; + +public: + source_mixin(const replay_executor& e, const fits::image<T>& image); +}; + +template<class T> +replay_executor::source_mixin<T>::source_mixin(const replay_executor& e, const fits::image<T>& image): + mempool_mixin(sizeof(T) * image.width() * image.height()), + ::source_mixin<fits_source<value_type, mempool_type::align, allocator_type>>(image, make_allocator<T>()) {} + +template<template<class> class Runner, class Executor, class ResultType> +class replay_executor::runner_visitor { +private: + const Executor& e_; +public: + typedef ResultType result_type; + + explicit runner_visitor(const Executor& e): e_(e) {} + + template<class T> result_type operator()(const fits::image<T>& im) const { + Runner<T> r{e_, im}; + + return r.run(); + }; +}; + +#endif // _EXECUTORFWD_H
View file
domecam-0.1.5.obscpio/include/fits.h -> domecam-0.1.6.obscpio/include/fits.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _FITS_H #define _FITS_H
View file
domecam-0.1.5.obscpio/include/grad.h -> domecam-0.1.6.obscpio/include/grad.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _GRAD_H #define _GRAD_H
View file
domecam-0.1.5.obscpio/include/histogram.h -> domecam-0.1.6.obscpio/include/histogram.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _HISTOGRAM_H #define _HISTOGRAM_H
View file
domecam-0.1.5.obscpio/include/io.h -> domecam-0.1.6.obscpio/include/io.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _IO_H #define _IO_H @@ -138,7 +144,7 @@ return std::unique_ptr<executor>{new grad_executor(pt.get<std::string>("filename"), pt.get<std::size_t>("frames_number"))}; } else if (type == "binary") { return std::unique_ptr<executor>{new binary_executor(pt.get<std::string>("filename"), pt.get<std::size_t>("frames_number"))}; - } else if (type == "pupil" || type == "edge" || type == "pupil_scan" || type == "edge_scan") { + } else if (type == "pupil" || type == "edge" || type == "pupil_scan" || type == "edge_scan" || type == "pupil_mask") { const auto frames_number = pt.get<std::size_t>("frames_number"); const auto samples_number = pt.get<std::size_t>("samples_number", 60); const auto force_initial = pt.get<bool>("force_initial", true); @@ -155,7 +161,13 @@ } else if (type == "edge_scan") { return std::unique_ptr<executor>{new edge_scan_executor(frames_number, samples_number, force_initial, loss_factor)}; } + } else if (type == "pupil_mask") { + return std::unique_ptr<executor>{new pupil_mask_executor(pt.get<std::string>("filename"), frames_number, samples_number, force_initial)}; + } else if (type == "mean_pupil_mask") { + return std::unique_ptr<executor>{new mean_pupil_mask_executor(pt.get<std::string>("filename"), frames_number, samples_number)}; } + } else if (type == "mean_raw") { + return std::unique_ptr<executor>{new mean_raw_executor(pt.get<std::string>("filename"), pt.get<std::size_t>("frames_number"))}; } else if (type == "gain") { return std::unique_ptr<executor>{new gain_executor(pt.get<std::string>("filename"), pt.get<std::size_t>("pairs_number"), pt.get<float>("exposure_step_scale"), pt.get<float>("exposure_step_bias"))}; } else if (type == "carriage_run") {
View file
domecam-0.1.5.obscpio/include/iofwd.h -> domecam-0.1.6.obscpio/include/iofwd.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _IOFWD_H #define _IOFWD_H
View file
domecam-0.1.5.obscpio/include/mempool.h -> domecam-0.1.6.obscpio/include/mempool.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _MEMPOOL_H #define _MEMPOOL_H
View file
domecam-0.1.5.obscpio/include/otsu.h -> domecam-0.1.6.obscpio/include/otsu.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _OTSU_H #define _OTSU_H
View file
domecam-0.1.5.obscpio/include/partial_shuffle.h -> domecam-0.1.6.obscpio/include/partial_shuffle.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _PARTIAL_SHUFFLE_H #define _PARTIAL_SHUFFLE_H
View file
domecam-0.1.5.obscpio/include/pipeline.h -> domecam-0.1.6.obscpio/include/pipeline.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _PIPELINE_H #define _PIPELINE_H @@ -11,6 +17,7 @@ #include <convert.h> #include <edge_entropy.h> #include <edge_select.h> +#include <element_wise.h> #include <error.h> #include <grad.h> #include <mempool.h> @@ -33,11 +40,18 @@ pipeline_base& operator=(const pipeline_base&) = default; pipeline_base& operator=(pipeline_base&&) = default; ~pipeline_base() = default; + + inline allocator_type make_allocator(); protected: mempool_type pool_; convert_type convert_; }; +template<class InpT, class T> +typename pipeline_base<InpT, T>::allocator_type pipeline_base<InpT, T>::make_allocator() { + return pool_.make_allocator<value_type>(); +} + template<class InpT> class gradient_pipeline: public pipeline_base<InpT, float> { @@ -173,7 +187,7 @@ using typename pipeline_base<InpT, float>::allocator_type; using typename pupil_pipeline<InpT>::geometry_type; private: - using edge_select_type = edge_select<value_type, mempool_type::align, allocator_type>; + using edge_select_type = edge_select<value_type, value_type, mempool_type::align, allocator_type>; using edge_entropy_op_type = edge_entropy_op<value_type, mempool_type::align, allocator_type>; protected: using pipeline_base<InpT, float>::pool_; @@ -213,4 +227,99 @@ return std::make_pair(edge_entropy, geometry); } +template<class InpT> +class pupil_mask_pipeline: + public pupil_pipeline<InpT> { +public: + using typename pipeline_base<InpT, float>::value_type; + using typename pipeline_base<InpT, float>::mempool_type; + using typename pipeline_base<InpT, float>::allocator_type; + using typename pupil_pipeline<InpT>::geometry_type; +private: + using edge_select_type = edge_select<value_type, value_type, mempool_type::align, allocator_type>; + using binary_type = binary_mask<value_type, mempool_type::align, typename mempool_type::template allocator<std::uint8_t>>; +protected: + using pipeline_base<InpT, float>::pool_; + using pipeline_base<InpT, float>::convert_; + using pupil_pipeline<InpT>::grad_; +public: + using buffer_type = typename binary_type::buffer_type; + using result_type = std::pair<geometry_type, buffer_type>; +protected: + edge_select_type edge_select_; + binary_type pupil_mask_; + value_type dx_; + value_type dy_; +public: + pupil_mask_pipeline(std::size_t width, std::size_t height, std::size_t samples): + pupil_pipeline<InpT>(width, height, samples), + edge_select_(grad_.width(), grad_.height(), typename edge_select_type::allocator_type(pool_)), + pupil_mask_(width, height, typename binary_type::allocator_type(pool_)), + dx_(static_cast<value_type>(width - grad_.width()) / static_cast<value_type>(2)), + dy_(static_cast<value_type>(height - grad_.height()) / static_cast<value_type>(2)) { + } + + template<class URBG> + inline result_type operator() (buffer_view<InpT, mempool_type::align> b, URBG&& random_generator, const geometry_type* init_geometry = nullptr) const; + + inline std::size_t width() const { return pupil_mask_.width(); } + inline std::size_t height() const { return pupil_mask_.height(); } +}; + +template<class InpT> +template<class URBG> +typename pupil_mask_pipeline<InpT>::result_type +pupil_mask_pipeline<InpT>::operator() (buffer_view<InpT, mempool_type::align> b, URBG&& random_generator, const geometry_type* init_geometry) const { + const auto& c = convert_(b); + auto p = pupil_pipeline<InpT>::operator()(b, std::forward<URBG>(random_generator), init_geometry); + auto& geometry = p.first; + + const std::array<value_type, 2> center{ + std::get<0>(geometry.edge.center) + dx_, + std::get<1>(geometry.edge.center) + dy_}; + const std::pair<value_type, value_type> radius{0.0f, geometry.edge.radius * 1.05f}; + const auto& edge_flux = edge_select_(c, center, radius); + + return std::make_pair(std::move(geometry), pupil_mask_(c, pupil_mask_.estimate_threshold(edge_flux))); +} + +template<class InpT> +class mean_pipeline: + public pipeline_base<InpT, float> { +public: + using typename pipeline_base<InpT, float>::value_type; + using typename pipeline_base<InpT, float>::mempool_type; + using typename pipeline_base<InpT, float>::allocator_type; +private: + using plus_op_type = element_plus<value_type, mempool_type::align>; + using divides_op_type = element_divides<value_type, mempool_type::align>; +protected: + using pipeline_base<InpT, float>::convert_; +public: + using buffer_type = buffer<value_type, mempool_type::align, allocator_type>; + using result_type = buffer_type; +private: + plus_op_type plus_op_; + divides_op_type divides_op_; +public: + mean_pipeline(std::size_t width, std::size_t height): + pipeline_base<InpT, float>(mempool_type(width * height * sizeof(float), 2)) {} + + inline result_type& operator() (buffer_type& accum, buffer_view<InpT, mempool_type::align> b) const; + inline result_type& operator() (buffer_type& accum, value_type count) const; +}; + +template<class InpT> +typename mean_pipeline<InpT>::result_type& +mean_pipeline<InpT>::operator() (buffer_type& accum, buffer_view<InpT, mempool_type::align> b) const { + const auto& c = convert_(b); + return plus_op_(accum, c); +} + +template<class InpT> +typename mean_pipeline<InpT>::result_type& +mean_pipeline<InpT>::operator() (buffer_type& accum, value_type count) const { + return divides_op_(accum, count); +} + #endif // _PIPELINE_H
View file
domecam-0.1.5.obscpio/include/pupil_geom.h -> domecam-0.1.6.obscpio/include/pupil_geom.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _PUPIL_GEOM_H #define _PUPIL_GEOM_H
View file
domecam-0.1.5.obscpio/include/quadfit.h -> domecam-0.1.6.obscpio/include/quadfit.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _QUADFIT_H #define _QUADFIT_H
View file
domecam-0.1.5.obscpio/include/relative_difference.h -> domecam-0.1.6.obscpio/include/relative_difference.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _RELATIVE_DIFFERENCE_H #define _RELATIVE_DIFFERENCE_H
View file
domecam-0.1.5.obscpio/include/serial_io.h -> domecam-0.1.6.obscpio/include/serial_io.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _SERIAL_IO_H #define _SERIAL_IO_H
View file
domecam-0.1.5.obscpio/include/source.h -> domecam-0.1.6.obscpio/include/source.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _SOURCE_H #define _SOURCE_H @@ -176,10 +182,21 @@ } }; +class fits_source_base { +protected: + const fits::image_base& image_; +public: + explicit fits_source_base(const fits::image_base& image); + + std::size_t width() const { return image_.width(); } + std::size_t height() const { return image_.height(); } + std::size_t depth() const { return image_.depth(); } +}; + template<class T, std::size_t Align, class Allocator> -class fits_source { +class fits_source: + public fits_source_base { private: - const fits::image<T>& image_; Allocator alloc_; public: using value_type = T; @@ -187,18 +204,16 @@ constexpr static const std::size_t align = Align; fits_source(const fits::image<T>& image, const Allocator& alloc): - image_(image), + fits_source_base(image), alloc_(alloc) { } - std::size_t width() const { return image_.width(); } - std::size_t height() const { return image_.height(); } - std::size_t depth() const { return image_.depth(); } - template<class F> void for_each(F sink) { + const auto& im = static_cast<const fits::image<T>&>(image_); + for (std::size_t i = 0; i < depth(); i++) { - sink(image_.template read_frame<Align>(i, alloc_)); + sink(im.template read_frame<Align>(i, alloc_)); } } };
View file
domecam-0.1.5.obscpio/include/stream.h -> domecam-0.1.6.obscpio/include/stream.h
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #ifndef _STREAM_H #define _STREAM_H
View file
domecam-0.1.5.obscpio/src/application.cpp -> domecam-0.1.6.obscpio/src/application.cpp
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #include <iostream> #include <sstream> #include <exception>
View file
domecam-0.1.5.obscpio/src/camera.cpp -> domecam-0.1.6.obscpio/src/camera.cpp
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #include <camera.h> #include <stream.h>
View file
domecam-0.1.5.obscpio/src/camera_settings.cpp -> domecam-0.1.6.obscpio/src/camera_settings.cpp
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #include <camera_settings.h> namespace {
View file
domecam-0.1.5.obscpio/src/carriage.cpp -> domecam-0.1.6.obscpio/src/carriage.cpp
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #include <carriage.h> #include <thread> @@ -136,8 +142,6 @@ explicit nullary_command(const serialized_type& command); nullary_command(const nullary_command&) = default; nullary_command(nullary_command&&) = default; - nullary_command& operator=(const nullary_command&) = default; - nullary_command& operator=(nullary_command&&) = default; virtual ~nullary_command() = 0; result_type parse_reply(const serialized_type& command) const;
View file
domecam-0.1.5.obscpio/src/curl.cpp -> domecam-0.1.6.obscpio/src/curl.cpp
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #include <curl.h> libcurl_error::libcurl_error(CURLcode code):
View file
domecam-0.1.5.obscpio/src/device.cpp -> domecam-0.1.6.obscpio/src/device.cpp
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #include <device.h> #include <stream.h>
View file
domecam-0.1.5.obscpio/src/error.cpp -> domecam-0.1.6.obscpio/src/error.cpp
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #include <sstream> #include <error.h>
View file
domecam-0.1.6.obscpio/src/executor
Added
+(directory)
View file
domecam-0.1.6.obscpio/src/executor/binary.cpp
Added
@@ -0,0 +1,36 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#include <executor/binary.h> + + +binary_executor_base::binary_executor_base(const std::string& target_uri): + fits_sink_mixin(target_uri), + pipeline_mixin() {} + + +binary_executor::binary_executor(const std::string& target_uri, std::size_t frames_number): + camera_executor(frames_number), + binary_executor_base(target_uri) {} + +executor_result binary_executor::run(camera& c) const { + runner<source_mixin> r{*this, c}; + + r.run(); + + return {}; +} + + +binary_replay_executor::binary_replay_executor(const std::string& target_uri): + replay_executor(), + binary_executor_base(target_uri) {} + +executor_result binary_replay_executor::run(const fits::variant_image& vi) const { + vi.apply(runner_visitor<runner_type, binary_replay_executor>{*this}); + + return {}; +}
View file
domecam-0.1.6.obscpio/src/executor/carriage.cpp
Added
@@ -0,0 +1,79 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#include <executor/carriage.h> + + +struct carriage_track_executor::runner: + public carriage_executor::runner { + + const carriage_track_executor& executor_; + + runner(const carriage_track_executor& e, abstract_carriage& c); + + void run(); +}; + +carriage_track_executor::runner::runner(const carriage_track_executor& e, abstract_carriage& c): + carriage_executor::runner(c), + executor_{e} { +} + +void carriage_track_executor::runner::run() { + c_.axis(executor_.axis_); + c_.sync_track(executor_.direction_); +} + + +carriage_track_executor::carriage_track_executor(std::uint16_t axis, abstract_carriage::direction d): + carriage_executor(), + axis_{axis}, + direction_{d} { +} + +executor_result carriage_track_executor::run(abstract_carriage& c) const { + runner r(*this, c); + + r.run(); + + return {}; +} + + +struct carriage_run_executor::runner: + public carriage_executor::runner { + + const carriage_run_executor& executor_; + + runner(const carriage_run_executor& e, abstract_carriage& c); + + void run(); +}; + +carriage_run_executor::runner::runner(const carriage_run_executor& e, abstract_carriage& c): + carriage_executor::runner(c), + executor_(e) { +} + +void carriage_run_executor::runner::run() { + c_.axis(executor_.axis_); + c_.sync_run_absolute(executor_.absolute_pos_); +} + + +carriage_run_executor::carriage_run_executor(std::uint16_t axis, std::int16_t absolute_pos): + carriage_executor(), + axis_(axis), + absolute_pos_(absolute_pos) { +} + +executor_result carriage_run_executor::run(abstract_carriage& c) const { + runner r(*this, c); + + r.run(); + + return {}; +}
View file
domecam-0.1.6.obscpio/src/executor/edge.cpp
Added
@@ -0,0 +1,101 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#include <boost/accumulators/accumulators.hpp> +#include <boost/accumulators/statistics/error_of_mean.hpp> +#include <boost/accumulators/statistics/stats.hpp> + +#include <executor/edge.h> +#include <executor/pipeline_mixin.h> +#include <pipeline.h> +#include <quadfit.h> + + +std::ostream& operator<<(std::ostream& stm, const edge_executor_base::runner_result& s) { + stm << "Statistics:" << std::endl + << "Mean: " << s.entropy_mean << std::endl + << "Error: " << s.entropy_error << std::endl + << "Focus: " << s.focus << std::endl; + + return stm; +} + + +edge_executor_base::runner_base::runner_base(const edge_executor_base& e, std::size_t depth): + e_{e} { + + positions_.reserve(depth); + entropies_.reserve(depth); +} + +void edge_executor_base::runner_base::run_once(value_type edge_entropy, value_type position) { + positions_.push_back(position); + entropies_.push_back(edge_entropy); + + std::cout << position << " " << edge_entropy << std::endl; +} + +edge_executor_base::runner_result edge_executor_base::runner_base::statistics() const noexcept { + assert(positions_.size() == entropies_.size()); + assert(positions_.size() > 0); + + boost::accumulators::accumulator_set<value_type, + boost::accumulators::stats<boost::accumulators::tag::error_of<boost::accumulators::tag::mean>> + > entropy_acc; + entropy_acc = std::for_each(entropies_.cbegin(), entropies_.cend(), entropy_acc); + + const auto entropy_min = std::min_element(entropies_.cbegin(), entropies_.cend()); + const auto entropy_lim = *entropy_min * (e_.loss_factor_ + static_cast<value_type>(1)); + auto elower_bound = std::lower_bound(entropies_.cbegin(), entropy_min, entropy_lim, std::greater<value_type>()); + elower_bound = (elower_bound == entropies_.cbegin() ? elower_bound : std::prev(elower_bound)); + const auto eupper_bound = std::upper_bound(entropy_min, entropies_.cend(), entropy_lim); + const auto lower_bound = positions_.cbegin() + std::distance(entropies_.cbegin(), elower_bound); + const auto upper_bound = positions_.cbegin() + std::distance(entropies_.cbegin(), eupper_bound); + + const auto fit = quadfit(lower_bound, upper_bound, elower_bound, eupper_bound); + const auto mpos = -static_cast<value_type>(0.5) * fit[1] / fit[2]; + + return { + boost::accumulators::mean(entropy_acc), + boost::accumulators::error_of<boost::accumulators::tag::mean>(entropy_acc), + mpos}; +} + + +edge_executor_base::edge_executor_base(std::size_t samples, bool force_initial, float loss_factor): + pupil_executor_base(samples, force_initial), + loss_factor_(loss_factor) {} + + +edge_executor::edge_executor(std::size_t frames_number, std::size_t samples, bool force_initial, float loss_factor): + camera_executor(frames_number), + edge_executor_base(samples, force_initial, loss_factor) {} + +executor_result edge_executor::run(camera& c) const { + runner<source_mixin> r{*this, c}; + + return r.run(); +} + + +edge_scan_executor::edge_scan_executor(std::size_t frames_number, std::size_t samples, bool force_initial, float loss_factor): + scan_executor(frames_number), + edge_executor_base(samples, force_initial, loss_factor) {} + +executor_result edge_scan_executor::run(camera& c) const { + runner<source_mixin> r{*this, c}; + + return r.run(); +} + + +edge_replay_executor::edge_replay_executor(std::size_t samples, bool force_initial, float loss_factor): + replay_executor(), + edge_executor_base(samples, force_initial, loss_factor) {} + +executor_result edge_replay_executor::run(const fits::variant_image& vi) const { + return vi.apply(runner_visitor<runner_type, edge_replay_executor, runner_result>{*this}); +}
View file
domecam-0.1.6.obscpio/src/executor/fits_sink_mixin.cpp
Added
@@ -0,0 +1,102 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#include <memory> + +#include <executor/fits_sink_mixin.h> + + +struct fits_sink_mixin::runner_mixin_base::impl_file: + public impl { + + impl_file(const fits_sink_mixin& e); + ~impl_file() override = default; + + fits& get_fits() override { return fits_; } + +private: + fits fits_; +}; + +struct fits_sink_mixin::runner_mixin_base::impl_http: + public impl { + + impl_http(const fits_sink_mixin& e, std::size_t capacity); + ~impl_http() override = default; + + void commit() override; + fits& get_fits() override { return fits_; } + + static std::size_t read_callback(char *buffer, std::size_t size, std::size_t nitems, void *userdata); +private: + inmem_fits fits_; + curl curl_; + std::size_t offset_; +}; + +fits_sink_mixin::runner_mixin_base::impl::~impl() = default; + +fits_sink_mixin::runner_mixin_base::impl_file::impl_file(const fits_sink_mixin& e): + fits_{fits::create(e.target_uri())} { +} + +fits_sink_mixin::runner_mixin_base::impl_http::impl_http(const fits_sink_mixin& e, std::size_t capacity): + fits_{capacity}, + curl_{}, + offset_{0} { + + curl_.setopt(CURLOPT_URL, e.target_uri().c_str()); + curl_.setopt(CURLOPT_UPLOAD, 1L); + + curl_.append_header("Content-Type: image/fits"); +} + +void fits_sink_mixin::runner_mixin_base::impl_http::commit() { + offset_ = 0; + + curl_.setopt(CURLOPT_READFUNCTION, &impl_http::read_callback); + curl_.setopt(CURLOPT_READDATA, (void*)this); + curl_.setopt(CURLOPT_INFILESIZE_LARGE, static_cast<curl_off_t>(fits_.size())); + + curl_.perform(); + + const auto speed = curl_.getinfo<curl_off_t>(CURLINFO_SPEED_UPLOAD_T); + + std::cerr << "Upload speed: " << speed << " bytes/sec" << std::endl; +} + +std::size_t fits_sink_mixin::runner_mixin_base::impl_http::read_callback(char *buffer, std::size_t size, std::size_t nitems, void *userdata) { + auto that = reinterpret_cast<impl_http*>(userdata); + + const std::size_t required_size = size * nitems; + const std::size_t left_size = that->fits_.size() - that->offset_; + const auto& actual_size = std::min(required_size, left_size); + + std::memcpy(buffer, static_cast<const char*>(that->fits_.data()) + that->offset_, actual_size); + that->offset_ += actual_size; + + return actual_size; +} + +fits_sink_mixin::runner_mixin_base::runner_mixin_base(const fits_sink_mixin& e, std::size_t capacity): + pimpl_{e.target_uri().find("http") == 0 ? + std::unique_ptr<impl>(new impl_http(e, capacity)) : + std::unique_ptr<impl>(new impl_file(e))}, + frame_num_{0} { +} + +void fits_sink_mixin::runner_mixin_base::flush() { + get_fits().flush(); +} + +void fits_sink_mixin::runner_mixin_base::commit() { + shrink_to_fit(); + flush(); + pimpl_->commit(); +} + +fits_sink_mixin::fits_sink_mixin(const std::string& target_uri): + target_uri_{target_uri} {}
View file
domecam-0.1.6.obscpio/src/executor/gain.cpp
Added
@@ -0,0 +1,68 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#include <executor/gain.h> + + +struct gain_executor::runner: + private fits_sink_mixin::runner_mixin<std::uint16_t, camera_source<std::uint16_t>::align> { + + const gain_executor& e_; + camera& c_; + + runner(const gain_executor& e, camera& c): + fits_sink_mixin::runner_mixin<std::uint16_t, camera_source<std::uint16_t>::align>(e, std::get<0>(c.region().size), std::get<1>(c.region().size), e.frames_number_), + e_(e), + c_(c) { + + auto& f = get_fits(); + f.update_key("EXPTIME", std::chrono::duration_cast<std::chrono::duration<float>>(c.exposure_time()).count()); + f.update_key("EXPBIAS", std::chrono::duration_cast<std::chrono::duration<float>>(e_.exp_bias_).count()); + f.update_key("EXPSCALE", e_.exp_scale_); + const auto binning = c.binning(); + f.update_key("XBINNING", std::get<0>(binning)); + f.update_key("YBINNING", std::get<1>(binning)); + } + + void run(); +}; + +void gain_executor::runner::run() { + typedef camera_source<std::uint16_t> source_type; + + assert(image_.depth() % 2 == 0); + + while (!full()) { + const auto exposure = c_.exposure_time(); + + { + camera_source<std::uint16_t> source{c_, 2, std::chrono::seconds(5), 4}; + + source.for_each([this] (const source_type::result_type& b) { + append_frame(b); + }); + } + + const auto new_exposure = exposure * e_.exp_scale_ + e_.exp_bias_; + c_.exposure_time(new_exposure); + } + + commit(); +} + +gain_executor::gain_executor(const std::string& target_uri, std::size_t pairs_number, double exp_scale, double exp_bias): + camera_executor(pairs_number * 2), + fits_sink_mixin(target_uri), + exp_scale_(exp_scale), + exp_bias_(exp_bias) {} + +executor_result gain_executor::run(camera& c) const { + runner r{*this, c}; + + r.run(); + + return {}; +}
View file
domecam-0.1.6.obscpio/src/executor/grad.cpp
Added
@@ -0,0 +1,36 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#include <executor/grad.h> + + +grad_executor_base::grad_executor_base(const std::string& target_uri): + fits_sink_mixin(target_uri), + pipeline_mixin() {} + + +grad_executor::grad_executor(const std::string& target_uri, std::size_t frames_number): + camera_executor(frames_number), + grad_executor_base(target_uri) {} + +executor_result grad_executor::run(camera& c) const { + runner<source_mixin> r{*this, c}; + + r.run(); + + return {}; +} + + +grad_replay_executor::grad_replay_executor(const std::string& target_uri): + replay_executor(), + grad_executor_base(target_uri) {} + +executor_result grad_replay_executor::run(const fits::variant_image& vi) const { + vi.apply(runner_visitor<runner_type, grad_replay_executor>{*this}); + + return {}; +}
View file
domecam-0.1.6.obscpio/src/executor/mean_pupil_mask.cpp
Added
@@ -0,0 +1,37 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#include <executor/mean_pupil_mask.h> + + +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(), + samples_(samples_number) {} + + +mean_pupil_mask_executor::mean_pupil_mask_executor(const std::string& target_uri, std::size_t frames_number, std::size_t samples_number): + camera_executor(frames_number), + mean_pupil_mask_executor_base(target_uri, samples_number) {} + +executor_result mean_pupil_mask_executor::run(camera& c) const { + runner<source_mixin> r{*this, c}; + + r.run(); + + return {}; +} + + +mean_pupil_mask_replay_executor::mean_pupil_mask_replay_executor(const std::string& target_uri, std::size_t samples_number): + replay_executor(), + mean_pupil_mask_executor_base(target_uri, samples_number) {} + +executor_result mean_pupil_mask_replay_executor::run(const fits::variant_image& vi) const { + vi.apply(runner_visitor<runner_type, mean_pupil_mask_replay_executor>{*this}); + + return {}; +}
View file
domecam-0.1.6.obscpio/src/executor/mean_raw.cpp
Added
@@ -0,0 +1,36 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#include <executor/mean_raw.h> + + +mean_raw_executor_base::mean_raw_executor_base(const std::string& target_uri): + fits_sink_mixin(target_uri), + pipeline_mixin() {} + + +mean_raw_executor::mean_raw_executor(const std::string& target_uri, std::size_t frames_number): + camera_executor(frames_number), + mean_raw_executor_base(target_uri) {} + +executor_result mean_raw_executor::run(camera& c) const { + runner<source_mixin> r{*this, c}; + + r.run(); + + return {}; +} + + +mean_raw_replay_executor::mean_raw_replay_executor(const std::string& target_uri): + replay_executor(), + mean_raw_executor_base(target_uri) {} + +executor_result mean_raw_replay_executor::run(const fits::variant_image& vi) const { + vi.apply(runner_visitor<runner_type, mean_raw_replay_executor>{*this}); + + return {}; +}
View file
domecam-0.1.6.obscpio/src/executor/pupil.cpp
Added
@@ -0,0 +1,91 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#include <executor/pupil.h> + + +std::ostream& operator<<(std::ostream& stm, const pupil_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 + << "Error: " << std::get<0>(s.center_error) << " " << std::get<1>(s.center_error) << " " << s.radius_error << std::endl + << "Drift: " << std::get<0>(s.drift) << " " << std::get<1>(s.drift) << std::endl; + + return stm; +} + + +pupil_executor_base::runner_base::runner_base(): + pupil_executor_base::pupil_mixin_base() {} + +void pupil_executor_base::runner_base::run_once(const pupil_geometry& geometry, value_type position) { + const auto& pupil_x = std::get<0>(geometry.edge.center); + const auto& pupil_y = std::get<1>(geometry.edge.center); + const auto& pupil_radius = geometry.edge.radius; + + pupil_x_acc_(pupil_x); + pupil_y_acc_(pupil_y); + pupil_radius_acc_(pupil_radius); + position_acc_(position); + pupil_x_position_acc_(position * pupil_x); + pupil_y_position_acc_(position * pupil_y); + + std::cout << position << " " << geometry.ratio << " " << pupil_x << " " << pupil_y << " " << pupil_radius << " " << std::sqrt(geometry.edge.variance) << std::endl; +} + +pupil_executor_base::runner_result pupil_executor_base::runner_base::statistics() const noexcept { + const auto mean_x = boost::accumulators::mean(pupil_x_acc_); + const auto mean_y = boost::accumulators::mean(pupil_y_acc_); + const auto mean_p = boost::accumulators::mean(position_acc_); + const auto dp = boost::accumulators::max(position_acc_) - boost::accumulators::min(position_acc_); + const auto mean_xp = boost::accumulators::mean(pupil_x_position_acc_); + const auto mean_yp = boost::accumulators::mean(pupil_y_position_acc_); + const auto slope_den = boost::accumulators::moment<2>(position_acc_) - mean_p * mean_p; + const auto dx = dp * (mean_xp - mean_x * mean_p) / slope_den; + const auto dy = dp * (mean_yp - mean_y * mean_p) / slope_den; + + return { + {mean_x, mean_y}, + boost::accumulators::mean(pupil_radius_acc_), + {boost::accumulators::error_of<boost::accumulators::tag::mean>(pupil_x_acc_), boost::accumulators::error_of<boost::accumulators::tag::mean>(pupil_y_acc_)}, + boost::accumulators::error_of<boost::accumulators::tag::mean>(pupil_radius_acc_), + {dx, dy}}; +} + +pupil_executor_base::pupil_executor_base(std::size_t samples, bool force_initial): + samples_(samples), + force_initial_(force_initial) {} + + +pupil_executor::pupil_executor(std::size_t frames_number, std::size_t samples, bool force_initial): + camera_executor(frames_number), + pupil_executor_base(samples, force_initial) {} + +executor_result pupil_executor::run(camera& c) const { + runner<source_mixin> r{*this, c}; + + return r.run(); +} + + +pupil_scan_executor::pupil_scan_executor(std::size_t frames_number, std::size_t samples, bool force_initial): + scan_executor(frames_number), + pupil_executor_base(samples, force_initial) {} + +executor_result pupil_scan_executor::run(camera& c) const { + runner<source_mixin> r{*this, c}; + + return r.run(); +} + + +pupil_replay_executor::pupil_replay_executor(std::size_t samples, bool force_initial): + replay_executor(), + pupil_executor_base(samples, force_initial) {} + +executor_result pupil_replay_executor::run(const fits::variant_image& vi) const { + return vi.apply(runner_visitor<runner_type, pupil_replay_executor, runner_result>{*this}); +}
View file
domecam-0.1.6.obscpio/src/executor/pupil_mask.cpp
Added
@@ -0,0 +1,38 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#include <executor/pipeline_mixin.h> +#include <executor/pupil_mask.h> +#include <pipeline.h> + + +pupil_mask_executor_base::pupil_mask_executor_base(const std::string& target_uri, std::size_t samples, bool force_initial): + fits_sink_mixin(target_uri), + pupil_executor_base(samples, force_initial) {} + + +pupil_mask_executor::pupil_mask_executor(const std::string& target_uri, std::size_t frames_number, std::size_t samples, bool force_initial): + camera_executor(frames_number), + pupil_mask_executor_base(target_uri, samples, force_initial) {} + +executor_result pupil_mask_executor::run(camera& c) const { + runner<source_mixin> r{*this, c}; + + r.run(); + + return {}; +} + + +pupil_mask_replay_executor::pupil_mask_replay_executor(const std::string& target_uri, std::size_t samples, bool force_initial): + replay_executor(), + pupil_mask_executor_base(target_uri, samples, force_initial) {} + +executor_result pupil_mask_replay_executor::run(const fits::variant_image& vi) const { + vi.apply(runner_visitor<runner_type, pupil_mask_replay_executor>{*this}); + + return {}; +}
View file
domecam-0.1.6.obscpio/src/executor/raw.cpp
Added
@@ -0,0 +1,37 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#include <executor/raw.h> + + +raw_executor_base::raw_executor_base(const std::string& target_uri): + fits_sink_mixin(target_uri) { +} + +raw_executor::raw_executor(const std::string& target_uri, std::size_t frames_number): + camera_executor(frames_number), + raw_executor_base(target_uri) {} + +executor_result raw_executor::run(camera& c) const { + runner<source_mixin> r{*this, c}; + + r.run(); + + return {}; +} + + +raw_scan_executor::raw_scan_executor(const std::string& target_uri, std::size_t frames_number): + scan_executor(frames_number), + raw_executor_base(target_uri) {} + +executor_result raw_scan_executor::run(camera& c) const { + runner<source_mixin> r{*this, c}; + + r.run(); + + return {}; +}
View file
domecam-0.1.6.obscpio/src/executor_result.cpp
Added
@@ -0,0 +1,19 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#include <ostream> + +#include <executor_result.h> + + +executor_result::abstract_impl::~abstract_impl() = default; + +executor_result::executor_result(): + impl_{nullptr} {} + +std::ostream& executor_result::print(std::ostream& stm) const { + return impl_ ? impl_->print(stm) : stm; +}
View file
domecam-0.1.6.obscpio/src/executorfwd.cpp
Added
@@ -0,0 +1,83 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#include <iomanip> +#include <iostream> + +#include <boost/io/ios_state.hpp> + +#include <executorfwd.h> + + +executor::executor() = default; + +executor::~executor() = default; + + +camera_executor::source_mixin::source_mixin(const camera_executor& e, camera& c): + ::source_mixin<source_type>(c, e.frames_number_, std::chrono::seconds(5), 20) {} + + +camera_executor::camera_executor(std::size_t frames_number): + executor(), + frames_number_(frames_number) {} + +camera_executor::~camera_executor() = default; + + +carriage_executor::runner::runner(abstract_carriage& c): + c_(c) { + + c_.reset(); + c_.current(carriage::current_level::minimal); + + const boost::io::ios_flags_saver ifs(std::cerr); + + std::cerr << "Ident: 0x" << std::hex << std::setfill('0') << std::setw(4) << c_.ident() << std::endl; + std::cerr << "Status: 0x" << std::hex << std::setfill('0') << std::setw(4) << static_cast<std::uint16_t>(c_.status()) << std::endl; + std::cerr << "Absolute: " << std::dec << c_.absolute() << std::endl; + std::cerr << "Relative: " << std::dec << c_.relative() << std::endl; + std::cerr << "Speed: " << std::dec << c_.speed() << std::endl; + std::cerr << "Accel: " << std::dec << c_.accel() << std::endl; + std::cerr << "Path: " << std::dec << c_.path() << std::endl; + std::cerr << "Sync mask: 0x" << std::hex << c_.sync_mask() << std::endl; + std::cerr << "User data: 0x" << std::hex << c_.user_data() << std::endl; +} + +void carriage_executor::runner::run() { +} + +carriage_executor::carriage_executor(): + executor() {} + +executor_result carriage_executor::run(camera& c) const { + carriage carriage_{c}; + + return run(carriage_); +} + +executor_result carriage_executor::run(abstract_carriage& c) const { + runner r{c}; + + r.run(); + + return {}; +} + + +scan_executor::source_mixin::source_mixin(const scan_executor& e, camera& c): + ::source_mixin<source_type>(c, e.frames_number_, std::chrono::seconds(5), 20) {} + +scan_executor::scan_executor(std::size_t frames_number): + camera_executor(frames_number) {} + +scan_executor::~scan_executor() = default; + + +replay_executor::mempool_mixin::mempool_mixin(std::size_t size): + pool_{size, 1} {} + +replay_executor::~replay_executor() = default;
View file
domecam-0.1.5.obscpio/src/fits.cpp -> domecam-0.1.6.obscpio/src/fits.cpp
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #include <cstddef> #include <string>
View file
domecam-0.1.5.obscpio/src/mempool.cpp -> domecam-0.1.6.obscpio/src/mempool.cpp
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #include <mempool.h> #include <algorithm>
View file
domecam-0.1.5.obscpio/src/serial_io.cpp -> domecam-0.1.6.obscpio/src/serial_io.cpp
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #include <serial_io.h> serial_io::error::error(const std::string& what):
View file
domecam-0.1.5.obscpio/src/source.cpp -> domecam-0.1.6.obscpio/src/source.cpp
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #include <algorithm> #include <chrono> #include <limits> @@ -70,4 +76,8 @@ assert(size > 0); } +fits_source_base::fits_source_base(const fits::image_base& image): + image_(image) { +} + constexpr std::uint16_t scan_source_base::max_range_;
View file
domecam-0.1.5.obscpio/src/stream.cpp -> domecam-0.1.6.obscpio/src/stream.cpp
Changed
@@ -1,3 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + #include <stream.h>
View file
domecam-0.1.5.obscpio/test/buffer.cpp -> domecam-0.1.6.obscpio/test/buffer.cpp
Changed
@@ -1,3 +1,9 @@ +/* + * 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>
View file
domecam-0.1.6.obscpio/test/edge_select.cpp
Added
@@ -0,0 +1,356 @@ +/* + * 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 <edge_select.h> + +namespace CPPUNIT_NS { + +template<class U, std::size_t Align> +struct assertion_traits<buffer_view<U, Align>> { + static bool equal(const buffer_view<U, Align> x, const buffer_view<U, Align> y) { + if (x.size() != y.size()) + return false; + + return std::equal(x.data(), x.data() + x.size(), y.data()); + } + + static std::string toString(const buffer_view<U, Align> x) { + std::ostringstream oss; + oss << "[" << x.size() << "]"; + for (std::size_t i = 0; i < x.size(); ++i) { + oss << " " << x.data()[i]; + } + return oss.str(); + } +}; + +} // CPPUNIT_NS + +class test_edge_select_suite: public CppUnit::TestCase { +CPPUNIT_TEST_SUITE(test_edge_select_suite); +CPPUNIT_TEST(test_edge_select1); +CPPUNIT_TEST(test_edge_select2); +CPPUNIT_TEST(test_edge_select3); +CPPUNIT_TEST(test_edge_select4); +CPPUNIT_TEST(test_edge_select5); +CPPUNIT_TEST(test_edge_select6); +CPPUNIT_TEST(test_edge_select7); +CPPUNIT_TEST(test_edge_select8); +CPPUNIT_TEST(test_edge_select9); +CPPUNIT_TEST(test_edge_select10); +CPPUNIT_TEST(test_edge_select11); +CPPUNIT_TEST(test_edge_select12); +CPPUNIT_TEST(test_edge_select13); +CPPUNIT_TEST(test_edge_select14); +CPPUNIT_TEST(test_edge_select15); +CPPUNIT_TEST(test_edge_select16); +CPPUNIT_TEST(test_edge_select17); +CPPUNIT_TEST(test_edge_select18); +CPPUNIT_TEST_SUITE_END(); + +void test_edge_select1() { + constexpr std::size_t width = 5; + constexpr std::size_t height = 5; + std::array<std::size_t, width * height> arr; + std::iota(arr.begin(), arr.end(), static_cast<std::size_t>(0)); + buffer_view<std::size_t> bv(arr.data(), arr.size()); + std::array<std::size_t, 13> exp{2, 6, 7, 8, 10, 11, 12, 13, 14, 16, 17, 18, 22}; + buffer_view<std::size_t> be(exp.data(), exp.size()); + edge_select<std::size_t> e(width, height); + const std::array<std::size_t, 2> center{2, 2}; + const std::pair<std::size_t, std::size_t> radius{0, 2}; + const auto res = e(bv, center, radius); + + CPPUNIT_ASSERT_EQUAL(be, res.as_view()); +} + +void test_edge_select2() { + constexpr std::size_t width = 5; + constexpr std::size_t height = 5; + std::array<std::size_t, width * height> arr; + std::iota(arr.begin(), arr.end(), static_cast<std::size_t>(0)); + buffer_view<std::size_t> bv(arr.data(), arr.size()); + std::array<std::size_t, 12> exp{2, 6, 7, 8, 10, 11, 13, 14, 16, 17, 18, 22}; + buffer_view<std::size_t> be(exp.data(), exp.size()); + edge_select<std::size_t> e(width, height); + const std::array<std::size_t, 2> center{2, 2}; + const std::pair<std::size_t, std::size_t> radius{1, 2}; + const auto res = e(bv, center, radius); + + CPPUNIT_ASSERT_EQUAL(be, res.as_view()); +} + +void test_edge_select3() { + constexpr std::size_t width = 5; + constexpr std::size_t height = 5; + std::array<std::size_t, width * height> arr; + std::iota(arr.begin(), arr.end(), static_cast<std::size_t>(0)); + buffer_view<std::size_t> bv(arr.data(), arr.size()); + std::array<std::size_t, 4> exp{2, 10, 14, 22}; + buffer_view<std::size_t> be(exp.data(), exp.size()); + edge_select<std::size_t> e(width, height); + const std::array<std::size_t, 2> center{2, 2}; + const std::pair<std::size_t, std::size_t> radius{2, 2}; + const auto res = e(bv, center, radius); + + CPPUNIT_ASSERT_EQUAL(be, res.as_view()); +} + +void test_edge_select4() { + constexpr std::size_t width = 5; + constexpr std::size_t height = 5; + std::array<std::size_t, width * height> arr; + std::iota(arr.begin(), arr.end(), static_cast<std::size_t>(0)); + buffer_view<std::size_t> bv(arr.data(), arr.size()); + std::array<std::size_t, 6> exp{0, 1, 2, 5, 6, 10}; + buffer_view<std::size_t> be(exp.data(), exp.size()); + edge_select<std::size_t> e(width, height); + const std::array<std::size_t, 2> center{0, 0}; + const std::pair<std::size_t, std::size_t> radius{0, 2}; + const auto res = e(bv, center, radius); + + CPPUNIT_ASSERT_EQUAL(be, res.as_view()); +} + +void test_edge_select5() { + constexpr std::size_t width = 5; + constexpr std::size_t height = 5; + std::array<std::size_t, width * height> arr; + std::iota(arr.begin(), arr.end(), static_cast<std::size_t>(0)); + buffer_view<std::size_t> bv(arr.data(), arr.size()); + std::array<std::size_t, 6> exp{2, 3, 4, 8, 9, 14}; + buffer_view<std::size_t> be(exp.data(), exp.size()); + edge_select<std::size_t> e(width, height); + const std::array<std::size_t, 2> center{4, 0}; + const std::pair<std::size_t, std::size_t> radius{0, 2}; + const auto res = e(bv, center, radius); + + CPPUNIT_ASSERT_EQUAL(be, res.as_view()); +} + +void test_edge_select6() { + constexpr std::size_t width = 5; + constexpr std::size_t height = 5; + std::array<std::size_t, width * height> arr; + std::iota(arr.begin(), arr.end(), static_cast<std::size_t>(0)); + buffer_view<std::size_t> bv(arr.data(), arr.size()); + std::array<std::size_t, 6> exp{10, 15, 16, 20, 21, 22}; + buffer_view<std::size_t> be(exp.data(), exp.size()); + edge_select<std::size_t> e(width, height); + const std::array<std::size_t, 2> center{0, 4}; + const std::pair<std::size_t, std::size_t> radius{0, 2}; + const auto res = e(bv, center, radius); + + CPPUNIT_ASSERT_EQUAL(be, res.as_view()); +} + +void test_edge_select7() { + constexpr std::size_t width = 5; + constexpr std::size_t height = 5; + std::array<std::size_t, width * height> arr; + std::iota(arr.begin(), arr.end(), static_cast<std::size_t>(0)); + buffer_view<std::size_t> bv(arr.data(), arr.size()); + std::array<std::size_t, 6> exp{14, 18, 19, 22, 23, 24}; + buffer_view<std::size_t> be(exp.data(), exp.size()); + edge_select<std::size_t> e(width, height); + const std::array<std::size_t, 2> center{4, 4}; + const std::pair<std::size_t, std::size_t> radius{0, 2}; + const auto res = e(bv, center, radius); + + CPPUNIT_ASSERT_EQUAL(be, res.as_view()); +} + +void test_edge_select8() { + constexpr std::size_t width = 5; + constexpr std::size_t height = 5; + std::array<std::size_t, width * height> arr; + std::iota(arr.begin(), arr.end(), static_cast<std::size_t>(0)); + buffer_view<std::size_t> bv(arr.data(), arr.size()); + std::array<std::size_t, 8> exp{12, 16, 17, 18, 20, 21, 23, 24}; + buffer_view<std::size_t> be(exp.data(), exp.size()); + edge_select<std::size_t> e(width, height); + const std::array<std::size_t, 2> center{2, 4}; + const std::pair<std::size_t, std::size_t> radius{1, 2}; + const auto res = e(bv, center, radius); + + CPPUNIT_ASSERT_EQUAL(be, res.as_view()); +} + +void test_edge_select9() { + constexpr std::size_t width = 5; + constexpr std::size_t height = 5; + std::array<std::size_t, width * height> arr; + std::iota(arr.begin(), arr.end(), static_cast<std::size_t>(0)); + buffer_view<std::size_t> bv(arr.data(), arr.size()); + std::array<std::size_t, 8> exp{0, 1, 3, 4, 6, 7, 8, 12}; + buffer_view<std::size_t> be(exp.data(), exp.size());
View file
domecam-0.1.5.obscpio/test/mempool.cpp -> domecam-0.1.6.obscpio/test/mempool.cpp
Changed
@@ -1,3 +1,9 @@ +/* + * 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>
View file
domecam.obsinfo
Changed
@@ -1,3 +1,3 @@ name: domecam -version: 0.1.5 -mtime: 1643791168 +version: 0.1.6 +mtime: 1649788803
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
.