/robowaifu/ - DIY Robot Wives

Advancing robotics to a point where anime catgrill meidos in tiny miniskirts are a reality!

We are back. - TOR has been restored.

Canary update coming soon.

Max message length: 6144

Drag files to upload or
click here to select them

Maximum 5 files / Maximum size: 20.00 MB

More

(used to delete files and postings)


“I think and think for months and years. Ninety-nine times, the conclusion is false. The hundredth time I am right. ” -t. Albert Einstein


Open file (81.61 KB 601x203 python_logo.png)
Open file (15.21 KB 1600x1600 c++_logo.png)
Robowaifu Programming & Learning Thread Greentext anon 04/22/2025 (Tue) 13:37:49 No.37647
A thread for links, examples, & discussion for software development & instruction; primarily intended to focus on Python & C++. Obviously the endgoal being the crafting of quality code & systems for our robowaifus. --- > threads-related: ( >>19777 ) ( >>12 ) ( >>159 ) ( >>14409 ) ( >>18749 ) ( >>4969 ) ( >>86 ) ( >>128 ) >=== -add'l crosslink
Edited last time by Chobitsu on 04/23/2025 (Wed) 10:39:27.
I'll just leave this here for now. <---> C++26 Senders/Receivers [1] Async : Partition Sorting, & OpenCV -based [2] Image Processing Examples https://accu.org/journals/overload/33/185/teodorescu/ --- 1. https://en.cppreference.com/w/cpp/execution 2. https://docs.opencv.org/4.11.0/
>image-processing related cv::Mat tr_apply_mask(const cv::Mat& img_main, const cv::Mat& img_mask); cv::Mat tr_blur(const cv::Mat& src, int size); cv::Mat tr_to_grayscale(const cv::Mat& src); cv::Mat tr_adaptthresh(const cv::Mat& img, int block_size, int diff); cv::Mat tr_reducecolors(const cv::Mat& img, int num_colors) cv::Mat tr_oilpainting(const cv::Mat& img, int size, int dyn_ratio); auto tr_cartoonify(const cv::Mat& src, int blur_size, int num_colors, int block_size, int diff); auto error_to_exception(); std::vector<std::byte> read_file(const fs::directory_entry& file); void write_file(const char* filename, const std::vector<unsigned char>& data); exec::task<int> process_files(const char* in_folder_name, const char* out_folder_name, int blur_size, int num_colors, int block_size, int diff); int main() { auto everything = process_files("data", "out", blur_size, num_colors, block_size, diff); auto [processed] = stdexec::sync_wait(std::move(everything)).value(); printf("Processed images: %d\n", processed); return 0; } auto tr_cartoonify(const cv::Mat& src, int blur_size, int num_colors, int block_size, int diff) { auto sched = exec::get_system_scheduler(); stdexec::sender auto snd = stdexec::when_all( stdexec::transfer_just(sched, src) | error_to_exception() | stdexec::then([=](const cv::Mat& src) { auto blurred = tr_blur(src, blur_size); auto gray = tr_to_grayscale(blurred); return tr_adaptthresh(gray, block_size, diff); }), stdexec::transfer_just(sched, src) | error_to_exception() | stdexec::then([=](const cv::Mat& src) { return tr_reducecolors(src, num_colors); })) | stdexec::then([](const cv::Mat& edges, const cv::Mat& reduced_colors) { return tr_apply_mask(reduced_colors, edges); }); return snd; } auto error_to_exception() { return stdexec::let_error([](auto e) { if constexpr (std::same_as<decltype((e)), std::exception_ptr>) return stdexec::just_error(e); else return stdexec::just_error( std::make_exception_ptr(std::runtime_error("other error"))); }); } exec::task<int> process_files(const char* in_folder_name, const char* out_folder_name, int blur_size, int num_colors, int block_size, int diff) { exec::async_scope scope; exec::static_thread_pool io_pool(1); auto io_sched = io_pool.get_scheduler(); auto cpu_sched = exec::get_system_scheduler(); int processed = 0; for (const auto& entry : fs::directory_iterator(in_folder_name)) { auto extension = entry.path().extension(); if (! entry.is_regular_file() || (extension != ".jpg") && (extension != ".jpeg")) continue; auto in_filename = entry.path().string(); auto out_filename = (fs::path(out_folder_name) / entry.path().filename()).string(); printf(“Processing % s\n”, in_filename.c_str()); auto file_content = co_await (stdexec::schedule(io_sched) | stdexec::then([=] { return read_file(entry); })); stdexec::sender auto work = ... scope.spawn(std::move(work)); } co_await scope.on_empty(); co_return processed; } stdexec::sender auto work = stdexec::transfer_just(cpu_sched, cv::_InputArray::rawIn(file_content)) | error_to_exception() | stdexec::then([=](cv::InputArray file_content) -> cv::Mat { return cv::imdecode(file_content, cv::IMREAD_COLOR); }) | stdexec::let_value([=](const cv::Mat& img) { return tr_cartoonify(img, blur_size, num_colors, block_size, diff); }) | stdexec::then([=](const cv::Mat& img) { std::vector<unsigned char> out_image_content; if (! cv::imencode(extension, img, out_image_content)) { throw std::runtime_error("cannot encode image"); } return out_image_content; }) | stdexec::continues_on(io_sched) | stdexec::then([=](const std::vector<unsigned char>& bytes) { write_file(out_filename.c_str(), bytes); }) | stdexec::then([=] { printf("Written %s\n", out_filename.c_str()); }) | stdexec::then([&] { processed++; });
Edited last time by Chobitsu on 04/22/2025 (Tue) 14:20:24.
>via learncpp.com Here's a straightforward example of testing what C++ standard your compiler is currently using, directly inside your code: > read_cpp_standard.cpp : /* minimal build & run: g++ read_cpp_standard.cpp -std=c++14 -o read_std && ./read_std */ #include <algorithm> #include <iostream> #include <map> #include <string> using std::cerr; using std::cout; using std::find_if; using std::map; using std::string; //------------------------------------------------------------------------------ /** read the compiler's C++ standard version code number * * @return code number */ long get_cpp_standard() { // Visual Studio is non-conforming in support for __cplusplus (unless you set // a specific compiler flag, which you probably haven't). in Visual Studio // 2015 or newer we can use _MSVC_LANG instead. see // https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ #if defined(_MSVC_LANG) return _MSVC_LANG; #elif defined(_MSC_VER) // if we're using an older version of Visual Studio, bail out return -1; #else // __cplusplus is the intended way to query the language standard code (as // defined by the language standards) return __cplusplus; #endif } //------------------------------------------------------------------------------ /** the program's entry point * * outputs the compiler's C++ language colloquial version number to console * * @return exit status code - 0/'success' implicitly; any other value is failure */ int main() { auto const this_std = get_cpp_standard(); if (this_std == -1) { cerr << "ERROR: Unable to determine your compiler's C++ language " "standard\n"; return -1; } //--- // note: the C++26 std_code is a placeholder since the exact code won't be // determined until the standard is finalized map<long, string> const std_codes{{199711L, "Pre-C++11"}, {201103L, "C++11"}, {201402L, "C++14"}, {201703L, "C++17"}, {202002L, "C++20"}, {202302L, "C++23"}, {202604L, "C++26"}}; auto const it = find_if(std_codes.cbegin(), std_codes.cend(), // note: replace the below C++ lambda with this version for C++11: /* [this_std](decltype(*std_codes.cbegin())& e) { return e.first == this_std; }); */ [this_std](auto const& e) { return e.first == this_std; }); if (it != std_codes.cend()) // code found cout << "Compiler's C++ standard: " << it->second << '\n'; else // code not found cout << "Compiler is not using one of the " << std_codes.size() << " C++ standards: (" << this_std << "L)\n"; } // see: // https://www.learncpp.com/cpp-tutorial/what-language-standard-is-my-compiler-using/ // https://en.cppreference.com/w/cpp/container/map // https://en.cppreference.com/w/cpp/algorithm/find // https://en.cppreference.com/w/cpp/preprocessor/replace#Predefined_macros // https://en.cppreference.com/w/cpp/feature_test possible output: Compiler's C++ standard: C++20
Edited last time by Chobitsu on 04/23/2025 (Wed) 14:07:30.
Open file (799.11 KB 2354x1608 read_std_main.png)
Open file (640.57 KB 2354x1608 read_std_meson.png)
I admit I don't really know much about AI or programming, so what I'm about to say is probably redundant. Recently I was thinking about themed characters making puns and wordplay based on their theme. Six degrees of separation (which I guess would be a semantic network) was the first thing that came to mind on making the AI pick words more closely related to their theme. This could be extended to include similarities in syllable structure for some puns, like a dog-girl being more likely to use the word "rough" or "roughly" because it sounds like "ruff" which is closely related to "dog". But I don't know how a system would work that allows the AI to come up with new words. By that I mean anything from a terrible catgirl pun "pawful" as a conjunction of "paw" and "awful", but also the way humans reuse or combine words to make new ones when they can't or don't think to look-up if it exists already. The first example of this I think of is was a little girl who didn't know the word "died", but seemed to know what death and ghosts were said "his ghost fell out" when someone died. Although it might be a better example to say when people put "-ish" when approximating something.
Open file (371.18 KB 2048x2048 1732894383289072.jpg)
>>37652 Yes, these are all interesting questions, Anon. IMO (while ultimately programming solutions will be needed for the 'rubber to meet the road') for the moment at least, this is more of a Cognitive (or even a Philosophy) robowaifu topic (cf. >>24783 ) I'd think. Cheers, Anon. :^)
Lol, you're awesome, Greentext anon! My apologies & thanks!! I only meant to trouble you for the OP itself -- not to migrate the whole thing over! Thanks very kindly, Anon. Cheers. :^)
>>37653 >(or even a Philosophy) robowaifu topic I figured some of the former part of the post could be done with a semantic network, but no idea how to do the latter part. It's really not a philosophical question.
>>37706 >I figured some of the former part of the post could be done with a semantic network, but no idea how to do the latter part. Yeah, I can totally see that. Surely some software or other will be needed to accomplish all this in the end! :D >It's really not a philosophical question. I can understand that position. However my take on all this is that the entire domains of both sapience & cognition are only but vaguely-understood; to the degree such that they fall fairly into the realm of Philosophies; unlike say, Chemistry, Geology, Mechanics, Astrophysics, Optics & EM, &tc. -- the studies of which are all clearly within the so-called 'hard' Sciences of today. Thanks, Anon. Cheers. :^)
Edited last time by Chobitsu on 04/23/2025 (Wed) 11:27:02.

Report/Delete/Moderation Forms
Delete
Report