File size: 7,259 Bytes
a566fb0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
import React from 'react';
import { motion } from 'framer-motion';

export function BoundingBoxDemo() {
  return (
    <div className="relative w-full max-w-md mx-auto aspect-video bg-gradient-to-br from-slate-800 to-slate-900 rounded-2xl overflow-hidden border border-white/10">

      {/* Simulated Image */}

      <div className="absolute inset-0 flex items-center justify-center">

        <div className="text-6xl">πŸš—</div>

      </div>

      

      {/* Animated Bounding Box */}

      <motion.div

        className="absolute border-4 border-cyan-400 rounded-lg"

        initial={{ opacity: 0, scale: 0.8 }}

        animate={{ 

          opacity: [0, 1, 1, 1],

          scale: [0.8, 1, 1, 1],

        }}

        transition={{ duration: 2, repeat: Infinity, repeatDelay: 1 }}

        style={{

          top: '25%',

          left: '30%',

          width: '40%',

          height: '50%'

        }}

      >

        <motion.div

          className="absolute -top-8 left-0 bg-cyan-400 text-slate-900 px-3 py-1 rounded-lg text-sm font-bold"

          initial={{ opacity: 0, y: 10 }}

          animate={{ opacity: [0, 1, 1, 0], y: [10, 0, 0, -10] }}

          transition={{ duration: 2, repeat: Infinity, repeatDelay: 1, delay: 0.3 }}

        >

          Car 98%

        </motion.div>

        

        {/* Corner markers */}

        {[

          { top: -4, left: -4 },

          { top: -4, right: -4 },

          { bottom: -4, left: -4 },

          { bottom: -4, right: -4 }

        ].map((pos, i) => (

          <motion.div

            key={i}

            className="absolute w-3 h-3 bg-cyan-400 rounded-full"

            style={pos}

            animate={{ scale: [1, 1.3, 1] }}

            transition={{ duration: 1, repeat: Infinity, delay: i * 0.1 }}

          />

        ))}

      </motion.div>

    </div>
  );
}

export function PoseSkeletonDemo() {
  const keypoints = [
    { id: 'head', x: 50, y: 10, label: 'Head' },
    { id: 'neck', x: 50, y: 22 },
    { id: 'lshoulder', x: 35, y: 25 },
    { id: 'rshoulder', x: 65, y: 25 },
    { id: 'lelbow', x: 25, y: 40 },
    { id: 'relbow', x: 75, y: 40 },
    { id: 'lwrist', x: 20, y: 55 },
    { id: 'rwrist', x: 80, y: 55 },
    { id: 'hip', x: 50, y: 50 },
    { id: 'lhip', x: 40, y: 52 },
    { id: 'rhip', x: 60, y: 52 },
    { id: 'lknee', x: 38, y: 70 },
    { id: 'rknee', x: 62, y: 70 },
    { id: 'lankle', x: 35, y: 90 },
    { id: 'rankle', x: 65, y: 90 },
  ];

  const bones = [
    ['head', 'neck'],
    ['neck', 'lshoulder'],
    ['neck', 'rshoulder'],
    ['lshoulder', 'lelbow'],
    ['rshoulder', 'relbow'],
    ['lelbow', 'lwrist'],
    ['relbow', 'rwrist'],
    ['neck', 'hip'],
    ['hip', 'lhip'],
    ['hip', 'rhip'],
    ['lhip', 'lknee'],
    ['rhip', 'rknee'],
    ['lknee', 'lankle'],
    ['rknee', 'rankle'],
  ];

  const getPoint = (id) => keypoints.find(k => k.id === id);

  return (
    <div className="relative w-full max-w-sm mx-auto aspect-[3/4] bg-gradient-to-br from-purple-900/50 to-pink-900/50 rounded-2xl overflow-hidden border border-white/10">

      <svg className="w-full h-full" viewBox="0 0 100 100">

        {/* Bones */}

        {bones.map(([from, to], i) => {

          const p1 = getPoint(from);

          const p2 = getPoint(to);

          return (

            <motion.line

              key={i}

              x1={p1.x}

              y1={p1.y}

              x2={p2.x}

              y2={p2.y}

              stroke="url(#boneGradient)"

              strokeWidth="2"

              strokeLinecap="round"

              initial={{ pathLength: 0, opacity: 0 }}

              animate={{ pathLength: 1, opacity: 1 }}

              transition={{ duration: 0.5, delay: i * 0.05 }}

            />

          );

        })}



        {/* Keypoints */}

        {keypoints.map((point, i) => (

          <motion.circle

            key={point.id}

            cx={point.x}

            cy={point.y}

            r="3"

            fill="#EC4899"

            initial={{ scale: 0 }}

            animate={{ scale: [1, 1.3, 1] }}

            transition={{ 

              scale: { duration: 1, repeat: Infinity, delay: i * 0.1 },

              default: { delay: i * 0.05 }

            }}

          />

        ))}



        <defs>

          <linearGradient id="boneGradient" x1="0%" y1="0%" x2="100%" y2="100%">

            <stop offset="0%" stopColor="#8B5CF6" />

            <stop offset="100%" stopColor="#EC4899" />

          </linearGradient>

        </defs>

      </svg>

    </div>
  );
}

export function EmotionFaceDemo() {
  const emotions = [
    { emoji: '😊', label: 'Happy', color: 'from-yellow-400 to-orange-400' },
    { emoji: '😒', label: 'Sad', color: 'from-blue-400 to-indigo-400' },
    { emoji: '😠', label: 'Angry', color: 'from-red-400 to-rose-400' },
    { emoji: '😲', label: 'Surprise', color: 'from-purple-400 to-pink-400' },
    { emoji: '😐', label: 'Neutral', color: 'from-gray-400 to-slate-400' },
  ];

  const [currentEmotion, setCurrentEmotion] = React.useState(0);

  React.useEffect(() => {
    const interval = setInterval(() => {
      setCurrentEmotion((prev) => (prev + 1) % emotions.length);
    }, 2000);
    return () => clearInterval(interval);
  }, []);

  const emotion = emotions[currentEmotion];

  return (
    <div className="relative w-full max-w-sm mx-auto">

      <motion.div

        key={currentEmotion}

        initial={{ scale: 0.8, opacity: 0 }}

        animate={{ scale: 1, opacity: 1 }}

        exit={{ scale: 0.8, opacity: 0 }}

        className="aspect-square bg-gradient-to-br from-slate-800 to-slate-900 rounded-3xl border border-white/10 flex flex-col items-center justify-center"

      >

        <motion.div 

          className="text-8xl mb-4"

          animate={{ scale: [1, 1.1, 1] }}

          transition={{ duration: 1, repeat: Infinity }}

        >

          {emotion.emoji}

        </motion.div>

        

        <motion.div

          className={`px-6 py-2 rounded-full bg-gradient-to-r ${emotion.color} text-white font-bold text-lg`}

          initial={{ y: 20, opacity: 0 }}

          animate={{ y: 0, opacity: 1 }}

          transition={{ delay: 0.2 }}

        >

          {emotion.label}

        </motion.div>

      </motion.div>



      {/* Confidence Bars */}

      <div className="mt-6 space-y-2">

        {emotions.map((e, i) => (

          <div key={i} className="flex items-center gap-3">

            <span className="text-xl w-8">{e.emoji}</span>

            <div className="flex-1 h-3 bg-white/10 rounded-full overflow-hidden">

              <motion.div

                className={`h-full bg-gradient-to-r ${e.color}`}

                initial={{ width: 0 }}

                animate={{ width: i === currentEmotion ? '95%' : `${Math.random() * 30 + 5}%` }}

                transition={{ duration: 0.5 }}

              />

            </div>

            <span className="text-white/60 text-sm w-12 text-right">

              {i === currentEmotion ? '95%' : `${Math.floor(Math.random() * 20 + 5)}%`}

            </span>

          </div>

        ))}

      </div>

    </div>
  );
}