can anyone write a code for this "A python GUI to Extract frames from video"
Make a GUI: ● Upload a video from the user interface ● Generate frames from the uploaded video ● Input: Video and output path location for generated frames ● save them as per the input path location ● Show any random images from the generated frames to the user’s end
do you know?
how many words do you know
See also questions close to this topic
-
Python File Tagging System does not retrieve nested dictionaries in dictionary
I am building a file tagging system using Python. The idea is simple. Given a directory of files (and files within subdirectories), I want to filter them out using a filter input and tag those files with a word or a phrase.
If I got the following contents in my current directory:
data/ budget.xls world_building_budget.txt a.txt b.exe hello_world.dat world_builder.spec
and I execute the following command in the shell:
py -3 tag_tool.py -filter=world -tag="World-Building Tool"
My output will be:
These files were tagged with "World-Building Tool": data/ world_building_budget.txt hello_world.dat world_builder.spec
My current output isn't exactly like this but basically, I am converting all files and files within subdirectories into a single dictionary like this:
def fs_tree_to_dict(path_): file_token = '' for root, dirs, files in os.walk(path_): tree = {d: fs_tree_to_dict(os.path.join(root, d)) for d in dirs} tree.update({f: file_token for f in files}) return tree
Right now, my dictionary looks like this:
key:''
.In the following function, I am turning the empty values
''
into empty lists (to hold my tags):def empty_str_to_list(d): for k,v in d.items(): if v == '': d[k] = [] elif isinstance(v, dict): empty_str_to_list(v)
When I run my entire code, this is my output:
hello_world.dat ['World-Building Tool'] world_builder.spec ['World-Building Tool']
But it does not see
data/world_building_budget.txt
. This is the full dictionary:{'data': {'world_building_budget.txt': []}, 'a.txt': [], 'hello_world.dat': [], 'b.exe': [], 'world_builder.spec': []}
This is my full code:
import os, argparse def fs_tree_to_dict(path_): file_token = '' for root, dirs, files in os.walk(path_): tree = {d: fs_tree_to_dict(os.path.join(root, d)) for d in dirs} tree.update({f: file_token for f in files}) return tree def empty_str_to_list(d): for k, v in d.items(): if v == '': d[k] = [] elif isinstance(v, dict): empty_str_to_list(v) parser = argparse.ArgumentParser(description="Just an example", formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("--filter", action="store", help="keyword to filter files") parser.add_argument("--tag", action="store", help="a tag phrase to attach to a file") parser.add_argument("--get_tagged", action="store", help="retrieve files matching an existing tag") args = parser.parse_args() filter = args.filter tag = args.tag get_tagged = args.get_tagged current_dir = os.getcwd() files_dict = fs_tree_to_dict(current_dir) empty_str_to_list(files_dict) for k, v in files_dict.items(): if filter in k: if v == []: v.append(tag) print(k, v) elif isinstance(v, dict): empty_str_to_list(v) if get_tagged in v: print(k, v)
-
Actaully i am working on a project and in it, it is showing no module name pip_internal plz help me for the same. I am using pycharm(conda interpreter
File "C:\Users\pjain\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\pjain\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\pjain\AppData\Local\Programs\Python\Python310\Scripts\pip.exe\__main__.py", line 4, in <module> File "C:\Users\pjain\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\__init__.py", line 4, in <module> from pip_internal.utils import _log
I am using pycharm with conda interpreter.
-
Looping the function if the input is not string
I'm new to python (first of all) I have a homework to do a function about checking if an item exists in a dictionary or not.
inventory = {"apple" : 50, "orange" : 50, "pineapple" : 70, "strawberry" : 30} def check_item(): x = input("Enter the fruit's name: ") if not x.isalpha(): print("Error! You need to type the name of the fruit") elif x in inventory: print("Fruit found:", x) print("Inventory available:", inventory[x],"KG") else: print("Fruit not found") check_item()
I want the function to loop again only if the input written is not string. I've tried to type return Under print("Error! You need to type the name of the fruit") but didn't work. Help
-
how do I dissable debian python path/recursion limit
so, as of late, I've been having path length limit and recursion limit issues, so I really need to know how to disable these.
I can't even install modules like discord.py!!!!
-
TypeError: 'float' object cannot be interpreted as an integer on linspace
TypeError Traceback (most recent call last) d:\website\SpeechProcessForMachineLearning-master\SpeechProcessForMachineLearning-master\speech_process.ipynb Cell 15' in <cell line: 1>() -->1 plot_freq(signal, sample_rate) d:\website\SpeechProcessForMachineLearning-master\SpeechProcessForMachineLearning-master\speech_process.ipynb Cell 10' in plot_freq(signal, sample_rate, fft_size) 2 def plot_freq(signal, sample_rate, fft_size=512): 3 xf = np.fft.rfft(signal, fft_size) / fft_size ----> 4 freq = np.linspace(0, sample_rate/2, fft_size/2 + 1) 5 xfp = 20 * np.log10(np.clip(np.abs(xf), 1e-20, 1e100)) 6 plt.figure(figsize=(20, 5)) File <__array_function__ internals>:5, in linspace(*args, **kwargs) File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\numpy\core\function_base.py:120, in linspace(start, stop, num, endpoint, retstep, dtype, axis) 23 @array_function_dispatch(_linspace_dispatcher) 24 def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, 25 axis=0): 26 """ 27 Return evenly spaced numbers over a specified interval. 28 (...) 118 119 """ --> 120 num = operator.index(num) 121 if num < 0: 122 raise ValueError("Number of samples, %s, must be non-negative." % num) TypeError: 'float' object cannot be interpreted as an integer
What solution about this problem?
-
IndexError: list index out of range with api
all_currencies = currency_api('latest', 'currencies') # {'eur': 'Euro', 'usd': 'United States dollar', ...} all_currencies.pop('brl') qtd_moedas = len(all_currencies) texto = f'{qtd_moedas} Moedas encontradas\n\n' moedas_importantes = ['usd', 'eur', 'gbp', 'chf', 'jpy', 'rub', 'aud', 'cad', 'ars'] while len(moedas_importantes) != 0: for codigo, moeda in all_currencies.items(): if codigo == moedas_importantes[0]: cotacao, data = currency_api('latest', f'currencies/{codigo}/brl')['brl'], currency_api('latest', f'currencies/{codigo}/brl')['date'] texto += f'{moeda} ({codigo.upper()}) = R$ {cotacao} [{data}]\n' moedas_importantes.remove(codigo) if len(moedas_importantes) == 0: break # WITHOUT THIS LINE, GIVES ERROR
Why am I getting this error? the list actually runs out of elements, but the code only works with the if
-
How To set the size of image more than default value in OpenCV
What is the default frame size of opencv image streaming frame ?
If I set Width and height of frame more than default frame size what happens?
-
How to read grayscale img from a video with OpenCV?
I read all pictures from my
pic
directory and then convert them each to gray-scale withcanny
edge detections before writing it all to a video.But, when I use my video software to play it, it shows a green background, and I can't read video frames from it. Could someone show me how to solve it?
Sample code
import numpy as np import cv2 as cv import matplotlib.pyplot as plt fourcc = cv.VideoWriter_fourcc(*"I420") out = cv.VideoWriter("t2.avi", fourcc, 1, (640, 480), 0) for pic in glob.glob1("./pic/", "A*"): img = cv.imread(f"./pic/{pic}", -1) edge = cv.Canny(img, 100, 200) edge = cv.resize(edge, (640, 480)) out.write(edge) out.release() # Cant read video frame here: cap = cv.VideoCapture("t2.avi") ret, frame = cap.read() if ret: plt.imshow(frame) else: print("end") cap.release()
-
Is there a way to guarantee a certain number of lines detected with cv2.HoughLines()?
This question is an extension to my previous question asking about how to detect a pool table's corners. I have found the outline of a pool table, and I have managed to apply the Hough transform on the outline. The result of this Hough transform is below:
Unfortunately, the Hough transform returns multiple lines for a single table edge. I want the Hough transform to return four lines, each corresponding to an edge of the table given any image of a pool table. I don't want to tweak the parameters for the Hough transform method manually (because the outline of the pool table might differ for each image of the pool table). Is there any way to guarantee four lines to be generated by
cv2.HoughLines()?
Thanks in advance.
-
I am working on a small project in C++ with GUI, which is about calculating the age. I want to make my program work on other computers
I am using Visual Studio 2013, I finished my project and I need to publish it, the problem is that it does not work on other computer, I think, because of the static link library or the like.I used reserved libraries in the language like
time.h
,MyForm.h
and did not use external libraries, I need solution to my problem, if there are references to something similar, mention them.EDIT: Sorry for the ambiguity in my question,
clarification: When I tried to run my program in another machine, an error message appeared, which means that the system did not recognize the file.EXE, I did not do the release, I just did Debug and then the .exe file in the Debug folder Sent it to other computers.
Sorry for bad English.
Thank you.
-
AttributeError: 'str' object has no attribute 'tk' when click button
Here is my code:
window = tk.Tk() version = tk.Label(text="hi", fg="orange", bg="black", width=20, height=10, ) version.pack() enter = tk.Button(text="START",fg="blue",width=20,height=7) enter.pack() def click(event): version.forget() enter.forget() name = tk.Label("name") entry = tk.Entry() name.pack() entry.pack() enter.bind("<Button-1>", click) window.mainloop()
As you can see, I wanted to make a Label and an Entry appear once the START button is clicked.
When I click the button, though, it returns this error:
Exception in Tkinter callback Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 1892, in __call__ return self.func(*args) File "/Users/name/Desktop/project/gui/main.py", line 19, in click name = tk.Label("name") File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 3148, in __init__ Widget.__init__(self, master, 'label', cnf, kw) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 2566, in __init__ BaseWidget._setup(self, master, cnf) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 2535, in _setup self.tk = master.tk AttributeError: 'str' object has no attribute 'tk'
I don't know what is happening here.
-
Storyboard mirroring after localization in iOS
I have an iOS app. I started working on it without localization. The app is RTL-language-oriented. Now I wanted to localize the app so I created localization of strings. I didn't add any storyboard localization.
But unfortunately, all the UI got mirrored.
I don't even have "main(base)" file
The question is - Why is my UI NOT ignoring the language direction like it did before I started localizing? I expect the UI to ignore the language direction because I didn't add anything that should change the behavior it had before starting the localization.
(I know about the "right-leading left-trailing + respect language direction" ability of constraints, this is not my question)
Thank you!
-
is there a way to get a new image to display using a function inside of a function?
I'm doing a project for school and I have no clue as to why this isn't working. Any help is appreciated!
from tkinter import * def main(): def change(): photo2 = PhotoImage(file=r"image2") label.configure(image = photo2) mainwindow.destroy() window = Tk() window.geometry("1500x1500") photo1 = PhotoImage(file = r"image1") label = Label(window, image = photo1) label.place(x = 20, y = 20) button = Button(window, text = "Click Me!", command = change) button.place(x = 0, y = 0) window.mainloop() mainwindow = Tk() mainwindow.geometry("700x700") start = Button(mainwindow, text = "start", command = main) start.place(x = 0, y = 0) mainwindow.mainloop()
-
What is the reason of this error I'm getting when using tkinter for a math app
Im making a program that will do most of my homework. Im trying to add some ui and it gives errors in my code. Please tell what's wrong. Make it easy enough for a 13 year old to understand because I'm new to python. This gives an error only when i use canvas. If i use window, then it doesn't but i want to use canvas because I can change their position more accurately
from tkinter import * root=Tk() canvas1 = Canvas(root, width = 400, height = 300) canvas1.pack() entry1 = Entry (root) canvas1.create_window(200, 140, window=entry1) entry2 = Entry (root) canvas1.create_window(200, 180, window=entry2) entry3 = Entry (root) canvas1.create_window(200, 220, window=entry3) def getvalue(): p=entry1.get() r=entry2.get() t=entry3.get() labelans = Label(root, text = float(p*r*t)/100) canvas1.create_window(200, 230, window=labelans) label1 = Label(root, text="Time") canvas1.create_window(437, 220, window=label1) label2 = Label(root, text="Rate") canvas1.create_window(437,180, window=label2) label3 = Label(root, text="Principal") canvas1.create_window(465, 140, window=label3) button1 = Button(text='Solve!', bg="red", command=getvalue) canvas1.create_window(200, 300, window=button1) mainloop()
*And it gives this error
Exception in Tkinter callback Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.9/tkinter/__init__.py", line 1892, in __call__ return self.func(*args) File "/data/user/0/ru.iiec.pydroid3/files/temp_iiec_codefile.py", line 17, in getvalue labelans = Label(root, text = float(p*r*t)/100) TypeError: can't multiply sequence by non-int of type 'str' Exception in Tkinter callback Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.9/tkinter/__init__.py", line 1892, in __call__ return self.func(*args) File "/data/user/0/ru.iiec.pydroid3/files/temp_iiec_codefile.py", line 17, in getvalue labelans = Label(root, text = float(p*r*t)/100) TypeError: can't multiply sequence by non-int of type 'str' Exception in Tkinter callback Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.9/tkinter/__init__.py", line 1892, in __call__ return self.func(*args) File "/data/user/0/ru.iiec.pydroid3/files/temp_iiec_codefile.py", line 17, in getvalue labelans = Label(root, text = float(p*r*t)/100) TypeError: can't multiply sequence by non-int of type 'str' Exception in Tkinter callback Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.9/tkinter/__init__.py", line 1892, in __call__ return self.func(*args) File "/data/user/0/ru.iiec.pydroid3/files/temp_iiec_codefile.py", line 17, in getvalue labelans = Label(root, text = float(p*r*t)/100) TypeError: can't multiply sequence by non-int of type 'str' Exception in Tkinter callback Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.9/tkinter/__init__.py", line 1892, in __call__ return self.func(*args) File "/data/user/0/ru.iiec.pydroid3/files/temp_iiec_codefile.py", line 17, in getvalue labelans = Label(root, text = float(p*r*t)/100) TypeError: can't multiply sequence by non-int of type 'str'*
-
How to use Tkinter after method to give the impression of a wheel spinning?
I'm trying to create three separate 'wheels' that change the starting position of the first arc in order to give the impression of the wheel spinning. Tkinter will draw the first wheel on the canvas and delete it after 1 second, but the subsequent wheels are never drawn.
from tkinter import Canvas, Tk tk = Tk() tk.geometry('500x500') canvas = Canvas(tk) canvas.pack(expand=True, fill='both') in_list = [1,1,1,1,1,1,1] arc_length = 360 / len(in_list) first_mvmt = arc_length / 3 second_mvmt = arc_length * 2 / 3 mvmt_list = [0, first_mvmt, second_mvmt] for mvmt in mvmt_list: for i in range(len(in_list)): start = i * arc_length extent = (i + 1) * arc_length arc = canvas.create_arc(5, 5, 495, 495, outline='white', start=start + mvmt, extent=extent) canvas.after(1000) canvas.delete('all') tk.mainloop()
Also please excuse my poor formatting, this is my first post on stackoverflow