GIScience / sketch-map-tool

Create re-digitizable paper maps for offline data collection in the field.
https://sketch-map-tool.heigit.org/
GNU Affero General Public License v3.0
30 stars 7 forks source link

TimeOutError for multiple sketch maps of urban area #403

Open Gigaszi opened 5 months ago

Gigaszi commented 5 months ago

When digitizing multiple (here 4) sketch maps of an urban error, this error occurs:

sketch-map-tool-celery-1  | 2024-03-25 12:40:20,361 - ERROR - request.py - on_failure - Task handler raised error: TimeLimitExceeded(900)
sketch-map-tool-celery-1  | Traceback (most recent call last):
sketch-map-tool-celery-1  |   File "/home/smt/.conda/envs/smt/lib/python3.11/site-packages/billiard/pool.py", line 683, in on_hard_timeout
sketch-map-tool-celery-1  |     raise TimeLimitExceeded(job._timeout)
sketch-map-tool-celery-1  | billiard.einfo.ExceptionWithTraceback: 
sketch-map-tool-celery-1  | """
sketch-map-tool-celery-1  | Traceback (most recent call last):
sketch-map-tool-celery-1  |   File "/home/smt/.conda/envs/smt/lib/python3.11/site-packages/billiard/pool.py", line 683, in on_hard_timeout
sketch-map-tool-celery-1  |     raise TimeLimitExceeded(job._timeout)
sketch-map-tool-celery-1  | billiard.exceptions.TimeLimitExceeded: TimeLimitExceeded(900,)
sketch-map-tool-celery-1  | """
sketch-map-tool-celery-1  | 2024-03-25 12:40:20,362 - ERROR - request.py - on_timeout - Hard time limit (900s) exceeded for sketch_map_tool.tasks.georeference_sketch_maps[52c7f63b-2814-4618-b7af-0b1b774897c5]
sketch-map-tool-celery-1  | 2024-03-25 12:40:20,672 - ERROR - request.py - on_failure - Task handler raised error: TimeLimitExceeded(900)
sketch-map-tool-celery-1  | Traceback (most recent call last):
sketch-map-tool-celery-1  |   File "/home/smt/.conda/envs/smt/lib/python3.11/site-packages/billiard/pool.py", line 683, in on_hard_timeout
sketch-map-tool-celery-1  |     raise TimeLimitExceeded(job._timeout)
sketch-map-tool-celery-1  | billiard.einfo.ExceptionWithTraceback: 
sketch-map-tool-celery-1  | """
sketch-map-tool-celery-1  | Traceback (most recent call last):
sketch-map-tool-celery-1  |   File "/home/smt/.conda/envs/smt/lib/python3.11/site-packages/billiard/pool.py", line 683, in on_hard_timeout
sketch-map-tool-celery-1  |     raise TimeLimitExceeded(job._timeout)
sketch-map-tool-celery-1  | billiard.exceptions.TimeLimitExceeded: TimeLimitExceeded(900,)
sketch-map-tool-celery-1  | """
sketch-map-tool-celery-1  | 2024-03-25 12:40:20,672 - ERROR - request.py - on_timeout - Hard time limit (900s) exceeded for sketch_map_tool.tasks.digitize_sketches[72263cf6-27ce-4f4a-80e8-255472114184]
sketch-map-tool-celery-1  | Process 'ForkPoolWorker-2' pid:28 exited with 'signal 9 (SIGKILL)'
sketch-map-tool-celery-1  | Process 'ForkPoolWorker-4' pid:30 exited with 'signal 9 (SIGKILL)'

Map Frame: filename

Sketch Map: 13

matthiasschaub commented 5 months ago

Brisk is just able to find a ridiculus number of keypoints for this set of images. This leads naturaly to a longer processing time.

def limit_keypoints(keypoints: list, descriptors: NDArray, max_keypoints: int = 50000) -> tuple:
        """Limit the number of keypoints and descriptors """
        if len(keypoints) > max_keypoints:
            #randomly select max_keypoints
            indices = np.random.choice(len(keypoints), max_keypoints, replace=False)
            keypoints = [keypoints[i] for i in indices]
            descriptors = descriptors[indices]

        return keypoints, descriptors

kpts1, desc1 = limit_keypoints(kpts1, desc1)
kpts2, desc2 = limit_keypoints(kpts2, desc2)

(@itisacloud)

matthiasschaub commented 5 months ago

Other solutions could be to reduce the resolution of the input image (#421)

solo2307 commented 5 months ago

@matthiasschaub and @itisacloud , you are both correct. Two suggested ways , the limitation of descriptors' number and reduction of image size, are ok with me. However, I would suggest to go to image resizing:

h, w,  _ = temp_img.shape # the default template size is (1587, 1867)
img_clipped = clip(cv2.resize(img_raw, (w, h)), temp_img)