Skip to content

Commit

Permalink
Fix position of the shape images to sent request to decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
Rub21 committed Jun 22, 2023
1 parent 4dcecb9 commit ac653a9
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 21 deletions.
49 changes: 33 additions & 16 deletions src/components/EncodeItem.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useContext, useState } from "react";
import React, { useContext } from "react";
import { MainContext } from "../contexts/MainContext";
import { MapContext } from "../contexts/MapContext";
import { BsViewList, BsTrash } from "react-icons/bs";

Check warning on line 4 in src/components/EncodeItem.js

View workflow job for this annotation

GitHub Actions / lint

'BsViewList' is defined but never used

Check warning on line 4 in src/components/EncodeItem.js

View workflow job for this annotation

GitHub Actions / test

'BsViewList' is defined but never used

export const EncodeItem = ({ encodeItem, index }) => {
const { encodeItems, dispatchEncodeItems } = useContext(MainContext);

const { map } = useContext(MapContext);

const zoomTo = (encodeItem) => {
Expand All @@ -23,20 +23,37 @@ export const EncodeItem = ({ encodeItem, index }) => {
payload: [...newEncodeItems],
});
};

const handleRemove = () => {
console.log(encodeItems);
const updatedEncodeItems = encodeItems.filter((_, i) => i !== index);
console.log(updatedEncodeItems);
// dispatchEncodeItems({
// type: "CACHING_ENCODED",
// payload: updatedEncodeItems,
// });
};

return (
<img
src={encodeItem.canvas}
alt={`Encode Image ${index + 1}`}
className={`w-100 h-100 object-cover opacity-100 transition-opacity duration-500 ease-in-out transform hover:opacity-100 mb-2 ${
encodeItem.selected ? "border border-blue-300 border-2" : ""
}`}
style={{
width: "100px",
height: "100px",
}}
onClick={() => {
zoomTo(encodeItem);
}}
/>
<div className="relative">
<img

Check warning on line 39 in src/components/EncodeItem.js

View workflow job for this annotation

GitHub Actions / lint

Redundant alt attribute. Screen-readers already announce `img` tags as an image. You don’t need to use the words `image`, `photo,` or `picture` (or any specified custom words) in the alt prop

Check warning on line 39 in src/components/EncodeItem.js

View workflow job for this annotation

GitHub Actions / test

Redundant alt attribute. Screen-readers already announce `img` tags as an image. You don’t need to use the words `image`, `photo,` or `picture` (or any specified custom words) in the alt prop
src={encodeItem.canvas}
alt={`Encode Image ${index + 1}`}
className={`w-100 h-100 object-cover opacity-100 transition-opacity duration-500 ease-in-out transform hover:opacity-100 mb-2 ${
encodeItem.selected ? "border border-blue-300 border-2" : ""
}`}
style={{
width: "100px",
height: "100px",
}}
onClick={() => zoomTo(encodeItem)}
/>
<button
className="absolute bottom-1 right-1 bg-red-500 hover:bg-red-600 text-white rounded w-4 h-4 cursor-pointer flex items-center justify-center"
onClick={handleRemove}
>
<BsTrash />
</button>
</div>
);
};
4 changes: 2 additions & 2 deletions src/components/MenuEncodeItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export const MenuEncodeItems = () => {
return (
<div className="mt-8">
<div
className="absolute bg-white bg-opacity-50 p-1 right-0 top-0 bottom-20px scroll-smooth hover:scroll-auto overflow-auto overscroll-y-contain"
style={{ maxHeight: "100%", height: "100%" }}
className="absolute bg-white bg-opacity-50 p-1 right-0 top-0 scroll-smooth hover:scroll-auto overflow-auto overscroll-y-contain"
style={{ maxHeight: `calc(100% - 30px)`, height: `calc(100% - 30px)` }}
>
<div className="w-100">
{encodeItems.map((encodeItem, index) => (
Expand Down
1 change: 1 addition & 0 deletions src/components/SegmentAM.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export const SegmentAM = ({ setLoading }) => {
}
//=================== Need decode ===================
try {
console.log(requestProps);
const decodeRespJson = await getDecode(requestProps);
const classMaxId = getMaxIdPerClass(items, activeClass);
const features = sam2Geojson(
Expand Down
2 changes: 1 addition & 1 deletion src/static/apis.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"gpuEncodeAPI": "https://sas-gpu.ds.io",
"cpuDecodeAPI": "https://sas.ds.io",
"cpuDecodeAPI": "http://192.168.1.95:7080",
"samAPI": "http://segme-gpuel-ekfao79wi98g-617785108.us-east-1.elb.amazonaws.com",
"geojsonAPI": "https://bfokggy4ac.execute-api.us-east-1.amazonaws.com"
}
1 change: 0 additions & 1 deletion src/store/indexedDB.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const getAllData = (db) => {
const objectStore = transaction.objectStore("encodeiItems");
const getAllRequest = objectStore.getAll();
getAllRequest.onsuccess = (event) => {
console.log(event);
const result = event.target.result;
resolve(result);
};
Expand Down
1 change: 1 addition & 0 deletions src/utils/featureCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const sam2Geojson = (
const features = [];
for (let index = 0; index < ListGeoms.length; index++) {
const strGeom = ListGeoms[index];
// console.log(strGeom)
const geom = JSON.parse(strGeom);
const properties = {
class: activeClass.name,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/samApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const getPropertiesRequest = (map, pointsSelector) => {
const crs = projection.getCode();
const bbox = view.calculateExtent(map.getSize());
const reqProps = {
image_shape: [imgWidth, imgHeight],
image_shape: [imgHeight, imgWidth],
input_label: 1,
input_point: coords[0],
crs,
Expand Down

0 comments on commit ac653a9

Please sign in to comment.