Delete foren
Browse files- foren/__pycache__/utils.cpython-310.pyc +0 -0
- foren/app.py +0 -68
- foren/render.yaml +0 -7
- foren/requirements.txt +0 -4
- foren/static/styles.css +0 -31
- foren/templates/index.html +0 -306
- foren/templates/netlify.toml +0 -8
- foren/utils.py +0 -83
foren/__pycache__/utils.cpython-310.pyc
DELETED
|
Binary file (2.67 kB)
|
|
|
foren/app.py
DELETED
|
@@ -1,68 +0,0 @@
|
|
| 1 |
-
from flask import Flask, request, send_from_directory, jsonify, render_template
|
| 2 |
-
from werkzeug.utils import secure_filename
|
| 3 |
-
import os
|
| 4 |
-
import cv2
|
| 5 |
-
from utils import apply_watermark, apply_watermark_to_video
|
| 6 |
-
|
| 7 |
-
app = Flask(__name__)
|
| 8 |
-
app.config['UPLOAD_FOLDER'] = 'uploads'
|
| 9 |
-
app.config['RESULT_FOLDER'] = 'results'
|
| 10 |
-
|
| 11 |
-
@app.route('/')
|
| 12 |
-
def index():
|
| 13 |
-
return render_template('index.html')
|
| 14 |
-
|
| 15 |
-
@app.route('/upload', methods=['POST'])
|
| 16 |
-
def upload_file():
|
| 17 |
-
video_file = request.files.get('video')
|
| 18 |
-
image_file = request.files.get('image')
|
| 19 |
-
text = request.form['text']
|
| 20 |
-
watermark_image = request.files.get('watermark_image')
|
| 21 |
-
use_image = False
|
| 22 |
-
|
| 23 |
-
if video_file:
|
| 24 |
-
filename = secure_filename(video_file.filename)
|
| 25 |
-
input_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
|
| 26 |
-
video_file.save(input_path)
|
| 27 |
-
watermark_image_path = text
|
| 28 |
-
if watermark_image:
|
| 29 |
-
watermark_filename = secure_filename(watermark_image.filename)
|
| 30 |
-
watermark_image_path = os.path.join(app.config['UPLOAD_FOLDER'], watermark_filename)
|
| 31 |
-
watermark_image.save(watermark_image_path)
|
| 32 |
-
use_image = True
|
| 33 |
-
watermarked_filename = 'watermarked_' + filename
|
| 34 |
-
watermarked_path = os.path.join(app.config['RESULT_FOLDER'], watermarked_filename)
|
| 35 |
-
apply_watermark_to_video(input_path, watermarked_path, watermark_image_path, frame_skip=2, use_image=use_image)
|
| 36 |
-
return jsonify({
|
| 37 |
-
'original_url': filename,
|
| 38 |
-
'watermarked_url': watermarked_filename
|
| 39 |
-
})
|
| 40 |
-
elif image_file and text:
|
| 41 |
-
filename = secure_filename(image_file.filename)
|
| 42 |
-
input_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
|
| 43 |
-
image_file.save(input_path)
|
| 44 |
-
img = cv2.imread(input_path)
|
| 45 |
-
watermarked_img = apply_watermark(img, text)
|
| 46 |
-
watermarked_filename = 'watermarked_' + filename
|
| 47 |
-
watermarked_path = os.path.join(app.config['RESULT_FOLDER'], watermarked_filename)
|
| 48 |
-
cv2.imwrite(watermarked_path, watermarked_img)
|
| 49 |
-
return jsonify({
|
| 50 |
-
'original_url': filename,
|
| 51 |
-
'watermarked_url': watermarked_filename
|
| 52 |
-
})
|
| 53 |
-
return 'Invalid request', 400
|
| 54 |
-
|
| 55 |
-
@app.route('/uploads/<filename>')
|
| 56 |
-
def uploaded_file(filename):
|
| 57 |
-
return send_from_directory(app.config['UPLOAD_FOLDER'], filename)
|
| 58 |
-
|
| 59 |
-
@app.route('/results/<filename>')
|
| 60 |
-
def result_file(filename):
|
| 61 |
-
return send_from_directory(app.config['RESULT_FOLDER'], filename)
|
| 62 |
-
|
| 63 |
-
if __name__ == '__main__':
|
| 64 |
-
if not os.path.exists(app.config['UPLOAD_FOLDER']):
|
| 65 |
-
os.makedirs(app.config['UPLOAD_FOLDER'])
|
| 66 |
-
if not os.path.exists(app.config['RESULT_FOLDER']):
|
| 67 |
-
os.makedirs(app.config['RESULT_FOLDER'])
|
| 68 |
-
app.run(host='0.0.0.0', port=5000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foren/render.yaml
DELETED
|
@@ -1,7 +0,0 @@
|
|
| 1 |
-
services:
|
| 2 |
-
- type: web
|
| 3 |
-
name: flask-backend
|
| 4 |
-
env: python
|
| 5 |
-
plan: free
|
| 6 |
-
buildCommand: pip install -r requirements.txt
|
| 7 |
-
startCommand: python app.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foren/requirements.txt
DELETED
|
@@ -1,4 +0,0 @@
|
|
| 1 |
-
Flask
|
| 2 |
-
numpy
|
| 3 |
-
opencv-python-headless
|
| 4 |
-
werkzeug
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foren/static/styles.css
DELETED
|
@@ -1,31 +0,0 @@
|
|
| 1 |
-
body {
|
| 2 |
-
font-family: Arial, sans-serif;
|
| 3 |
-
margin: 20px;
|
| 4 |
-
}
|
| 5 |
-
|
| 6 |
-
h1 {
|
| 7 |
-
text-align: center;
|
| 8 |
-
}
|
| 9 |
-
|
| 10 |
-
form {
|
| 11 |
-
display: flex;
|
| 12 |
-
flex-direction: column;
|
| 13 |
-
align-items: center;
|
| 14 |
-
margin-bottom: 20px;
|
| 15 |
-
}
|
| 16 |
-
|
| 17 |
-
form div {
|
| 18 |
-
margin: 10px 0;
|
| 19 |
-
}
|
| 20 |
-
|
| 21 |
-
button {
|
| 22 |
-
padding: 10px 20px;
|
| 23 |
-
font-size: 16px;
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
img, video {
|
| 27 |
-
margin: 10px 0;
|
| 28 |
-
border: 1px solid #ccc;
|
| 29 |
-
padding: 5px;
|
| 30 |
-
background-color: #f9f9f9;
|
| 31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foren/templates/index.html
DELETED
|
@@ -1,306 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8">
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>Watermark Application</title>
|
| 7 |
-
<style>
|
| 8 |
-
body {
|
| 9 |
-
font-family: Arial, sans-serif;
|
| 10 |
-
background-color: #333;
|
| 11 |
-
margin: 0;
|
| 12 |
-
padding: 0;
|
| 13 |
-
display: flex;
|
| 14 |
-
flex-direction: column;
|
| 15 |
-
align-items: center;
|
| 16 |
-
justify-content: center;
|
| 17 |
-
min-height: 100vh;
|
| 18 |
-
color: #ccc;
|
| 19 |
-
}
|
| 20 |
-
nav {
|
| 21 |
-
margin-bottom: 20px;
|
| 22 |
-
}
|
| 23 |
-
nav a {
|
| 24 |
-
color: #ccc;
|
| 25 |
-
text-decoration: none;
|
| 26 |
-
margin: 0 10px;
|
| 27 |
-
}
|
| 28 |
-
h1 {
|
| 29 |
-
margin-bottom: 20px;
|
| 30 |
-
color: #fff;
|
| 31 |
-
}
|
| 32 |
-
.container {
|
| 33 |
-
display: flex;
|
| 34 |
-
justify-content: center;
|
| 35 |
-
width: 80%;
|
| 36 |
-
flex-direction: column;
|
| 37 |
-
align-items: center;
|
| 38 |
-
}
|
| 39 |
-
.upload-area {
|
| 40 |
-
border: 2px dashed #009688;
|
| 41 |
-
padding: 20px;
|
| 42 |
-
width: 100%;
|
| 43 |
-
max-width: 500px;
|
| 44 |
-
text-align: center;
|
| 45 |
-
background-color: #444;
|
| 46 |
-
margin-bottom: 20px;
|
| 47 |
-
cursor: pointer;
|
| 48 |
-
color: #ccc;
|
| 49 |
-
}
|
| 50 |
-
.upload-area:hover {
|
| 51 |
-
background-color: #555;
|
| 52 |
-
}
|
| 53 |
-
form {
|
| 54 |
-
display: flex;
|
| 55 |
-
flex-direction: column;
|
| 56 |
-
align-items: center;
|
| 57 |
-
width: 100%;
|
| 58 |
-
}
|
| 59 |
-
input[type="file"], input[type="text"], input[type="submit"] {
|
| 60 |
-
margin-bottom: 10px;
|
| 61 |
-
padding: 10px;
|
| 62 |
-
width: 80%;
|
| 63 |
-
max-width: 300px;
|
| 64 |
-
background-color: #555;
|
| 65 |
-
color: #ccc;
|
| 66 |
-
border: 1px solid #666;
|
| 67 |
-
}
|
| 68 |
-
input[type="submit"] {
|
| 69 |
-
background-color: #009688;
|
| 70 |
-
color: white;
|
| 71 |
-
border: none;
|
| 72 |
-
cursor: pointer;
|
| 73 |
-
}
|
| 74 |
-
input[type="submit"]:hover {
|
| 75 |
-
background-color: #00796b;
|
| 76 |
-
}
|
| 77 |
-
.result-section {
|
| 78 |
-
margin: 20px 0;
|
| 79 |
-
padding-top: 20px;
|
| 80 |
-
border-top: 1px solid #444;
|
| 81 |
-
}
|
| 82 |
-
.result-section video, .result-section img {
|
| 83 |
-
max-width: 80%;
|
| 84 |
-
height: auto;
|
| 85 |
-
display: block;
|
| 86 |
-
margin: 10px auto;
|
| 87 |
-
}
|
| 88 |
-
footer {
|
| 89 |
-
text-align: center;
|
| 90 |
-
margin-top: 20px;
|
| 91 |
-
}
|
| 92 |
-
footer a {
|
| 93 |
-
color: #009688;
|
| 94 |
-
text-decoration: none;
|
| 95 |
-
font-size: 18px;
|
| 96 |
-
}
|
| 97 |
-
footer a:hover {
|
| 98 |
-
text-decoration: underline;
|
| 99 |
-
}
|
| 100 |
-
</style>
|
| 101 |
-
<script>
|
| 102 |
-
function switchLanguage(lang) {
|
| 103 |
-
document.documentElement.lang = lang;
|
| 104 |
-
if(lang === 'ko') {
|
| 105 |
-
document.getElementById('title').innerText = '워터마킹 애플리케이션';
|
| 106 |
-
document.getElementById('uploadVideoLabel').innerText = '비디오 업로드';
|
| 107 |
-
document.getElementById('uploadImageLabel').innerText = '이미지 업로드';
|
| 108 |
-
document.getElementById('watermarkTextPlaceholder').placeholder = '워터마크 텍스트';
|
| 109 |
-
document.getElementById('submit').value = '업로드';
|
| 110 |
-
document.getElementById('dragDropTextVideo').innerText = '여기에 비디오 파일을 드롭하세요';
|
| 111 |
-
document.getElementById('dragDropTextImage').innerText = '여기에 이미지 파일을 드롭하세요';
|
| 112 |
-
} else {
|
| 113 |
-
document.getElementById('title').innerText = 'Watermark Application';
|
| 114 |
-
document.getElementById('uploadVideoLabel').innerText = 'Upload Video';
|
| 115 |
-
document.getElementById('uploadImageLabel').innerText = 'Upload Image';
|
| 116 |
-
document.getElementById('watermarkTextPlaceholder').placeholder = 'Watermark Text';
|
| 117 |
-
document.getElementById('submit').value = 'Upload';
|
| 118 |
-
document.getElementById('dragDropTextVideo').innerText = 'Drag & Drop your video here';
|
| 119 |
-
document.getElementById('dragDropTextImage').innerText = 'Drag & Drop your image here';
|
| 120 |
-
}
|
| 121 |
-
}
|
| 122 |
-
|
| 123 |
-
document.addEventListener('DOMContentLoaded', function() {
|
| 124 |
-
var videoDropArea = document.getElementById('video-drop-area');
|
| 125 |
-
var imageDropArea = document.getElementById('image-drop-area');
|
| 126 |
-
|
| 127 |
-
function preventDefaults(e) {
|
| 128 |
-
e.preventDefault();
|
| 129 |
-
e.stopPropagation();
|
| 130 |
-
}
|
| 131 |
-
|
| 132 |
-
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
|
| 133 |
-
videoDropArea.addEventListener(eventName, preventDefaults, false);
|
| 134 |
-
imageDropArea.addEventListener(eventName, preventDefaults, false);
|
| 135 |
-
});
|
| 136 |
-
|
| 137 |
-
videoDropArea.addEventListener('click', () => document.getElementById('video_file').click());
|
| 138 |
-
imageDropArea.addEventListener('click', () => document.getElementById('image_file').click());
|
| 139 |
-
|
| 140 |
-
document.getElementById('video_file').addEventListener('change', function(e) {
|
| 141 |
-
var file = this.files[0];
|
| 142 |
-
updatePreview(file, 'video-preview', 'video-drop-area');
|
| 143 |
-
});
|
| 144 |
-
|
| 145 |
-
document.getElementById('image_file').addEventListener('change', function(e) {
|
| 146 |
-
var file = this.files[0];
|
| 147 |
-
updatePreview(file, 'image-preview', 'image-drop-area');
|
| 148 |
-
});
|
| 149 |
-
|
| 150 |
-
function updatePreview(file, previewId, dropAreaId) {
|
| 151 |
-
var preview = document.getElementById(previewId);
|
| 152 |
-
var dropArea = document.getElementById(dropAreaId);
|
| 153 |
-
|
| 154 |
-
if (preview) {
|
| 155 |
-
preview.remove();
|
| 156 |
-
}
|
| 157 |
-
|
| 158 |
-
if (file.type.startsWith('video/')) {
|
| 159 |
-
var video = document.createElement('video');
|
| 160 |
-
video.id = previewId;
|
| 161 |
-
video.src = URL.createObjectURL(file);
|
| 162 |
-
video.controls = true;
|
| 163 |
-
video.style.maxWidth = '100%';
|
| 164 |
-
video.style.height = 'auto';
|
| 165 |
-
dropArea.appendChild(video);
|
| 166 |
-
} else if (file.type.startsWith('image/')) {
|
| 167 |
-
var img = document.createElement('img');
|
| 168 |
-
img.id = previewId;
|
| 169 |
-
img.src = URL.createObjectURL(file);
|
| 170 |
-
img.style.maxWidth = '100%';
|
| 171 |
-
img.style.height = 'auto';
|
| 172 |
-
dropArea.appendChild(img);
|
| 173 |
-
}
|
| 174 |
-
}
|
| 175 |
-
|
| 176 |
-
document.querySelector('form').addEventListener('submit', function(event) {
|
| 177 |
-
event.preventDefault();
|
| 178 |
-
|
| 179 |
-
var formData = new FormData(this);
|
| 180 |
-
fetch('/upload', {
|
| 181 |
-
method: 'POST',
|
| 182 |
-
body: formData
|
| 183 |
-
})
|
| 184 |
-
.then(response => response.json())
|
| 185 |
-
.then(data => {
|
| 186 |
-
displayResults(data);
|
| 187 |
-
})
|
| 188 |
-
.catch(error => {
|
| 189 |
-
console.error('Error:', error);
|
| 190 |
-
});
|
| 191 |
-
});
|
| 192 |
-
|
| 193 |
-
function displayResults(data) {
|
| 194 |
-
var resultSection = document.getElementById('result');
|
| 195 |
-
resultSection.innerHTML = '';
|
| 196 |
-
|
| 197 |
-
if (data.original_url) {
|
| 198 |
-
var originalHeading = document.createElement('h2');
|
| 199 |
-
originalHeading.textContent = 'Original File';
|
| 200 |
-
resultSection.appendChild(originalHeading);
|
| 201 |
-
|
| 202 |
-
if (data.original_url.endsWith('png') || data.original_url.endsWith('jpg') || data.original_url.endsWith('jpeg')) {
|
| 203 |
-
var originalImg = document.createElement('img');
|
| 204 |
-
originalImg.src = `/uploads/${data.original_url}`;
|
| 205 |
-
originalImg.alt = 'Original Image';
|
| 206 |
-
resultSection.appendChild(originalImg);
|
| 207 |
-
} else {
|
| 208 |
-
var originalVideo = document.createElement('video');
|
| 209 |
-
originalVideo.src = `/uploads/${data.original_url}`;
|
| 210 |
-
originalVideo.controls = true;
|
| 211 |
-
resultSection.appendChild(originalVideo);
|
| 212 |
-
}
|
| 213 |
-
|
| 214 |
-
var originalLink = document.createElement('a');
|
| 215 |
-
originalLink.href = `/uploads/${data.original_url}`;
|
| 216 |
-
originalLink.textContent = 'Download Original';
|
| 217 |
-
originalLink.download = true;
|
| 218 |
-
resultSection.appendChild(originalLink);
|
| 219 |
-
}
|
| 220 |
-
|
| 221 |
-
if (data.watermarked_url) {
|
| 222 |
-
var watermarkedHeading = document.createElement('h2');
|
| 223 |
-
watermarkedHeading.textContent = 'Watermarked File';
|
| 224 |
-
resultSection.appendChild(watermarkedHeading);
|
| 225 |
-
|
| 226 |
-
if (data.watermarked_url.endsWith('png') || data.watermarked_url.endsWith('jpg') || data.watermarked_url.endsWith('jpeg')) {
|
| 227 |
-
var watermarkedImg = document.createElement('img');
|
| 228 |
-
watermarkedImg.src = `/results/${data.watermarked_url}`;
|
| 229 |
-
watermarkedImg.alt = 'Watermarked Image';
|
| 230 |
-
resultSection.appendChild(watermarkedImg);
|
| 231 |
-
} else {
|
| 232 |
-
var watermarkedVideo = document.createElement('video');
|
| 233 |
-
watermarkedVideo.src = `/results/${data.watermarked_url}`;
|
| 234 |
-
watermarkedVideo.controls = true;
|
| 235 |
-
resultSection.appendChild(watermarkedVideo);
|
| 236 |
-
}
|
| 237 |
-
|
| 238 |
-
var watermarkedLink = document.createElement('a');
|
| 239 |
-
watermarkedLink.href = `/results/${data.watermarked_url}`;
|
| 240 |
-
watermarkedLink.textContent = 'Download Watermarked';
|
| 241 |
-
watermarkedLink.download = true;
|
| 242 |
-
resultSection.appendChild(watermarkedLink);
|
| 243 |
-
}
|
| 244 |
-
|
| 245 |
-
if (data.extracted_url) {
|
| 246 |
-
var extractedHeading = document.createElement('h2');
|
| 247 |
-
extractedHeading.textContent = 'Extracted Watermark';
|
| 248 |
-
resultSection.appendChild(extractedHeading);
|
| 249 |
-
|
| 250 |
-
if (data.extracted_url.endsWith('png') || data.extracted_url.endsWith('jpg') || data.extracted_url.endsWith('jpeg')) {
|
| 251 |
-
var extractedImg = document.createElement('img');
|
| 252 |
-
extractedImg.src = `/extracts/${data.extracted_url}`;
|
| 253 |
-
extractedImg.alt = 'Extracted Watermark Image';
|
| 254 |
-
resultSection.appendChild(extractedImg);
|
| 255 |
-
} else {
|
| 256 |
-
var extractedVideo = document.createElement('video');
|
| 257 |
-
extractedVideo.src = `/extracts/${data.extracted_url}`;
|
| 258 |
-
extractedVideo.controls = true;
|
| 259 |
-
resultSection.appendChild(extractedVideo);
|
| 260 |
-
}
|
| 261 |
-
|
| 262 |
-
var extractedLink = document.createElement('a');
|
| 263 |
-
extractedLink.href = `/extracts/${data.extracted_url}`;
|
| 264 |
-
extractedLink.textContent = 'Download Extracted';
|
| 265 |
-
extractedLink.download = true;
|
| 266 |
-
resultSection.appendChild(extractedLink);
|
| 267 |
-
}
|
| 268 |
-
}
|
| 269 |
-
});
|
| 270 |
-
</script>
|
| 271 |
-
</head>
|
| 272 |
-
<body>
|
| 273 |
-
<nav>
|
| 274 |
-
<a href="#" onclick="switchLanguage('en')">English</a> | <a href="#" onclick="switchLanguage('ko')">한국어</a>
|
| 275 |
-
</nav>
|
| 276 |
-
<h1 id="title">Watermark Application</h1>
|
| 277 |
-
<div class="container">
|
| 278 |
-
<div id="video-drop-area" class="upload-area">
|
| 279 |
-
<p id="dragDropTextVideo">Drag & Drop your video here</p>
|
| 280 |
-
<p>or</p>
|
| 281 |
-
<p>Click to select a file</p>
|
| 282 |
-
</div>
|
| 283 |
-
<div id="image-drop-area" class="upload-area">
|
| 284 |
-
<p id="dragDropTextImage">Drag & Drop your image here</p>
|
| 285 |
-
<p>or</p>
|
| 286 |
-
<p>Click to select a file</p>
|
| 287 |
-
</div>
|
| 288 |
-
</div>
|
| 289 |
-
<div class="container">
|
| 290 |
-
<form action="/upload" method="post" enctype="multipart/form-data">
|
| 291 |
-
<input type="file" id="video_file" name="video" accept="video/*" style="display: none;">
|
| 292 |
-
<input type="file" id="image_file" name="image" accept="image/*" style="display: none;">
|
| 293 |
-
<input type="text" id="watermarkTextPlaceholder" name="text" placeholder="Watermark Text">
|
| 294 |
-
<input type="file" id="watermark_image" name="watermark_image" accept="image/*" style="display: none;">
|
| 295 |
-
<label for="watermark_image" id="uploadWatermarkImageLabel" style="cursor: pointer;">Upload Watermark Image</label>
|
| 296 |
-
<input type="submit" id="submit" value="Upload">
|
| 297 |
-
</form>
|
| 298 |
-
</div>
|
| 299 |
-
|
| 300 |
-
<section class="result-section" id="result"></section>
|
| 301 |
-
|
| 302 |
-
<footer>
|
| 303 |
-
<a href="{{ url_for('index') }}">Go to Main Page</a>
|
| 304 |
-
</footer>
|
| 305 |
-
</body>
|
| 306 |
-
</html>
|
|
|
|
|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
|
|
|
|
|
|
|
foren/utils.py
DELETED
|
@@ -1,83 +0,0 @@
|
|
| 1 |
-
import numpy as np
|
| 2 |
-
import cv2
|
| 3 |
-
import random
|
| 4 |
-
from concurrent.futures import ThreadPoolExecutor
|
| 5 |
-
import os
|
| 6 |
-
|
| 7 |
-
# 공통 유틸리티 함수
|
| 8 |
-
def resize_image(img, shape):
|
| 9 |
-
return cv2.resize(img, (shape[1], shape[0]), interpolation=cv2.INTER_LINEAR)
|
| 10 |
-
|
| 11 |
-
def text_to_image(text, img_shape, font=cv2.FONT_HERSHEY_SIMPLEX, font_scale=3, thickness=5):
|
| 12 |
-
text_size = cv2.getTextSize(text, font, font_scale, thickness)[0]
|
| 13 |
-
text_x = (img_shape[1] - text_size[0]) // 2
|
| 14 |
-
text_y = (img_shape[0] + text_size[1]) // 2
|
| 15 |
-
|
| 16 |
-
img_wm = np.zeros(img_shape, dtype=np.uint8)
|
| 17 |
-
cv2.putText(img_wm, text, (text_x, text_y), font, font_scale, (255, 255, 255), thickness)
|
| 18 |
-
|
| 19 |
-
return img_wm
|
| 20 |
-
|
| 21 |
-
# 이미지 워터마크 함수
|
| 22 |
-
def apply_watermark(img, text_or_image_path, alpha=5, use_image=False):
|
| 23 |
-
height, width = img.shape[:2]
|
| 24 |
-
if use_image and os.path.exists(text_or_image_path):
|
| 25 |
-
img_wm = cv2.imread(text_or_image_path, cv2.IMREAD_GRAYSCALE)
|
| 26 |
-
img_wm = resize_image(img_wm, (height, width))
|
| 27 |
-
else:
|
| 28 |
-
img_wm = text_to_image(text_or_image_path, (height, width))
|
| 29 |
-
|
| 30 |
-
img_f = np.fft.fft2(img)
|
| 31 |
-
|
| 32 |
-
y_random_indices, x_random_indices = list(range(height)), list(range(width))
|
| 33 |
-
random.seed(2021)
|
| 34 |
-
random.shuffle(x_random_indices)
|
| 35 |
-
random.shuffle(y_random_indices)
|
| 36 |
-
|
| 37 |
-
random_wm = np.zeros(img.shape, dtype=np.uint8)
|
| 38 |
-
|
| 39 |
-
for y in range(height):
|
| 40 |
-
for x in range(width):
|
| 41 |
-
random_wm[y_random_indices[y], x_random_indices[x]] = img_wm[y, x]
|
| 42 |
-
|
| 43 |
-
result_f = img_f + alpha * random_wm
|
| 44 |
-
|
| 45 |
-
result = np.fft.ifft2(result_f)
|
| 46 |
-
result = np.real(result)
|
| 47 |
-
result = result.astype(np.uint8)
|
| 48 |
-
|
| 49 |
-
return result
|
| 50 |
-
|
| 51 |
-
# 비디오 워터마크 함수
|
| 52 |
-
def process_video(input_path, output_path, process_function, *args, frame_skip=1):
|
| 53 |
-
try:
|
| 54 |
-
cap = cv2.VideoCapture(input_path)
|
| 55 |
-
fourcc = cv2.VideoWriter_fourcc(*'XVID')
|
| 56 |
-
fps = cap.get(cv2.CAP_PROP_FPS)
|
| 57 |
-
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
| 58 |
-
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
| 59 |
-
out = cv2.VideoWriter(output_path, fourcc, fps, (width, height))
|
| 60 |
-
|
| 61 |
-
frame_idx = 0
|
| 62 |
-
with ThreadPoolExecutor() as executor:
|
| 63 |
-
futures = []
|
| 64 |
-
while cap.isOpened():
|
| 65 |
-
ret, frame = cap.read()
|
| 66 |
-
if not ret:
|
| 67 |
-
break
|
| 68 |
-
|
| 69 |
-
if frame_idx % frame_skip == 0:
|
| 70 |
-
futures.append(executor.submit(process_function, frame, *args))
|
| 71 |
-
frame_idx += 1
|
| 72 |
-
|
| 73 |
-
for future in futures:
|
| 74 |
-
processed_frame = future.result()
|
| 75 |
-
out.write(processed_frame)
|
| 76 |
-
|
| 77 |
-
cap.release()
|
| 78 |
-
out.release()
|
| 79 |
-
except Exception as e:
|
| 80 |
-
print(f"Error processing video: {e}")
|
| 81 |
-
|
| 82 |
-
def apply_watermark_to_video(input_path, output_path, text_or_image_path, frame_skip=1, use_image=False):
|
| 83 |
-
process_video(input_path, output_path, apply_watermark, text_or_image_path, frame_skip, use_image)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|