SO, it started quite nicely with a fully working program. However nearing the end… or at the end of my programming experience or asking it to program something for me, it wrote in some nasty nasty screen flickering shit. I couldn’t stop it and it quickly just froze my screen where the only option was to push the button. I tried it a second time to confirm, but this time I was able to quickly go to a different CLI window and kill that sonobabich. Here is what it came up with in case you want to try it. maybe it only screws up my computer:

import os
import cv2
import numpy as np
import time
import tkinter as tk
from tkinter import messagebox, filedialog

def threshold_to_black(image_path, duration):
    original_image = cv2.imread(image_path)
    
    if original_image is None:
        print("Error: Could not read the image.")
        return

    height, width, _ = original_image.shape
    gray_image = cv2.cvtColor(original_image, cv2.COLOR_BGR2GRAY)
    steps = duration * 10  # 10 frames per second

    for i in range(steps + 1):
        # Calculate the threshold value (0 to 255)
        threshold = int((i / steps) * 255)
        
        # Create the thresholded image
        thresholded_image = np.where(gray_image < threshold, 0, 255).astype(np.uint8)

        # Resize the thresholded image to fill the window
        resized_image = cv2.resize(thresholded_image, (window_width, window_height), interpolation=cv2.INTER_LINEAR)

        # Display the thresholded image
        cv2.imshow(window_name, resized_image)

        # Wait for a short period to create the effect
        time.sleep(0.1)

        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

    # Display the final black image
    cv2.imshow(window_name, np.zeros_like(thresholded_image))
    
    while True:
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    
    cv2.destroyAllWindows()

def select_image():
    current_directory = os.getcwd()  # Get the current directory
    filetypes = (
        ('JPEG files', '*.jpg'),
        ('JPEG files', '*.jpeg'),
        ('All files', '*.*')
    )
    
    filename = filedialog.askopenfilename(
        title='Select an Image',
        initialdir=current_directory,  # Start in the current directory
        filetypes=filetypes
    )
    
    if filename:
        return filename
    else:
        messagebox.showerror("Error", "No image selected.")
        return None

def get_duration():
    def submit():
        nonlocal total_duration
        try:
            minutes = int(minutes_entry.get())
            seconds = int(seconds_entry.get())
            total_duration = minutes * 60 + seconds
            if total_duration > 0:
                duration_window.destroy()
            else:
                messagebox.showerror("Error", "Duration must be greater than zero.")
        except ValueError:
            messagebox.showerror("Error", "Please enter valid integers.")

    total_duration = None
    duration_window = tk.Toplevel()
    duration_window.title("Input Duration")
    
    tk.Label(duration_window, text="Enter duration:").grid(row=0, columnspan=2)
    
    tk.Label(duration_window, text="Minutes:").grid(row=1, column=0)
    minutes_entry = tk.Entry(duration_window)
    minutes_entry.grid(row=1, column=1)
    minutes_entry.insert(0, "12")  # Set default value for minutes
    
    tk.Label(duration_window, text="Seconds:").grid(row=2, column=0)
    seconds_entry = tk.Entry(duration_window)
    seconds_entry.grid(row=2, column=1)
    seconds_entry.insert(0, "2")  # Set default value for seconds
    
    tk.Button(duration_window, text="Submit", command=submit).grid(row=3, columnspan=2)
    
    # Center the duration window on the screen
    duration_window.update_idletasks()  # Update "requested size" from geometry manager
    width = duration_window.winfo_width()
    height = duration_window.winfo_height()
    x = (duration_window.winfo_screenwidth() // 2) - (width // 2)
    y = (duration_window.winfo_screenheight() // 2) - (height // 2)
    duration_window.geometry(f'{width}x{height}+{x}+{y}')

    duration_window.transient()  # Make the duration window modal
    duration_window.grab_set()    # Prevent interaction with the main window
    duration_window.wait_window()  # Wait for the duration window to close

    return total_duration

def wait_for_start(image_path):
    global window_name, window_width, window_height

    original_image = cv2.imread(image_path)
    height, width, _ = original_image.shape

    window_name = 'Threshold to Black'
    cv2.namedWindow(window_name, cv2.WINDOW_NORMAL)
    cv2.resizeWindow(window_name, width, height)
    cv2.imshow(window_name, np.zeros((height, width, 3), dtype=np.uint8))  # Black window
    print("Press 's' to start the threshold effect. Press 'F11' to toggle full screen.")
    
    while True:
        key = cv2.waitKey(1) & 0xFF
        if key == ord('s'):
            break
        elif key == 255:  # F11 key
            toggle_fullscreen()

def toggle_fullscreen():
    global window_name
    fullscreen = cv2.getWindowProperty(window_name, cv2.WND_PROP_FULLSCREEN)
    
    if fullscreen == cv2.WINDOW_FULLSCREEN:
        cv2.setWindowProperty(window_name, cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_NORMAL)
    else:
        cv2.setWindowProperty(window_name, cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)

if __name__ == "__main__":
    current_directory = os.getcwd()
    jpeg_files = [f for f in os.listdir(current_directory) if f.lower().endswith(('.jpeg', '.jpg'))]
    
    if jpeg_files:
        image_path = select_image()
        if image_path is None:
            print("No image selected. Exiting.")
            exit()

        duration = get_duration()
        if duration is None:
            print("No valid duration entered. Exiting.")
            exit()

        wait_for_start(image_path)

        # Get the original
    • werefreeatlast@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      0
      arrow-down
      1
      ·
      3 months ago

      If you download it and accidentally run it. I think you would think otherwise. A virus is any malicious code. It doesn’t have to be made with a special virus API. Literally you can make viruses that only run on Microsoft Excel.

      But AI is helping level that field.

      • quixotic120@lemmy.world
        link
        fedilink
        English
        arrow-up
        4
        ·
        3 months ago

        a virus perpetuates and replicates itself infecting other executables with its code, thus the name “virus”.

        this is just shitty code that crashes hard. it’s not even particularly malicious, it doesn’t destroy anything

          • Asetru@feddit.org
            link
            fedilink
            English
            arrow-up
            2
            ·
            3 months ago

            It doesn’t give anyone access to your system or forward information from your system to outsiders, so no.

            • ChaoticNeutralCzech@feddit.org
              link
              fedilink
              English
              arrow-up
              0
              arrow-down
              1
              ·
              edit-2
              3 months ago

              Trojan is any malware that pretends to be a legit program. It does not need to have backdoor or info stealing capability even though most malware (trojan or not) today does. For example, pre-Internet trojans might just invisibly install themselves along the actual program they were bundled with and then nuke the system on a certain date. Antivirus companies would even advance the date on their systems in hopes of detecting these and being the first to develop a patch.

              But since this program is not malicious, it just straight up hogs system resources and/or crashes it due to a mistake, it cannot be considered malware and therefore not a trojan.

              Certain Intel processors from around 2000 would crash everything when loading the 4 bytes F0 0F C7 C8 into a specific register. Would you consider this a backdoor because it allows any program to crash the system? I wouldn’t say so, crashing Windows 98 was probably not too hard anyway…

  • Myro@lemm.ee
    link
    fedilink
    English
    arrow-up
    2
    ·
    3 months ago

    I’m sorry, but it seems like you’re playing with tools and code you don’t understand. First, this has nothing in common with a virus. That is either a click bait or you don’t understand what it is you are looking at. If it crashes your computer, it is simply badly written code. Any programmer has done something similarly (in their area of domain, ie not necessarily able to crash a computer).

    For the next time, I would recommend you to use the AI to explain the code and ask questions about it.

    • nyan@lemmy.cafe
      link
      fedilink
      English
      arrow-up
      1
      ·
      3 months ago

      Exactly. This is as much a virus as the program I wrote as a first year CS student that rebooted the computer due to a bad pointer dereference was a virus. (That one would probably just segfault today, but I started back in the DOS dark ages . . .)

    • werefreeatlast@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      0
      arrow-down
      2
      ·
      3 months ago

      You know, AI was able to lock up my computer in less than a minute! Do you know how long it would take for me to do the same?

      I know python, but the exploration here is about how AI is all hype and 0 shits given to quality. It doesn’t know it has made a little mistake or a big one. It doesn’t actually know anything. It just sort of meanders from the question to the answer and it writes what other people might have written if they had written the previous 10 lines too.

      • technocrit@lemmy.dbzer0.com
        link
        fedilink
        English
        arrow-up
        2
        ·
        3 months ago

        AI was able to lock up my computer in less than a minute! Do you know how long it would take for me to do the same?

        It would probably take about a minute to google “python how to crash my computer” and then copy/paste.

  • Asetru@feddit.org
    link
    fedilink
    English
    arrow-up
    0
    ·
    3 months ago

    I once heard a cook say that cooks who use salt mills aren’t cooks.

    I’m really tempted to say the same thing about programmers that use llms to code.

  • werefreeatlast@lemmy.worldOP
    link
    fedilink
    English
    arrow-up
    0
    arrow-down
    1
    ·
    3 months ago

    LOL, I asked Chat-GPT to fix it and it couldn’t do it. It gave me code that also crashed my computer within a few seconds. In couldn’t even go to Ctrl alt F4 for example.

    • ilega_dh@feddit.nl
      link
      fedilink
      English
      arrow-up
      2
      ·
      3 months ago

      You’re either 11 years old, trolling or highly regarded (or all of the above)

      • werefreeatlast@lemmy.worldOP
        link
        fedilink
        English
        arrow-up
        0
        arrow-down
        2
        ·
        3 months ago

        Nah, mah man! I’m just a real really really hot looking chick with very large boobs that are still normal looking and pinup. I happen to be really good at using chat gpt to make fun of it.