Skip to content

Commit

Permalink
correct hires images fetch; no freeze when zoom out;faster spot search
Browse files Browse the repository at this point in the history
  • Loading branch information
pronopython committed Jul 2, 2024
1 parent ca191ac commit 92570c8
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 40 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
47 changes: 24 additions & 23 deletions rugivi/crawlers/first_organic/organic_crawler_first_edition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions rugivi/image_service/image_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
27 changes: 18 additions & 9 deletions rugivi/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 92570c8

Please sign in to comment.