eitaa logo
Coders
158 دنبال‌کننده
19 عکس
2 ویدیو
0 فایل
My goal is your progress and not fraud Peace be upon Khomeini the Great
مشاهده در ایتا
دانلود
یعنی کتابخونه numpy نصب نشده و باید نصبش کنین
حالا ی اموزش برای نصب کتابخونه بریم با یک روش دیگه (با ترمینال)
اینجا دستور رو وارد میکنی
import numpy as np import matplotlib.pyplot as plt # ساخت یه دایره با اندازه یکسان در تمام جهت‌ها circle = plt.Circle((0, 0), 0.5, color='gray', fill=True) # مختصات محورها تو حالت خاکستری روشن x = np.linspace(-1, 1, 1000) X, Y = np.meshgrid(x, x) Z = np.sqrt(X*X + Y*Y) # رسم محورها و دایره در یه نمودار fig, ax = plt.subplots() ax.contourf(X, Y, Z, levels=30, cmap='gray') ax.add_artist(circle) # رسم نمودار plt.axis('scaled') plt.show()
import tkinter as tk import time class TimerApp: def init(self, master): self.master = master master.title("Timer App") self.time_var = tk.StringVar() self.time_var.set('00:00:00') self.timer_label = tk.Label(master, textvariable=self.time_var, font=('Helvetica', 48)) self.timer_label.pack() self.start_button = tk.Button(master, text="Start", command=self.start_timer) self.start_button.pack() self.running = False def start_timer(self): if not self.running: self.running = True self.start_button.config(text="Stop") self.start_time = time.time() self.update_timer() else: self.master.after_cancel(self.timer_job) self.running = False self.start_button.config(text="Start") def update_timer(self): elapsed_time = time.time() - self.start_time hours, rem = divmod(elapsed_time, 3600) minutes, seconds = divmod(rem, 60) time_string = '{:02}:{:02}:{:02}'.format(int(hours), int(minutes), int(seconds)) self.time_var.set(time_string) self.timer_job = self.master.after(1000, self.update_timer) root = tk.Tk() timer_app = TimerApp(root) root.mainloop()
یکم سطح رو بالاتر میبرم
این کد به شما کمک می کنه تا یه آهنگ رو از اینترنت دانلود کرده و در پوشه موسیقی ذخیره کنین اول باید کتابخونه requests رو نصب کنین pip install requests بعدش با استفاده از کد زیر لینک آهنگ مورد نظر خود رو تو قسمت url قرار بدید import requests url = "https://example.com/song.mp3" response = requests.get(url) with open("music/song.mp3", "wb") as f:     f.write(response.content) تو اینجا فایل mp3 با نام song تو پوشه music ذخیره می شه
پیاده سازی پروژه تشخیص حرکت با استفاده از کتابخانه OpenCV: اول کتابخونه رو از ترمینال دانلود کنین : pip3 install opencv-python –user کد : Library import cv2 frame first_frame = None Video our_video = cv2.VideoCapture(0) while True: if loaded correctly check, frame = our_video.read() to Gray our_frame_gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) our_frame_gray = cv2.GaussianBlur(our_frame_gray,(21,21),0) first frame if first_frame is None: first_frame=our_frame_gray continue frame first frame to current frame delta_frame = cv2.absdiff(first_frame, our_frame_gray) frame threshold_frame = cv2.threshold(delta_frame, 30, 255, cv2.THRESH_BINARY)[1] threshold_frame = cv2.dilate(threshold_frame, None, iterations=2) cnts, hierarchy = cv2.findContours(threshold_frame.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) rectangle for moving objects for contour in cnts: if cv2.contourArea(contour) < 500: continue x, y, w, h = cv2.boundingRect(contour) cv2.rectangle(frame, (x,y), (x+w,y+h), (0,255,0), 3) the captured frame of video cv2.imshow("First Frame", first_frame) cv2.imshow("Capturing first ", our_frame_gray) cv2.imshow("Delta Frame", delta_frame) cv2.imshow("Threshold Frame", threshold_frame) cv2.imshow("Detecting objects", frame) q=quit key = cv2.waitKey(1) if(key == ord('q')): break our_video.release() cv2.destroyAllWindows