From 92570c89617ff90b5ad7f5b9e082fa70894c8ab4 Mon Sep 17 00:00:00 2001 From: pronopython Date: Tue, 2 Jul 2024 17:34:30 +0200 Subject: [PATCH] correct hires images fetch; no freeze when zoom out;faster spot search --- README.md | 13 +++-- .../organic_crawler_first_edition.py | 47 ++++++++++--------- rugivi/image_service/image_server.py | 8 ++-- rugivi/view.py | 27 +++++++---- setup.py | 2 +- 5 files changed, 57 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 0fc7cf7..68b7b88 100755 --- a/README.md +++ b/README.md @@ -474,16 +474,14 @@ cv2verbose=True ``` ## Known bugs and limitations -* Quit does not work everytime. The crawler then runs in an infinite loop. * Sometimes the garbage collection is not run or runs too late and memory is depleted (rugivi can easily grab gigabytes of RAM of course). You then get an out-of-memory error. * Despite not changing anything, RuGiVi does not work on read-only media directories. This is because pygame image loader opens files with write access. * TIFF files may produce warnings which on Windows are opened as separate message boxes. * Audio pops at startup (probably a pygame issue) -* High res versions are unloaded despite being displayed (pictures end up showing as a colored square when zoomed beyond thumb size) # Technical Stuff -Every Image is placed into a Frame with Spot Size of 4096 x 4096 Pixels, which is Heigth = 1 +Every Image is placed into a Frame with Spot Size of 4096 x 4096 Pixels, which is height = 1 A Frame is placed onto a spot. @@ -716,6 +714,14 @@ Don't want to use GitHub? You can also contact me via email: pronopython@proton. # Release Notes +## v0.5.2-alpha + +### fixed + +- Higher resolution images are now fetched at correct zoom level (that means much earlier when zooming) +- RuGiVi no more freezes for seconds when zooming out (Freeze resulted in a warning from the OS) +- Spot search for new images is faster when searching for a place for many images + ## v0.5.1-alpha ### changed @@ -725,6 +731,7 @@ Don't want to use GitHub? You can also contact me via email: pronopython@proton. ### fixed - Fixed permanent unload of images after housekeeping (happened around 30 mins of runtime) +- Crawler does not block anymore when closing RuGiVi ## v0.5.0-alpha diff --git a/rugivi/crawlers/first_organic/organic_crawler_first_edition.py b/rugivi/crawlers/first_organic/organic_crawler_first_edition.py index 926591e..e724c58 100644 --- a/rugivi/crawlers/first_organic/organic_crawler_first_edition.py +++ b/rugivi/crawlers/first_organic/organic_crawler_first_edition.py @@ -531,30 +531,31 @@ def __find_empty_spots(self, current_dir, neededSpots): parent_spot = self.dir_and_start_spot[str(basedir_parent_path)] (parent_spot_x_S, parent_spot_y_S) = parent_spot - - # try x times to find an empty border spot closer and closer to the parent spot - for current_round in range( - 0, 30 - ): # was 300 -> more time needed for that (bad), but 30 is inaccurate - sleep(0.0002) - candidate = random.choice(tuple(self.border_spots)) - #print("border spot candidate",candidate) - if candidate in list_of_unsuccessful_border_spots: - #print("Border candiate",candidate, "already checked and it is not good") - continue - #print("Border candiate",candidate) - (candidate_x_S, candidate_y_S) = candidate - (start_spot_x_S, start_spot_y_S) = start_spot - # changed "or" to "and" - if self.CROSS_SHAPE_GROW: - if abs(candidate_x_S - parent_spot_x_S) < abs( - start_spot_x_S - parent_spot_x_S - ) and abs(candidate_y_S - parent_spot_y_S) < abs( - start_spot_y_S - parent_spot_y_S - ): + if len(list_of_unsuccessful_border_spots) < 14: + + # try x times to find an empty border spot closer and closer to the parent spot + for current_round in range( + 0, 30 - len(list_of_unsuccessful_border_spots) # the more unsuccessful the search is, the less nearer the spot is selected + ): # was 300 -> more time needed for that (bad), but 30 is inaccurate + sleep(0.0002) + candidate = random.choice(tuple(self.border_spots)) + #print("border spot candidate",candidate) + if candidate in list_of_unsuccessful_border_spots: + #print("Border candiate",candidate, "already checked and it is not good") + continue + #print("Border candiate",candidate) + (candidate_x_S, candidate_y_S) = candidate + (start_spot_x_S, start_spot_y_S) = start_spot + # changed "or" to "and" + if self.CROSS_SHAPE_GROW: + if abs(candidate_x_S - parent_spot_x_S) < abs( + start_spot_x_S - parent_spot_x_S + ) and abs(candidate_y_S - parent_spot_y_S) < abs( + start_spot_y_S - parent_spot_y_S + ): + start_spot = candidate + elif math.dist((candidate_x_S,candidate_y_S),(parent_spot_x_S,parent_spot_y_S)) < math.dist((start_spot_x_S,start_spot_y_S),(parent_spot_x_S,parent_spot_y_S)): start_spot = candidate - elif math.dist((candidate_x_S,candidate_y_S),(parent_spot_x_S,parent_spot_y_S)) < math.dist((start_spot_x_S,start_spot_y_S),(parent_spot_x_S,parent_spot_y_S)): - start_spot = candidate elif ( self.start_spot_search_method diff --git a/rugivi/image_service/image_server.py b/rugivi/image_service/image_server.py index 5847bca..ec4c689 100755 --- a/rugivi/image_service/image_server.py +++ b/rugivi/image_service/image_server.py @@ -440,7 +440,7 @@ def server_view_fetcher_loop(self) -> None: # view.height / 4 # <= World.SPOT_SIZE spot_width - >= ImageServer.QUALITY_PIXEL_SIZE[StreamedImage.QUALITY_GRID] + >= (ImageServer.QUALITY_PIXEL_SIZE[StreamedImage.QUALITY_GRID] / 3) ): view_chunk_x1_C = view.world.convert_S_to_C(view.world_x1_S) @@ -456,9 +456,9 @@ def server_view_fetcher_loop(self) -> None: # print("view fetcher: chunk",chunk.x_C,chunk.y_C) # sleep(0.02) for x_SL in range(0, World.CHUNK_SIZE): - # sleep(0.002) + sleep(0.00002) for y_SL in range(0, World.CHUNK_SIZE): - # sleep(0.00001) + sleep(0.00001) frame = chunk.get_frame_at_SL(x_SL, y_SL) if frame != None: @@ -492,7 +492,7 @@ def server_view_fetcher_loop(self) -> None: > ImageServer.QUALITY_PIXEL_SIZE[ StreamedImage.QUALITY_SCREEN ] - / 2 + / 4 ): needed_quality = ( StreamedImage.QUALITY_SCREEN diff --git a/rugivi/view.py b/rugivi/view.py index e9d1013..ea7148d 100755 --- a/rugivi/view.py +++ b/rugivi/view.py @@ -144,8 +144,14 @@ def draw_view( drawrounds = self.max_draw_rounds start_time = time_ns() + broke_draw_loop = False for drawround in range(0, drawrounds): + if (time_ns() - start_time)/1000000 > 200: # no round longer than 200 ms + broke_draw_loop = True + break + + self.update_matrix_position += 1 if self.update_matrix_position >= len(self.update_matrix): self.update_matrix_position = 0 @@ -317,18 +323,21 @@ def draw_view( self.performance_images_drawn + 1 ) - elapsed_time = int((time_ns() - start_time) / 1000000) - - new_max_draw_rounds = 1 + if broke_draw_loop: + new_max_draw_rounds = 1 + else: + elapsed_time = int((time_ns() - start_time) / 1000000) - per_round = elapsed_time / self.max_draw_rounds - if per_round < 1: - per_round = 1 - fps = 15 - new_max_draw_rounds = int((1000 / fps) / per_round) - if new_max_draw_rounds < 1: new_max_draw_rounds = 1 + per_round = elapsed_time / self.max_draw_rounds + if per_round < 1: + per_round = 1 + fps = 15 + new_max_draw_rounds = int((1000 / fps) / per_round) + if new_max_draw_rounds < 1: + new_max_draw_rounds = 1 + self.max_draw_rounds_queue.append(new_max_draw_rounds) self.max_draw_rounds_queue.pop(0) diff --git a/setup.py b/setup.py index 6de90e9..9339570 100755 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ from setuptools import setup setup(name='rugivi', - version='0.5.1-alpha', + version='0.5.2-alpha', description='RuGiVi - Adult Media Landscape Browser', long_description='RuGiVi enables you to fly over your image and video collection and view thousands of images and video frames at once. Zoom in and out from one image to small thumbnails with your mousewheel in seconds. All images are grouped as you have them on your disk and arranged in a huge landscape. RuGiVi can work with hundred thousand of images at once.', url='https://github.com/pronopython/rugivi',