Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lb-components): Update trackID self-incrementing logic #610

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 34 additions & 6 deletions packages/lb-utils/src/PointCloudUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,19 @@ class PointCloudUtils {
return arr;
}

/**
* Get the next available trackID for the point cloud data.
* filter out more than 4 digits marking ID self-increment logic, for example:
* the label ID has: 1, 2, 3, 1001, then mark again when marking the label ID should be 4 (currently 1002)
* special scenarios, assuming that the annotation ID 1-1001 are all used up, and can be marked again when the self-increment for 1002
*
* @param {Object} params - An object containing the parameters for the function.
* @param {Array<{ result: string }>} params.imgList - An array of objects containing the point cloud data.
* @param {number} [params.step=1] - The step size for processing the data.
* @param {IPointCloudBox[]} params.extraBoxList - An array of additional boxes for the point cloud data.
* @param {IPointCloudSphere[]} [params.extraSphereList] - An array of additional spheres for the point cloud data.
* @returns {number} - The next available trackID.
*/
public static getNextTrackID({
imgList,
step = 1,
Expand All @@ -515,16 +528,31 @@ class PointCloudUtils {
extraBoxList: IPointCloudBox[];
extraSphereList?: IPointCloudSphere[];
}) {
let trackID = 1;
const boxList = this.getAllPointCloudResult({ imgList, step, extraBoxList, extraSphereList });

boxList.forEach((data: IPointCloudBox | IPointCloudSphere) => {
if (typeof data?.trackID === 'number' && data.trackID >= trackID) {
trackID = data.trackID + 1;
const existingTrackIDs = boxList
.map((data) => data.trackID)
.filter((trackID): trackID is number => typeof trackID === 'number')
.sort((a, b) => a - b);

if (existingTrackIDs.length === 0) {
return 1;
}

let index = existingTrackIDs.length - 1;
while (index >= 0) {
const currentID = existingTrackIDs[index];

if (currentID && currentID < 1000 && !existingTrackIDs.includes(currentID + 1)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 1000?it seem that hard is not need

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The background of demand in the user community

return currentID + 1;
}
});

return trackID;
index--;
}

return existingTrackIDs[existingTrackIDs.length - 1]
? existingTrackIDs[existingTrackIDs.length - 1] + 1
: 1;
}

public static batchUpdateTrackID({
Expand Down
Loading