Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2f83d0d54 |
@@ -15,18 +15,33 @@
|
||||
*/
|
||||
import useMessagesSnackbar from '@/common/components/snackbar/useDemoMessagesSnackbar';
|
||||
import useVideo from '@/common/components/video/editor/useVideo';
|
||||
import {activeTrackletObjectIdAtom, labelTypeAtom} from '@/demo/atoms';
|
||||
import {
|
||||
activeTrackletObjectIdAtom,
|
||||
isStreamingAtom,
|
||||
labelTypeAtom,
|
||||
} from '@/demo/atoms';
|
||||
import {Add} from '@carbon/icons-react';
|
||||
import {useSetAtom} from 'jotai';
|
||||
import {useAtomValue, useSetAtom} from 'jotai';
|
||||
|
||||
export default function AddObjectButton() {
|
||||
const video = useVideo();
|
||||
const setActiveTrackletId = useSetAtom(activeTrackletObjectIdAtom);
|
||||
const isStreaming = useAtomValue(isStreamingAtom);
|
||||
const setLabelType = useSetAtom(labelTypeAtom);
|
||||
const {enqueueMessage} = useMessagesSnackbar();
|
||||
|
||||
async function addObject() {
|
||||
enqueueMessage('addObjectClick');
|
||||
|
||||
// Make sure video is paused to allow users adding clicks. Either abort
|
||||
// streaming if propagation is running or simply pause the video.
|
||||
if (isStreaming) {
|
||||
void video?.abortStreamMasks();
|
||||
} else {
|
||||
video?.pause();
|
||||
}
|
||||
|
||||
// Create tracklet for video.
|
||||
const tracklet = await video?.createTracklet();
|
||||
if (tracklet != null) {
|
||||
setActiveTrackletId(tracklet.id);
|
||||
|
||||
@@ -24,8 +24,7 @@ export const DEMO_SHORT_NAME = 'SAM 2 Demo';
|
||||
export const RESEARCH_BY_META_AI = 'By Meta FAIR';
|
||||
export const DEMO_FRIENDLY_NAME = 'Segment Anything 2 Demo';
|
||||
export const VIDEO_WATERMARK_TEXT = `Modified with ${DEMO_FRIENDLY_NAME}`;
|
||||
export const PROJECT_GITHUB_URL =
|
||||
'https://github.com/facebookresearch/sam2';
|
||||
export const PROJECT_GITHUB_URL = 'https://github.com/facebookresearch/sam2';
|
||||
export const AIDEMOS_URL = 'https://aidemos.meta.com';
|
||||
export const ABOUT_URL = 'https://ai.meta.com/sam2';
|
||||
export const EMAIL_ADDRESS = 'segment-anything@meta.com';
|
||||
|
||||
@@ -123,14 +123,9 @@ export const pointsAtom = atom<SegmentationPoint[]>(get => {
|
||||
export const labelTypeAtom = atom<'positive' | 'negative'>('positive');
|
||||
|
||||
export const isAddObjectEnabledAtom = atom<boolean>(get => {
|
||||
const session = get(sessionAtom);
|
||||
const trackletsInitialized = get(areTrackletObjectsInitializedAtom);
|
||||
const isObjectLimitReached = get(isTrackletObjectLimitReachedAtom);
|
||||
return (
|
||||
session?.ranPropagation === false &&
|
||||
trackletsInitialized &&
|
||||
!isObjectLimitReached
|
||||
);
|
||||
return trackletsInitialized && !isObjectLimitReached;
|
||||
});
|
||||
|
||||
export const codeEditorOpenedAtom = atom<boolean>(false);
|
||||
|
||||
Reference in New Issue
Block a user