Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ww23 committed Mar 7, 2019
1 parent 63a7139 commit 26b874a
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ dependencies {
// compile 'org.bytedeco.javacpp-presets:opencv:4.0.1-1.4.4:windows-x86'
// compile 'org.bytedeco.javacpp-presets:opencv:4.0.1-1.4.4:windows-x86_64-gpu'
// compile 'org.bytedeco.javacpp-presets:opencv:4.0.1-1.4.4:windows-x86_64'
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.0'
}
66 changes: 66 additions & 0 deletions src/test/java/me/ww23/image/BlindWatermarkTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2019 ww23(https://github.com/ww23/BlindWatermark).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package me.ww23.image;

import me.ww23.image.coder.Decoder;
import me.ww23.image.coder.Encoder;
import me.ww23.image.coder.ImageEncoder;
import me.ww23.image.coder.TextEncoder;
import me.ww23.image.converter.Converter;
import me.ww23.image.converter.DctConverter;
import me.ww23.image.converter.DftConverter;
import me.ww23.image.util.Supporter;
import org.bytedeco.javacpp.opencv_core;
import org.junit.jupiter.api.Test;

import static org.bytedeco.javacpp.opencv_core.*;

class BlindWatermarkTest {

private Converter converterDct = new DctConverter();

@Test
void dct() {
Converter converter = new DctConverter();
Encoder encoder = new ImageEncoder(converter);
encoder.encode("image/gakki-src.png", "image/watermark.png", "image/gakki-dct-img-ec.jpg");
Decoder decoder = new Decoder(converter);
decoder.decode("image/gakki-dct-img-ec.jpg", "image/gakki-dct-img-dc.jpg");
encoder = new TextEncoder(converter);
encoder.encode("image/gakki-src.png", "test", "image/gakki-dct-text-ec.jpg");
decoder.decode("image/gakki-dct-text-ec.jpg", "image/gakki-dct-text-dc.jpg");
}

@Test
void dft() {
Converter converter = new DftConverter();
Encoder encoder = new ImageEncoder(converter);
encoder.encode("image/gakki-src.png", "image/watermark.png", "image/gakki-dft-img-ec.png");
Decoder decoder = new Decoder(converter);
decoder.decode("image/gakki-dft-img-ec.png", "image/gakki-dft-img-dc.png");
encoder = new TextEncoder(converter);
encoder.encode("image/gakki-src.png", "test", "image/gakki-dft-text-ec.png");
decoder.decode("image/gakki-dft-text-ec.png", "image/gakki-dft-text-dc.png");
}

@Test
void speedGray() {
opencv_core.Mat src = Supporter.read("image/gakki-src.png", CV_8U);
converterDct.addTextWatermark(converterDct.start(src), "test");
converterDct.inverse(src);
}
}

0 comments on commit 26b874a

Please sign in to comment.