face-recognition / frontend /src /components /ResultDisplay.jsx
orik-ss's picture
Claude Opus 4.5
Initial deployment - Face verification demo
ccb7e46
Raw History Blame Contribute Delete
5.07 kB
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