nutri / index.html
qhjk's picture
import cv2 from pyzbar.pyzbar import decode import webbrowser # Optional: Base URL if barcode contains only a product ID BASE_URL = "https://www.example.com/product/" def open_url(data): if data.startswith("http://") or data.startswith("https://"): webbrowser.open(data) else: # Assume it's a product ID; redirect to your platform webbrowser.open(BASE_URL + data) def main(): cap = cv2.VideoCapture(0) print("Scanning... Press 'q' to quit.") scanned = set() while True: ret, frame = cap.read() if not ret: break for barcode in decode(frame): barcode_data = barcode.data.decode('utf-8') if barcode_data not in scanned: print(f"Scanned: {barcode_data}") scanned.add(barcode_data) open_url(barcode_data) pts = barcode.polygon if len(pts) > 4: pts = pts[:4] for i in range(len(pts)): cv2.line(frame, pts[i], pts[(i+1) % 4], (0,255,0), 2) cv2.putText(frame, barcode_data, (pts[0].x, pts[0].y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.6, (255, 0, 0), 2) cv2.imshow("Barcode Scanner", frame) if cv2.waitKey(1) == ord('q'): break cap.release() cv2.destroyAllWindows() if __name__ == "__main__": main() create a dedicated website - Initial Deployment
08fab6f verified
Raw
History Blame Contribute Delete
28.8 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>QR & Barcode Scanner Pro</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.scanner-container {
position: relative;
overflow: hidden;
border-radius: 1rem;
box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}
.scanner-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(180deg, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0) 50%, rgba(0,0,0,0.1) 100%);
pointer-events: none;
}
.scanner-frame {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 70%;
height: 30%;
border: 4px solid rgba(74, 222, 128, 0.8);
border-radius: 0.5rem;
box-shadow: 0 0 0 10000px rgba(0, 0, 0, 0.5);
pointer-events: none;
}
.scan-animation {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 4px;
background: linear-gradient(to right, transparent, rgba(74, 222, 128, 0.8), transparent);
animation: scan 2s linear infinite;
}
@keyframes scan {
0% { top: 0; }
100% { top: 100%; }
}
.history-item {
transition: all 0.3s ease;
}
.history-item:hover {
transform: translateY(-2px);
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
</style>
</head>
<body class="bg-gray-50 min-h-screen">
<!-- Header -->
<header class="bg-gradient-to-r from-green-500 to-emerald-600 text-white shadow-lg">
<div class="container mx-auto px-4 py-6">
<div class="flex justify-between items-center">
<div class="flex items-center space-x-2">
<i class="fas fa-qrcode text-3xl"></i>
<h1 class="text-2xl font-bold">ScanPro</h1>
</div>
<nav class="hidden md:block">
<ul class="flex space-x-6">
<li><a href="#" class="hover:underline">Home</a></li>
<li><a href="#features" class="hover:underline">Features</a></li>
<li><a href="#how-it-works" class="hover:underline">How It Works</a></li>
<li><a href="#contact" class="hover:underline">Contact</a></li>
</ul>
</nav>
<button class="md:hidden text-2xl">
<i class="fas fa-bars"></i>
</button>
</div>
</div>
</header>
<!-- Hero Section -->
<section class="py-12 px-4">
<div class="container mx-auto flex flex-col md:flex-row items-center">
<div class="md:w-1/2 mb-8 md:mb-0 md:pr-8">
<h2 class="text-4xl font-bold text-gray-800 mb-4">Scan Any Barcode or QR Code Instantly</h2>
<p class="text-gray-600 mb-6 text-lg">Our advanced scanner detects all major barcode formats and QR codes, providing instant access to product information, websites, and more.</p>
<div class="flex flex-col sm:flex-row space-y-4 sm:space-y-0 sm:space-x-4">
<button class="bg-emerald-500 hover:bg-emerald-600 text-white font-bold py-3 px-6 rounded-lg shadow-md transition duration-300 flex items-center justify-center">
<i class="fas fa-play mr-2"></i> Start Scanning
</button>
<button class="bg-white hover:bg-gray-100 text-gray-800 font-bold py-3 px-6 rounded-lg border border-gray-300 shadow-sm transition duration-300 flex items-center justify-center">
<i class="fas fa-download mr-2"></i> Download App
</button>
</div>
</div>
<div class="md:w-1/2 relative">
<div class="scanner-container bg-black aspect-video w-full">
<div class="scanner-overlay"></div>
<div class="scanner-frame">
<div class="scan-animation"></div>
</div>
<video id="scanner-video" class="w-full h-full object-cover" autoplay playsinline></video>
</div>
<div class="mt-4 text-center">
<p class="text-gray-600">Point your camera at a barcode or QR code to scan</p>
</div>
</div>
</div>
</section>
<!-- Scanner Interface -->
<section class="py-12 px-4 bg-gray-100" id="scanner">
<div class="container mx-auto">
<div class="text-center mb-12">
<h2 class="text-3xl font-bold text-gray-800 mb-2">Powerful Scanner Interface</h2>
<div class="w-20 h-1 bg-emerald-500 mx-auto"></div>
</div>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
<!-- Scanner Panel -->
<div class="lg:col-span-2 bg-white rounded-xl shadow-md overflow-hidden">
<div class="scanner-container bg-black aspect-video w-full">
<div class="scanner-overlay"></div>
<div class="scanner-frame">
<div class="scan-animation"></div>
</div>
<video id="scanner-video-real" class="w-full h-full object-cover" autoplay playsinline></video>
</div>
<div class="p-6">
<div class="flex justify-center space-x-4 mb-4">
<button id="start-scan" class="bg-emerald-500 hover:bg-emerald-600 text-white font-bold py-2 px-6 rounded-lg shadow-md transition duration-300 flex items-center">
<i class="fas fa-play mr-2"></i> Start Scan
</button>
<button id="stop-scan" class="bg-red-500 hover:bg-red-600 text-white font-bold py-2 px-6 rounded-lg shadow-md transition duration-300 flex items-center">
<i class="fas fa-stop mr-2"></i> Stop
</button>
<button id="toggle-flash" class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-6 rounded-lg shadow-md transition duration-300 flex items-center">
<i class="fas fa-lightbulb mr-2"></i> Flash
</button>
</div>
<div class="text-center">
<p id="scan-status" class="text-gray-600">Ready to scan</p>
</div>
</div>
</div>
<!-- Scan Results -->
<div class="bg-white rounded-xl shadow-md overflow-hidden">
<div class="bg-emerald-500 text-white p-4">
<h3 class="text-xl font-bold flex items-center">
<i class="fas fa-history mr-2"></i> Scan History
</h3>
</div>
<div class="p-4">
<div id="scan-results" class="space-y-3 max-h-96 overflow-y-auto">
<div class="text-center py-8 text-gray-400">
<i class="fas fa-barcode text-4xl mb-2"></i>
<p>No scans yet</p>
</div>
</div>
</div>
<div class="p-4 border-t">
<div class="flex items-center justify-between">
<span class="text-gray-600">Total scans:</span>
<span id="total-scans" class="font-bold">0</span>
</div>
<button id="clear-history" class="mt-4 w-full bg-gray-200 hover:bg-gray-300 text-gray-800 py-2 px-4 rounded transition duration-300">
<i class="fas fa-trash-alt mr-2"></i> Clear History
</button>
</div>
</div>
</div>
</div>
</section>
<!-- Features -->
<section class="py-12 px-4" id="features">
<div class="container mx-auto">
<div class="text-center mb-12">
<h2 class="text-3xl font-bold text-gray-800 mb-2">Advanced Features</h2>
<div class="w-20 h-1 bg-emerald-500 mx-auto"></div>
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
<div class="bg-white p-6 rounded-xl shadow-md hover:shadow-lg transition duration-300">
<div class="text-emerald-500 text-4xl mb-4">
<i class="fas fa-bolt"></i>
</div>
<h3 class="text-xl font-bold mb-2">Lightning Fast</h3>
<p class="text-gray-600">Our optimized scanning algorithm detects codes in milliseconds, even in low light conditions.</p>
</div>
<div class="bg-white p-6 rounded-xl shadow-md hover:shadow-lg transition duration-300">
<div class="text-emerald-500 text-4xl mb-4">
<i class="fas fa-qrcode"></i>
</div>
<h3 class="text-xl font-bold mb-2">Multiple Formats</h3>
<p class="text-gray-600">Supports all major barcode types including QR, UPC, EAN, Code 39, and more.</p>
</div>
<div class="bg-white p-6 rounded-xl shadow-md hover:shadow-lg transition duration-300">
<div class="text-emerald-500 text-4xl mb-4">
<i class="fas fa-link"></i>
</div>
<h3 class="text-xl font-bold mb-2">Smart Actions</h3>
<p class="text-gray-600">Automatically opens URLs, shows product info, or saves to your history based on scan content.</p>
</div>
</div>
</div>
</section>
<!-- How It Works -->
<section class="py-12 px-4 bg-gray-100" id="how-it-works">
<div class="container mx-auto">
<div class="text-center mb-12">
<h2 class="text-3xl font-bold text-gray-800 mb-2">How It Works</h2>
<div class="w-20 h-1 bg-emerald-500 mx-auto"></div>
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
<div class="flex flex-col items-center text-center">
<div class="bg-white w-16 h-16 rounded-full flex items-center justify-center text-emerald-500 text-2xl shadow-md mb-4">
<span class="font-bold">1</span>
</div>
<h3 class="text-xl font-bold mb-2">Point Your Camera</h3>
<p class="text-gray-600">Aim your device's camera at the barcode or QR code you want to scan.</p>
</div>
<div class="flex flex-col items-center text-center">
<div class="bg-white w-16 h-16 rounded-full flex items-center justify-center text-emerald-500 text-2xl shadow-md mb-4">
<span class="font-bold">2</span>
</div>
<h3 class="text-xl font-bold mb-2">Automatic Detection</h3>
<p class="text-gray-600">Our system instantly recognizes and decodes the information.</p>
</div>
<div class="flex flex-col items-center text-center">
<div class="bg-white w-16 h-16 rounded-full flex items-center justify-center text-emerald-500 text-2xl shadow-md mb-4">
<span class="font-bold">3</span>
</div>
<h3 class="text-xl font-bold mb-2">Get Results</h3>
<p class="text-gray-600">View the decoded information or let the app take the appropriate action.</p>
</div>
</div>
</div>
</section>
<!-- Contact -->
<section class="py-12 px-4" id="contact">
<div class="container mx-auto max-w-4xl">
<div class="text-center mb-12">
<h2 class="text-3xl font-bold text-gray-800 mb-2">Contact Us</h2>
<div class="w-20 h-1 bg-emerald-500 mx-auto"></div>
</div>
<div class="bg-white rounded-xl shadow-md overflow-hidden">
<div class="md:flex">
<div class="md:w-1/2 bg-emerald-500 text-white p-8 flex flex-col justify-center">
<h3 class="text-2xl font-bold mb-4">Get In Touch</h3>
<div class="space-y-4">
<div class="flex items-start">
<i class="fas fa-envelope mt-1 mr-4"></i>
<div>
<h4 class="font-bold">Email</h4>
<p>support@scanpro.com</p>
</div>
</div>
<div class="flex items-start">
<i class="fas fa-phone-alt mt-1 mr-4"></i>
<div>
<h4 class="font-bold">Phone</h4>
<p>+1 (555) 123-4567</p>
</div>
</div>
<div class="flex items-start">
<i class="fas fa-map-marker-alt mt-1 mr-4"></i>
<div>
<h4 class="font-bold">Address</h4>
<p>123 Tech Street, Silicon Valley, CA 94000</p>
</div>
</div>
</div>
</div>
<div class="md:w-1/2 p-8">
<form>
<div class="mb-4">
<label class="block text-gray-700 mb-2" for="name">Name</label>
<input type="text" id="name" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-emerald-500">
</div>
<div class="mb-4">
<label class="block text-gray-700 mb-2" for="email">Email</label>
<input type="email" id="email" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-emerald-500">
</div>
<div class="mb-4">
<label class="block text-gray-700 mb-2" for="message">Message</label>
<textarea id="message" rows="4" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-emerald-500"></textarea>
</div>
<button type="submit" class="w-full bg-emerald-500 hover:bg-emerald-600 text-white font-bold py-3 px-4 rounded-lg shadow-md transition duration-300">
Send Message
</button>
</form>
</div>
</div>
</div>
</div>
</section>
<!-- Footer -->
<footer class="bg-gray-800 text-white py-8 px-4">
<div class="container mx-auto">
<div class="flex flex-col md:flex-row justify-between items-center">
<div class="mb-4 md:mb-0">
<div class="flex items-center space-x-2">
<i class="fas fa-qrcode text-2xl"></i>
<span class="text-xl font-bold">ScanPro</span>
</div>
<p class="text-gray-400 mt-2">The ultimate barcode and QR code scanning solution.</p>
</div>
<div class="flex space-x-6">
<a href="#" class="text-gray-400 hover:text-white transition duration-300">
<i class="fab fa-facebook-f"></i>
</a>
<a href="#" class="text-gray-400 hover:text-white transition duration-300">
<i class="fab fa-twitter"></i>
</a>
<a href="#" class="text-gray-400 hover:text-white transition duration-300">
<i class="fab fa-instagram"></i>
</a>
<a href="#" class="text-gray-400 hover:text-white transition duration-300">
<i class="fab fa-github"></i>
</a>
</div>
</div>
<div class="border-t border-gray-700 mt-6 pt-6 text-center text-gray-400">
<p>&copy; 2023 ScanPro. All rights reserved.</p>
</div>
</div>
</footer>
<!-- Scanner Modal -->
<div id="scan-modal" class="fixed inset-0 bg-black bg-opacity-75 flex items-center justify-center z-50 hidden">
<div class="bg-white rounded-xl max-w-2xl w-full mx-4 overflow-hidden">
<div class="bg-emerald-500 text-white p-4 flex justify-between items-center">
<h3 class="text-xl font-bold">Scan Result</h3>
<button id="close-modal" class="text-white hover:text-gray-200">
<i class="fas fa-times"></i>
</button>
</div>
<div class="p-6">
<div id="modal-content" class="mb-4">
<p id="scan-data" class="break-all p-3 bg-gray-100 rounded mb-4"></p>
<div id="scan-type" class="inline-block px-3 py-1 rounded-full text-xs font-semibold mb-4"></div>
</div>
<div class="flex flex-col sm:flex-row space-y-3 sm:space-y-0 sm:space-x-3">
<button id="open-url" class="bg-emerald-500 hover:bg-emerald-600 text-white font-bold py-2 px-4 rounded-lg transition duration-300 flex-1 flex items-center justify-center">
<i class="fas fa-external-link-alt mr-2"></i> Open Link
</button>
<button id="copy-text" class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded-lg transition duration-300 flex-1 flex items-center justify-center">
<i class="fas fa-copy mr-2"></i> Copy Text
</button>
<button id="save-scan" class="bg-purple-500 hover:bg-purple-600 text-white font-bold py-2 px-4 rounded-lg transition duration-300 flex-1 flex items-center justify-center">
<i class="fas fa-save mr-2"></i> Save
</button>
</div>
</div>
</div>
</div>
<script>
// Mock scanner functionality for demonstration
document.addEventListener('DOMContentLoaded', function() {
const startBtn = document.getElementById('start-scan');
const stopBtn = document.getElementById('stop-scan');
const toggleFlashBtn = document.getElementById('toggle-flash');
const scanStatus = document.getElementById('scan-status');
const scanResults = document.getElementById('scan-results');
const totalScans = document.getElementById('total-scans');
const clearHistoryBtn = document.getElementById('clear-history');
const scanModal = document.getElementById('scan-modal');
const closeModal = document.getElementById('close-modal');
const scanData = document.getElementById('scan-data');
const scanType = document.getElementById('scan-type');
const openUrlBtn = document.getElementById('open-url');
const copyTextBtn = document.getElementById('copy-text');
const saveScanBtn = document.getElementById('save-scan');
let scanCount = 0;
let isScanning = false;
let flashOn = false;
// Sample barcodes for demonstration
const sampleBarcodes = [
{ type: 'QR Code', data: 'https://www.example.com/product/12345' },
{ type: 'UPC-A', data: '012345678905' },
{ type: 'EAN-13', data: '5901234123457' },
{ type: 'Code 39', data: 'ABC-123-XYZ' },
{ type: 'QR Code', data: 'https://github.com/scanpro' }
];
// Start scanning
startBtn.addEventListener('click', function() {
if (isScanning) return;
isScanning = true;
scanStatus.textContent = 'Scanning... Point camera at barcode';
startBtn.classList.remove('bg-emerald-500');
startBtn.classList.add('bg-emerald-700');
// Simulate scanning with random delay
setTimeout(() => {
if (isScanning) {
const randomBarcode = sampleBarcodes[Math.floor(Math.random() * sampleBarcodes.length)];
showScanResult(randomBarcode.type, randomBarcode.data);
}
}, Math.random() * 3000 + 1000);
});
// Stop scanning
stopBtn.addEventListener('click', function() {
isScanning = false;
scanStatus.textContent = 'Ready to scan';
startBtn.classList.remove('bg-emerald-700');
startBtn.classList.add('bg-emerald-500');
});
// Toggle flash
toggleFlashBtn.addEventListener('click', function() {
flashOn = !flashOn;
if (flashOn) {
toggleFlashBtn.classList.remove('bg-blue-500');
toggleFlashBtn.classList.add('bg-blue-600');
toggleFlashBtn.innerHTML = '<i class="fas fa-lightbulb mr-2"></i> Flash On';
} else {
toggleFlashBtn.classList.remove('bg-blue-600');
toggleFlashBtn.classList.add('bg-blue-500');
toggleFlashBtn.innerHTML = '<i class="fas fa-lightbulb mr-2"></i> Flash';
}
});
// Show scan result
function showScanResult(type, data) {
scanCount++;
totalScans.textContent = scanCount;
// Add to history
const now = new Date();
const timeString = now.toLocaleTimeString();
const dateString = now.toLocaleDateString();
const resultItem = document.createElement('div');
resultItem.className = 'history-item bg-gray-50 p-3 rounded-lg cursor-pointer hover:bg-emerald-50';
resultItem.innerHTML = `
<div class="flex justify-between items-start">
<div>
<div class="font-semibold truncate">${data}</div>
<div class="flex items-center mt-1">
<span class="inline-block px-2 py-1 rounded-full text-xs font-semibold ${type === 'QR Code' ? 'bg-purple-100 text-purple-800' : 'bg-blue-100 text-blue-800'}">${type}</span>
<span class="text-gray-500 text-xs ml-2">${timeString}</span>
</div>
</div>
<i class="fas fa-chevron-right text-gray-400 mt-1"></i>
</div>
`;
resultItem.addEventListener('click', () => {
showModal(type, data);
});
// Add to top of results
if (scanResults.firstChild && scanResults.firstChild.classList.contains('text-center')) {
scanResults.innerHTML = '';
}
scanResults.insertBefore(resultItem, scanResults.firstChild);
// Show modal
showModal(type, data);
// Continue scanning if still active
if (isScanning) {
setTimeout(() => {
if (isScanning) {
const randomBarcode = sampleBarcodes[Math.floor(Math.random() * sampleBarcodes.length)];
showScanResult(randomBarcode.type, randomBarcode.data);
}
}, Math.random() * 3000 + 1000);
}
}
// Show modal with scan details
function showModal(type, data) {
scanData.textContent = data;
scanType.textContent = type;
scanType.className = 'inline-block px-3 py-1 rounded-full text-xs font-semibold mb-4 ' +
(type === 'QR Code' ? 'bg-purple-100 text-purple-800' : 'bg-blue-100 text-blue-800');
// Show/hide open URL button based on content
if (data.startsWith('http://') || data.startsWith('https://')) {
openUrlBtn.classList.remove('hidden');
} else {
openUrlBtn.classList.add('hidden');
}
scanModal.classList.remove('hidden');
}
// Close modal
closeModal.addEventListener('click', () => {
scanModal.classList.add('hidden');
});
// Open URL
openUrlBtn.addEventListener('click', () => {
window.open(scanData.textContent, '_blank');
});
// Copy text
copyTextBtn.addEventListener('click', () => {
navigator.clipboard.writeText(scanData.textContent).then(() => {
const originalText = copyTextBtn.innerHTML;
copyTextBtn.innerHTML = '<i class="fas fa-check mr-2"></i> Copied!';
setTimeout(() => {
copyTextBtn.innerHTML = originalText;
}, 2000);
});
});
// Save scan
saveScanBtn.addEventListener('click', () => {
const originalText = saveScanBtn.innerHTML;
saveScanBtn.innerHTML = '<i class="fas fa-check mr-2"></i> Saved!';
setTimeout(() => {
saveScanBtn.innerHTML = originalText;
}, 2000);
});
// Clear history
clearHistoryBtn.addEventListener('click', () => {
scanResults.innerHTML = `
<div class="text-center py-8 text-gray-400">
<i class="fas fa-barcode text-4xl mb-2"></i>
<p>No scans yet</p>
</div>
`;
scanCount = 0;
totalScans.textContent = '0';
});
// Demo: Auto-scan after page load for demo purposes
setTimeout(() => {
startBtn.click();
}, 1500);
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=qhjk/nutri" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>