|
175 | 175 | <div class="space-y-4"> |
176 | 176 | <div class="relative overflow-hidden rounded-xl border-2 border-purple-200 bg-purple-50"> |
177 | 177 | <img |
| 178 | + bind:this={imgElement} |
| 179 | + on:load={handleImageLoad} |
178 | 180 | src="/{data.image.imageUrl}" |
179 | 181 | alt="Detection {data.detection.id}" |
180 | 182 | class="h-auto w-full object-contain" |
181 | 183 | /> |
182 | 184 | <!-- Bounding Box Overlay --> |
183 | | - <svg |
184 | | - class="pointer-events-none absolute left-0 top-0 h-full w-full" |
185 | | - viewBox="0 0 100 100" |
186 | | - preserveAspectRatio="none" |
187 | | - > |
188 | | - <rect |
189 | | - x={data.detection.bbox[0]} |
190 | | - y={data.detection.bbox[1]} |
191 | | - width={data.detection.bbox[2] - data.detection.bbox[0]} |
192 | | - height={data.detection.bbox[3] - data.detection.bbox[1]} |
193 | | - fill="none" |
194 | | - stroke="rgb(74, 222, 128)" |
195 | | - stroke-width="4" |
196 | | - vector-effect="non-scaling-stroke" |
197 | | - /> |
198 | | - </svg> |
| 185 | + {#if imageWidth > 0 && imageHeight > 0} |
| 186 | + <svg |
| 187 | + class="pointer-events-none absolute left-0 top-0 h-full w-full" |
| 188 | + viewBox="0 0 {imageWidth} {imageHeight}" |
| 189 | + preserveAspectRatio="none" |
| 190 | + > |
| 191 | + <rect |
| 192 | + x={data.detection.bbox[0]} |
| 193 | + y={data.detection.bbox[1]} |
| 194 | + width={data.detection.bbox[2] - data.detection.bbox[0]} |
| 195 | + height={data.detection.bbox[3] - data.detection.bbox[1]} |
| 196 | + fill="none" |
| 197 | + stroke="rgb(74, 222, 128)" |
| 198 | + stroke-width="4" |
| 199 | + vector-effect="non-scaling-stroke" |
| 200 | + /> |
| 201 | + </svg> |
| 202 | + {/if} |
199 | 203 | </div> |
200 | 204 | <div class="rounded-lg border border-purple-200 bg-purple-50 p-4"> |
201 | 205 | <h3 class="mb-2 font-semibold text-purple-900">Image Information</h3> |
|
0 commit comments