It is strange, I don’t know what the problem is. But I will try to look into it
Any luck on resolving this problem?
Sorry about the silence.
The problem seems to be, that the video is not loaded correctly. The new version of the script can hopefully help.
I have edited the top post with a new version of the script.
The changes are
- Check to make sure it finds the video file
- The progress bar is now capped at the number of frames in the video, when a number is not provided in
beat_scripter.predict_beats()
How long does it usually take to predict beats? My 45 minute video took ~1hr10min
I don’t have exact numbers, but the videos I have used, have taken about 10-15 mins on my desktop. Maybe it takes longer if the video is high resolution, because it is the loading of the video frames that is time consuming. Maybe your graphics card also matters, though I am not sure
How long was the length of these videos?
The one I tried was ~45 minutes with I think around like 75k frames.
This is quite literally the first time I have ever used python and my only other coding experience was making a “hello world” program in Java. So Im curious if a factor is that the program I used was called Anaconda that ran in my browser. Assuming it mainly uses ram to process would using a different program maybe work faster, if so what would you suggest
Hello,
can you make a Video tutorial ? Pls
Im a Noob
Ty
Added that to the first few lines
from os import path
site_packages = path.expandvars(r'%LOCALAPPDATA%\Programs\Python\Python39\Lib\site-packages')
import sys
sys.path.append(site_packages)
Since I got this err despite installed package cv2
ModuleNotFoundError: No module named ‘cv2’
I second this
I THiRD THIS
I use this script for all my beat-bar scripts but I’m not really up for making a tutorial video.
Maybe I can still help though. Are you having trouble installing python and all the packages? or with using the script itself?
kida everyting
Okay, I can try and guide you through it.
The very first step is to install Python itself, followed by Jupyter notebook which is a program that allows you to use python. And thirdly installing ‘pip’, a package installer that makes it much much easier to download and install any ‘packages’ to python. Packages are kinda like mods that expand functionality.
These three installation steps are all shown in this tutorial video:
After following the video you should be able to get to this window in your browser:
Obviously the folders might be different for your PC
Let me know if you can get this far.
The next step is to gather all the packages that are listed in step 1 of the original post here.
You follow each link and on each page there will be a command line to install that package using your console.
For example pip install -U scikit-learn
.
There’s usually also a command to check if it installed correctly.
After completing OP’s step 1 you’ve set up python and are ready to copy the program code into a new notebook. (top right button ‘new’ → python 3)
hey bro,i used chatgpt about how to use mouse choose area by python.i dont know python,but i think its uesful to you.
import matplotlib.pyplot as plt
def box(data):
plt.imshow(data, cmap=“gray”)
print(“Please select a region using the mouse”)
coords = plt.ginput(n=2, timeout=-1)
x_min, y_min = coords[0]
x_max, y_max = coords[1]
x_center = (x_min + x_max) / 2
y_center = (y_min + y_max) / 2
x_range = abs(x_max - x_min)
y_range = abs(y_max - y_min)
return x_center, y_center, x_range, y_range
this will make the whole CH genre super fast now
If you want to be able to add the bounding box with a mouse u can add this to the code:
(this part gets added in the BeatScripter Class):
#add this to the top of the def init function
self.box_drawn = False
#this part can be added after the export_funscript function
#draw bounding box with mouse
def draw_bounding_box(self, frame):
clone = frame.copy()
cv2.namedWindow('Draw Bounding Box')
cv2.imshow('Draw Bounding Box', clone)
# Mouse callback function
def draw_rectangle(event, x, y, flags, param):
nonlocal clone
if event == cv2.EVENT_LBUTTONDOWN:
self.box_top_corner = (x, y)
self.box_drawn = False
elif event == cv2.EVENT_MOUSEMOVE and flags == cv2.EVENT_FLAG_LBUTTON:
clone = frame.copy()
cv2.rectangle(clone, (self.box_top_corner[0], self.box_top_corner[1]), (x, y), (0, 255, 0), 2)
cv2.imshow('Draw Bounding Box', clone)
elif event == cv2.EVENT_LBUTTONUP:
self.box_size = (abs(x - self.box_top_corner[0]), abs(y - self.box_top_corner[1]))
self.box_drawn = True
cv2.setMouseCallback('Draw Bounding Box', draw_rectangle)
while not self.box_drawn:
cv2.imshow('Draw Bounding Box', clone)
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
cv2.destroyAllWindows()
To run the script remove
beat_scripter.box_top_corner = (625, 669)
beat_scripter.box_size=(32, 50)
and replace with
# Draw bounding box interactively
frame_to_draw = beat_scripter.frames_list[1][0][1] # You can choose any frame to draw the bounding box on
beat_scripter.draw_bounding_box(frame_to_draw)
installed all and first error comes already in setting up =P
“ModuleNotFoundError: No module named ‘cv2’”
maybe I try to uninstall all and install all again =)
You probably already figured this one out, but for future people trying this, the fix is:
pip install -U opencv-python