Giter VIP home page Giter VIP logo

Comments (2)

hjing100 avatar hjing100 commented on July 17, 2024

代码:

import numpy as np
from blind_watermark import WaterMark
from blind_watermark import att
from blind_watermark.recover import estimate_crop_parameters, recover_crop
import cv2
import os
import time

start_time=time.time()

bwm = WaterMark(password_img=1, password_wm=1)

bwm.read_img('examples/pic-test/NI7A7780_1.JPG')
wm = 'hello world.My name is xiaoming,my phone is 1237868765456'
bwm.read_wm(wm, mode='str')
bwm.embed('examples/output/embedded.png')

len_wm = len(bwm.wm_bit)
print('Put down the length of wm_bit {len_wm}'.format(len_wm=len_wm))

ori_img_shape = cv2.imread('examples/pic-test/NI7A7780_1.JPG').shape[:2]

bwm1 = WaterMark(password_img=1, password_wm=1)
wm_extract = bwm1.extract('examples/output/embedded.png', wm_shape=len_wm, mode='str')
print("不攻击的提取结果:", wm_extract)

try:
assert wm == wm_extract, '不攻击 提取水印和原水印不一致'
except AssertionError:
print('不攻击 提取水印和原水印不一致')

(x1, y1, x2, y2), image_o_shape, score, scale_infer = estimate_crop_parameters(original_file='examples/output/embedded.png',
template_file='examples/output/cut.png',
scale=(0.5, 2), search_num=200)

print(f'Crop attack's estimate parameters: x1={x1},y1={y1},x2={x2},y2={y2}. score={score}')

recover_crop(template_file='examples/output/cut.png', output_file_name='examples/output/jieping2_huanyuan.png',
loc=(x1, y1, x2, y2), image_o_shape=image_o_shape)

bwm1 = WaterMark(password_wm=1, password_img=1)
wm_extract = bwm1.extract('examples/output/jieping2_huanyuan.png', wm_shape=len_wm, mode='str')
print("截屏攻击,不知道攻击参数。提取结果:", wm_extract)
try:
assert wm == wm_extract, '截屏攻击,不知道攻击参数 提取水印和原水印不一致'
except AssertionError:
print('截屏攻击,不知道攻击参数 提取水印和原水印不一致')

from blind_watermark.

guofei9987 avatar guofei9987 commented on July 17, 2024

#81 (comment)

from blind_watermark.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.