#coding

danie10@squeet.me

OpenCV Tutorial demonstrates how a Python program is built to measure the distance of a hand using a single webcam

Apart from the information on how to use these Python libraries (hand recognition and tracking), it’s a very interesting exercise which shows how you build out any program piece by piece, by testing the logic at each step. This is, of course, not possible if you don’t have open source code to examine and re-use.
I love how the logic is unpacked at each stage, and it is the approach most programmers will use to simplify what can become complex as it progresses to completion. You test each stage before starting a new one, and this is where you’d notice the X measurement is not sufficient to provide accurate results, and why the diagonal measurement is more accurate. Then testing whether it is a linear relationship or not, and so you keep building up the following stages.

Although this was for hand recognition and distance interpretation, the type of approach could be followed for face tracking or anything else.

See OpenCV Knows Where Your Hand Is

#technology #opensource #programming #coding #Python

Imagem/foto

We have to say, [Murtaza]’s example game in his latest video isn’t very exciting. However, the OpenCV technique he uses to track a hand and determine its distance from a single camera i…

Bild/Foto
#Blog, #rss- - - - - -

https://gadgeteer.co.za/opencv-tutorial-demonstrates-how-a-python-program-is-built-to-measure-the-distance-of-a-hand-using-a-single-webcam/

coderdojo_bxl_yser@diaspora.psyco.fr
coderdojo_bxl_yser@diaspora.psyco.fr
coderdojo_bxl_yser@diaspora.psyco.fr

We zijn op zoek naar nieuwe vrijwillige coaches

Coach zijn bij CoderDojo is een buitengewoon avontuur. Wij organiseren ludieke workshops rond computerwetenschappen voor jongeren van 7~8 jaar tot 18 jaar. En je hoeft geen computergoeroe te zijn om een coach te zijn. Dus, als je geïnteresseerd bent om het team van CoderDojo Brussels Yser te versterken, neem dan contact met ons op via bxl-yser@coderdojobelgium.be.

#arduino #belgie #belgië #brussel #code #coderdojo #coderdojo-belgium #coderdojo_belgium #coderdojobelgium #codering #coding #computerontwikkeling #css #css3 #elektronicaworkshops #elektronisch #elektronisch-circuit #elektronisch_circuit #elektronischcircuit #formatie #godot #html #html5 #informatica #initiatie #it-ontwikkeling #it_ontwikkeling #itontwikkeling #javascript #jeugd #jeugdigheid #jongere #kind #kinderen #microbit #ontwikkeling #programmering #python #robotica #scratch #technologie #vrijwilliger #web #webontwikkeling

coderdojo_bxl_yser@diaspora.psyco.fr
tord_dellsen@diasp.eu

I've been working on this code for storing settings in a JSON file. It's for the mindfulness-at-the-computer project

def settings_file_exists() -> bool:
    return os.path.isfile(JSON_SETTINGS_FILE_NAME)

def save_dict_to_json(i_dict_to_save: dict, i_file_path: str):
    print("save_data_to_json")
    with open(i_file_path, "w") as write_file:
        json.dump(i_dict_to_save, write_file, indent=2)

def load_dict_from_json(i_minimum_dict: dict, i_file_path: str) -> dict:
    print("load_data_from_json")
    ret_dict = i_minimum_dict.copy()
    if os.path.isfile(i_file_path):
        with open(i_file_path, "r") as read_file:
            from_file_dict: dict = json.load(read_file)

            diff_key_list: list = []
            for min_key in i_minimum_dict.keys():
                if min_key not in from_file_dict.keys():
                    diff_key_list.append(min_key)
            print(f"One or more keys needed for the application to work were not "
            f"available in {os.path.basename(i_file_path)} so have been added now. "
            f"These are the keys: {diff_key_list}")

            diff_key_list: list = []
            for file_key in from_file_dict.keys():
                if file_key not in i_minimum_dict.keys():
                    diff_key_list.append(file_key)
            print(f"One or more keys in {os.path.basename(i_file_path)} are not "
            f"used by the application (though may have been used before). "
            f"These are the keys: {diff_key_list}")

            print(f"Before merge {i_minimum_dict=}")
            print(f"Before merge {from_file_dict=}")
            ret_dict.update(from_file_dict)
            # -if there are different values for the same key, the value
            #  in from_file_dict takes precendence
            print(f"After merge {ret_dict=}")
    return ret_dict

SK_SHOW_BREATHING_TEXT = "show breathing text"
SK_REST_ACTIONS = "rest actions"
SK_BREATHING_AUDIO_VOLUME = "breathing audio volume"
SK_BREATHING_BREAK_TIMER_SECS = "breathing break timer secs"

# The values given here are the minimum values needed for the application to work
min_settings_dict = {
    SK_SHOW_BREATHING_TEXT: True,
    SK_BREATHING_AUDIO_VOLUME: 50,
    SK_REST_ACTIONS: {},
    SK_BREATHING_BREAK_TIMER_SECS: 3,
}

# Initial setup
if not settings_file_exists():
    rest_actions: dict = {
        "Making tea": "path/to/image",
        "Cleaning workspace": "/home/user/_",
        "Walking meditation": "path/to/image",
    }
    min_settings_dict.get(SK_REST_ACTIONS).update(rest_actions)

db_file_exists_at_application_startup_bl = settings_file_exists()
settings: dict = load_dict_from_json(min_settings_dict, get_json_file_path())
print(f"{settings=}")

#python #programming #coding #json #datapersistence #mindfulness-at-the-computer #matc

coderdojo_bxl_yser@diaspora.psyco.fr
danie10@squeet.me

How different programming languages read and write data: C, C++, Java, Groovy, Lua, and Python

In his article How different programming languages do the same thing, Jim Hall demonstrates how 6 different languages accomplish the same exact task with different syntax. The lesson is that programming languages tend to have many similarities, and once you know one programming language, you can learn another by figuring its syntax and structure.

In the same spirit, Jim's article compares how different programming languages read and write data. Whether that data comes from a configuration file or from a file a user creates, processing data on a storage device is a common task for coders.

Every programming language has a unique way of accomplishing a task; that's why there are so many languages to choose from. You can and should choose the language that works best for you. But once you understand the basic constructs of programming, you can also feel free to try out different languages, without fear of not knowing how to accomplish basic tasks. More often than not, the pathways to a goal are similar, so they're easy to learn as long as you keep the basic concepts in mind.

See How different programming languages read and write data

#technology #programming #coding

Image/photo

In his article How different programming languages do the same thing, Jim Hall demonstrates how 13 different languages accomplish the same exact task with different syntax. The lesson is that programming languages tend to have many similarities, and once you know one programming language, you can learn another by figuring its syntax and structure.


https://gadgeteer.co.za/how-different-programming-languages-read-and-write-data-c-c-java-groovy-lua-and-python