File size: 5,067 Bytes
ccb7e46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { motion } from 'framer-motion'
import { CheckCircle2, XCircle } from 'lucide-react'

function ResultDisplay({ result, image1, image2 }) {
  const isMatch = result.match
  const similarity = Math.round(result.similarity * 100)

  return (
    <div className={`
      glass-card p-6 md:p-8 h-full relative overflow-hidden
      ${isMatch ? 'border-green-500/30' : 'border-red-500/30'}
    `}>
      {/* Background glow effect */}
      <div className={`
        absolute inset-0 opacity-20
        ${isMatch
          ? 'bg-gradient-radial from-green-500/30 via-transparent to-transparent'
          : 'bg-gradient-radial from-red-500/30 via-transparent to-transparent'
        }
      `} />

      {/* Content */}
      <div className="relative z-10">
        {/* Match Status Header */}
        <div className="text-center mb-6">
          <motion.div
            initial={{ scale: 0 }}
            animate={{ scale: 1 }}
            transition={{ type: 'spring', delay: 0.2 }}
            className={`
              inline-flex items-center justify-center w-16 h-16 rounded-full mb-4
              ${isMatch
                ? 'bg-green-500/20 match-indicator'
                : 'bg-red-500/20 no-match-indicator'
              }
            `}
          >
            {isMatch ? (
              <CheckCircle2 className="w-8 h-8 text-green-400" />
            ) : (
              <XCircle className="w-8 h-8 text-red-400" />
            )}
          </motion.div>

          <motion.h2
            initial={{ opacity: 0, y: 10 }}
            animate={{ opacity: 1, y: 0 }}
            transition={{ delay: 0.3 }}
            className={`text-3xl font-bold mb-2 ${isMatch ? 'text-green-400' : 'text-red-400'}`}
          >
            {isMatch ? 'Match Found' : 'No Match'}
          </motion.h2>

          <motion.p
            initial={{ opacity: 0 }}
            animate={{ opacity: 1 }}
            transition={{ delay: 0.4 }}
            className="text-gray-400 text-sm"
          >
            {isMatch
              ? 'The faces belong to the same person'
              : 'The faces belong to different people'
            }
          </motion.p>
        </div>

        {/* Face Comparison */}
        <div className="flex items-center justify-center gap-4 mb-6">
          {/* Image 1 */}
          <motion.div
            initial={{ opacity: 0, x: -20 }}
            animate={{ opacity: 1, x: 0 }}
            transition={{ delay: 0.4 }}
          >
            <div className={`
              w-24 h-24 md:w-32 md:h-32 rounded-xl overflow-hidden
              ring-2 ${isMatch ? 'ring-green-500/50' : 'ring-red-500/50'}
            `}>
              <img
                src={image1.preview}
                alt="Face 1"
                className="w-full h-full object-cover"
              />
            </div>
          </motion.div>

          {/* Percentage Circle */}
          <motion.div
            initial={{ opacity: 0, scale: 0.8 }}
            animate={{ opacity: 1, scale: 1 }}
            transition={{ delay: 0.5 }}
            className={`
              w-14 h-14 rounded-full flex items-center justify-center
              ${isMatch ? 'bg-green-500/20 text-green-400' : 'bg-red-500/20 text-red-400'}
            `}
          >
            <span className="text-lg font-bold">{similarity}%</span>
          </motion.div>

          {/* Image 2 */}
          <motion.div
            initial={{ opacity: 0, x: 20 }}
            animate={{ opacity: 1, x: 0 }}
            transition={{ delay: 0.4 }}
          >
            <div className={`
              w-24 h-24 md:w-32 md:h-32 rounded-xl overflow-hidden
              ring-2 ${isMatch ? 'ring-green-500/50' : 'ring-red-500/50'}
            `}>
              <img
                src={image2.preview}
                alt="Face 2"
                className="w-full h-full object-cover"
              />
            </div>
          </motion.div>
        </div>

        {/* Similarity Meter */}
        <motion.div
          initial={{ opacity: 0, y: 10 }}
          animate={{ opacity: 1, y: 0 }}
          transition={{ delay: 0.6 }}
        >
          <div className="flex justify-between text-xs text-gray-400 mb-1">
            <span>Similarity Score</span>
            <span>{similarity}%</span>
          </div>
          <div className="similarity-meter">
            <motion.div
              initial={{ width: 0 }}
              animate={{ width: `${similarity}%` }}
              transition={{ delay: 0.7, duration: 1, ease: 'easeOut' }}
              className={`similarity-fill ${isMatch
                ? 'bg-gradient-to-r from-green-500 to-emerald-400'
                : 'bg-gradient-to-r from-red-500 to-orange-400'
              }`}
            />
          </div>
          <div className="flex justify-between text-xs text-gray-600 mt-1">
            <span>0%</span>
            <span className="text-gray-500">Threshold: 70%</span>
            <span>100%</span>
          </div>
        </motion.div>
      </div>
    </div>
  )
}

export default ResultDisplay