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
53 points

that’s not what a virus is

permalink
report
reply
-44 points

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.

permalink
report
parent
reply
64 points

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

permalink
report
parent
reply
15 points

Okay 👍 you are right.

permalink
report
parent
reply
-20 points

This could be considered a trojan.

permalink
report
parent
reply
25 points

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.

permalink
report
reply
5 points

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 . . .)

permalink
report
parent
reply
18 points

You don’t need AI. Take some basic programming courses.

permalink
report
reply
-7 points

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.

permalink
report
parent
reply
4 points

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.

permalink
report
parent
reply
-2 points

But you wouldn’t do that right? You wouldn’t download a car!

permalink
report
parent
reply
2 points

You know, AI was able to lock up my computer in less than a minute!

You know, I won’t let AI do that to mine.

permalink
report
parent
reply
8 points

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.

permalink
report
reply
20 points

Yeah, programmers who use LLMs to code sure aren’t cooks.

permalink
report
parent
reply
2 points

We don’t know about all programmers, but we know one at least now.

permalink
report
parent
reply
5 points

PEBKAC

permalink
report
reply
1 point

I knew my clothes were the issue.

permalink
report
parent
reply

Technology

!technology@lemmy.world

Create post

This is a most excellent place for technology news and articles.


Our Rules


  1. Follow the lemmy.world rules.
  2. Only tech related content.
  3. Be excellent to each another!
  4. Mod approved content bots can post up to 10 articles per day.
  5. Threads asking for personal tech support may be deleted.
  6. Politics threads may be removed.
  7. No memes allowed as posts, OK to post as comments.
  8. Only approved bots from the list below, to ask if your bot can be added please contact us.
  9. Check for duplicates before posting, duplicates may be removed

Approved Bots


Community stats

  • 17K

    Monthly active users

  • 12K

    Posts

  • 542K

    Comments