diff --git a/windows/Acid.Cam.Qt.Windows.Project/.gitignore b/windows/Acid.Cam.Qt.Windows.Project/.gitignore new file mode 100755 index 0000000..c17485e --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/.gitignore @@ -0,0 +1 @@ +*DS_Store diff --git a/windows/Acid.Cam.Qt.Windows.Project/AcidCam.pro b/windows/Acid.Cam.Qt.Windows.Project/AcidCam.pro new file mode 100755 index 0000000..fa638f4 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/AcidCam.pro @@ -0,0 +1,17 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Wed Feb 1 02:31:01 2017 +###################################################################### + +TEMPLATE = app +TARGET = Acid.Cam.v2.Qt +RC_FILE = win-icon.rc +QT += core gui widgets +DEPENDPATH += . +INCLUDEPATH += . C:\OpenCV\opencv\build\include /usr/include/ /usr/local/include +LIBS += C:/OpenCV/opencv/build/x64/vc15/lib/opencv_world341.lib -luser32 -lgdi32 +#QMAKE_CXXFLAGS += -std=c++11 +RESOURCES += qresource.qrc + +# Input +HEADERS += main_window.h new_dialog.h plugin.h qtheaders.h select_image.h ac.h fractal.h display_window.h playback_thread.h ac.h fractal.h search_box.h goto_window.h +SOURCES += main.cpp main_window.cpp new_dialog.cpp plugin.cpp select_image.cpp fractal.cpp display_window.cpp playback_thread.cpp search_box.cpp fractal.cpp ac-alpha.cpp ac-obj.cpp ac-util.cpp ac-square.cpp ac-particle.cpp ac-grid.cpp ac-basic.cpp ac-filter1.cpp ac-filter2.cpp ac-filter3.cpp ac-filter4.cpp ac-filter5.cpp ac-filter6.cpp ac-filter7.cpp ac-filter8.cpp ac-filter9.cpp ac-filter10.cpp ac-filter11.cpp ac-image.cpp ac-box.cpp goto_window.cpp diff --git a/windows/Acid.Cam.Qt.Windows.Project/AcidCam.pro.user b/windows/Acid.Cam.Qt.Windows.Project/AcidCam.pro.user new file mode 100755 index 0000000..74f1b1e --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/AcidCam.pro.user @@ -0,0 +1,318 @@ + + + + + + EnvironmentId + {9c760219-7f46-4776-929b-24f16573a356} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.10.1 MSVC2015 64bit + Desktop Qt 5.10.1 MSVC2015 64bit + qt.qt5.5101.win64_msvc2015_64_kit + 1 + 0 + 0 + + C:/build-AcidCam-Desktop_Qt_5_10_1_MSVC2015_64bit-Debug + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + C:/build-AcidCam-Desktop_Qt_5_10_1_MSVC2015_64bit-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + C:/build-AcidCam-Desktop_Qt_5_10_1_MSVC2015_64bit-Profile + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + true + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy Configuration + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + AcidCam + + Qt4ProjectManager.Qt4RunConfiguration:C:/Acid.Cam.Build/AcidCam.pro + true + + AcidCam.pro + false + + C:/build-AcidCam-Desktop_Qt_5_10_1_MSVC2015_64bit-Release + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/windows/Acid.Cam.Qt.Windows.Project/Makefile b/windows/Acid.Cam.Qt.Windows.Project/Makefile new file mode 100755 index 0000000..11397ff --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/Makefile @@ -0,0 +1,382 @@ +############################################################################# +# Makefile for building: Acid_Cam_v2_Qt.app/Contents/MacOS/Acid_Cam_v2_Qt +# Generated by qmake (2.01a) (Qt 4.8.7) on: Fri Aug 10 15:04:29 2018 +# Project: Acid.Cam.v2.Linux.Qt.pro +# Template: app +# Command: /usr/local/bin/qmake -o Makefile Acid.Cam.v2.Linux.Qt.pro +############################################################################# + +####### Compiler, tools and options + +CC = clang +CXX = clang++ +DEFINES = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -pipe -mmacosx-version-min=10.7 -O2 -arch x86_64 -Wall -W $(DEFINES) +CXXFLAGS = -pipe -stdlib=libc++ -mmacosx-version-min=10.7 -std=c++11 `pkg-config acidcam opencv --cflags` -O2 -arch x86_64 -Wall -W $(DEFINES) +INCPATH = -I/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/unsupported/macx-clang-libc++ -I. -I/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/lib/QtCore.framework/Versions/4/Headers -I/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/lib/QtCore.framework/Versions/4/Headers -I/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/lib/QtGui.framework/Versions/4/Headers -I/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/lib/QtGui.framework/Versions/4/Headers -I/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/include -I. -I/usr/include/ -I/Volumes/LostDrive-6/Users/jared/usr.local/local/include -I. -F/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/lib +LINK = clang++ +LFLAGS = -headerpad_max_install_names -stdlib=libc++ -mmacosx-version-min=10.7 -arch x86_64 +LIBS = $(SUBLIBS) -F/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/lib -L/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/lib `pkg-config acidcam opencv --libs` -framework QtGui -L/Volumes/LostDrive-6/Users/jared/usr.local/local/opt/openssl/lib -L/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/lib -F/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/lib -framework QtCore +AR = ar cq +RANLIB = ranlib -s +QMAKE = /usr/local/bin/qmake +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = cp -f +COPY_DIR = cp -f -R +STRIP = +INSTALL_FILE = $(COPY_FILE) +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = $(COPY_FILE) +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p +export MACOSX_DEPLOYMENT_TARGET = 10.7 + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = main.cpp \ + main_window.cpp \ + new_dialog.cpp \ + plugin.cpp \ + select_image.cpp \ + display_window.cpp \ + playback_thread.cpp \ + search_box.cpp moc_main_window.cpp \ + moc_new_dialog.cpp \ + moc_display_window.cpp \ + moc_playback_thread.cpp \ + moc_search_box.cpp \ + qrc_qresource.cpp +OBJECTS = main.o \ + main_window.o \ + new_dialog.o \ + plugin.o \ + select_image.o \ + display_window.o \ + playback_thread.o \ + search_box.o \ + moc_main_window.o \ + moc_new_dialog.o \ + moc_display_window.o \ + moc_playback_thread.o \ + moc_search_box.o \ + qrc_qresource.o +DIST = /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/common/unix.conf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/common/mac.conf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/common/gcc-base.conf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/common/gcc-base-macx.conf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/common/clang.conf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/qconfig.pri \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/modules/qt_webkit_version.pri \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/qt_functions.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/qt_config.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/exclusive_builds.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/default_pre.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/mac/default_pre.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/release.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/default_post.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/mac/default_post.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/mac/x86_64.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/mac/objective_c.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/shared.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/warn_on.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/qt.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/unix/thread.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/moc.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/mac/rez.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/mac/sdk.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/resources.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/uic.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/yacc.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/lex.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/include_source_dir.prf \ + Acid.Cam.v2.Linux.Qt.pro +QMAKE_TARGET = Acid_Cam_v2_Qt +DESTDIR = +TARGET = Acid_Cam_v2_Qt.app/Contents/MacOS/Acid_Cam_v2_Qt + +####### Custom Compiler Variables +QMAKE_COMP_QMAKE_OBJECTIVE_CFLAGS = -pipe \ + -O2 \ + -arch \ + x86_64 \ + -Wall \ + -W + + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile Acid_Cam_v2_Qt.app/Contents/PkgInfo Acid_Cam_v2_Qt.app/Contents/Resources/empty.lproj Acid_Cam_v2_Qt.app/Contents/Info.plist $(TARGET) + +$(TARGET): $(OBJECTS) + @$(CHK_DIR_EXISTS) Acid_Cam_v2_Qt.app/Contents/MacOS/ || $(MKDIR) Acid_Cam_v2_Qt.app/Contents/MacOS/ + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: Acid.Cam.v2.Linux.Qt.pro /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/unsupported/macx-clang-libc++/qmake.conf /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/common/unix.conf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/common/mac.conf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/common/gcc-base.conf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/common/gcc-base-macx.conf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/common/clang.conf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/qconfig.pri \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/modules/qt_webkit_version.pri \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/qt_functions.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/qt_config.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/exclusive_builds.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/default_pre.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/mac/default_pre.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/release.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/default_post.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/mac/default_post.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/mac/x86_64.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/mac/objective_c.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/shared.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/warn_on.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/qt.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/unix/thread.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/moc.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/mac/rez.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/mac/sdk.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/resources.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/uic.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/yacc.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/lex.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/include_source_dir.prf \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/lib/QtGui.framework/QtGui.prl \ + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/lib/QtCore.framework/QtCore.prl + $(QMAKE) -o Makefile Acid.Cam.v2.Linux.Qt.pro +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/common/unix.conf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/common/mac.conf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/common/gcc-base.conf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/common/gcc-base-macx.conf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/common/clang.conf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/qconfig.pri: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/modules/qt_webkit_version.pri: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/qt_functions.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/qt_config.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/exclusive_builds.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/default_pre.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/mac/default_pre.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/release.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/default_post.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/mac/default_post.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/mac/x86_64.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/mac/objective_c.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/shared.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/warn_on.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/qt.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/unix/thread.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/moc.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/mac/rez.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/mac/sdk.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/resources.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/uic.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/yacc.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/lex.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/features/include_source_dir.prf: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/lib/QtGui.framework/QtGui.prl: +/Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/lib/QtCore.framework/QtCore.prl: +qmake: FORCE + @$(QMAKE) -o Makefile Acid.Cam.v2.Linux.Qt.pro + +Acid_Cam_v2_Qt.app/Contents/PkgInfo: + @$(CHK_DIR_EXISTS) Acid_Cam_v2_Qt.app/Contents || $(MKDIR) Acid_Cam_v2_Qt.app/Contents + @$(DEL_FILE) Acid_Cam_v2_Qt.app/Contents/PkgInfo + @echo "APPL????" >Acid_Cam_v2_Qt.app/Contents/PkgInfo +Acid_Cam_v2_Qt.app/Contents/Resources/empty.lproj: + @$(CHK_DIR_EXISTS) Acid_Cam_v2_Qt.app/Contents/Resources || $(MKDIR) Acid_Cam_v2_Qt.app/Contents/Resources + @touch Acid_Cam_v2_Qt.app/Contents/Resources/empty.lproj + +Acid_Cam_v2_Qt.app/Contents/Info.plist: + @$(CHK_DIR_EXISTS) Acid_Cam_v2_Qt.app/Contents || $(MKDIR) Acid_Cam_v2_Qt.app/Contents + @$(DEL_FILE) Acid_Cam_v2_Qt.app/Contents/Info.plist + @sed -e "s,@SHORT_VERSION@,1.0,g" -e "s,@TYPEINFO@,????,g" -e "s,@ICON@,,g" -e "s,@EXECUTABLE@,Acid_Cam_v2_Qt,g" -e "s,@TYPEINFO@,????,g" /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/mkspecs/unsupported/macx-clang-libc++/Info.plist.app >Acid_Cam_v2_Qt.app/Contents/Info.plist +dist: + @$(CHK_DIR_EXISTS) .tmp/Acid_Cam_v2_Qt1.0.0 || $(MKDIR) .tmp/Acid_Cam_v2_Qt1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/Acid_Cam_v2_Qt1.0.0/ && $(COPY_FILE) --parents main_window.h new_dialog.h plugin.h qtheaders.h select_image.h display_window.h playback_thread.h search_box.h .tmp/Acid_Cam_v2_Qt1.0.0/ && $(COPY_FILE) --parents qresource.qrc .tmp/Acid_Cam_v2_Qt1.0.0/ && $(COPY_FILE) --parents main.cpp main_window.cpp new_dialog.cpp plugin.cpp select_image.cpp display_window.cpp playback_thread.cpp search_box.cpp .tmp/Acid_Cam_v2_Qt1.0.0/ && (cd `dirname .tmp/Acid_Cam_v2_Qt1.0.0` && $(TAR) Acid_Cam_v2_Qt1.0.0.tar Acid_Cam_v2_Qt1.0.0 && $(COMPRESS) Acid_Cam_v2_Qt1.0.0.tar) && $(MOVE) `dirname .tmp/Acid_Cam_v2_Qt1.0.0`/Acid_Cam_v2_Qt1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/Acid_Cam_v2_Qt1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) -r Acid_Cam_v2_Qt.app + -$(DEL_FILE) Makefile + + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_objective_c_make_all: +compiler_objective_c_clean: +compiler_moc_header_make_all: moc_main_window.cpp moc_new_dialog.cpp moc_display_window.cpp moc_playback_thread.cpp moc_search_box.cpp +compiler_moc_header_clean: + -$(DEL_FILE) moc_main_window.cpp moc_new_dialog.cpp moc_display_window.cpp moc_playback_thread.cpp moc_search_box.cpp +moc_main_window.cpp: qtheaders.h \ + new_dialog.h \ + display_window.h \ + playback_thread.h \ + search_box.h \ + main_window.h \ + main_window.h + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/bin/moc $(DEFINES) $(INCPATH) -D__APPLE__ -D__GNUC__ main_window.h -o moc_main_window.cpp + +moc_new_dialog.cpp: qtheaders.h \ + new_dialog.h + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/bin/moc $(DEFINES) $(INCPATH) -D__APPLE__ -D__GNUC__ new_dialog.h -o moc_new_dialog.cpp + +moc_display_window.cpp: qtheaders.h \ + display_window.h + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/bin/moc $(DEFINES) $(INCPATH) -D__APPLE__ -D__GNUC__ display_window.h -o moc_display_window.cpp + +moc_playback_thread.cpp: qtheaders.h \ + playback_thread.h + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/bin/moc $(DEFINES) $(INCPATH) -D__APPLE__ -D__GNUC__ playback_thread.h -o moc_playback_thread.cpp + +moc_search_box.cpp: qtheaders.h \ + main_window.h \ + new_dialog.h \ + display_window.h \ + playback_thread.h \ + search_box.h \ + search_box.h + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/bin/moc $(DEFINES) $(INCPATH) -D__APPLE__ -D__GNUC__ search_box.h -o moc_search_box.cpp + +compiler_rcc_make_all: qrc_qresource.cpp +compiler_rcc_clean: + -$(DEL_FILE) qrc_qresource.cpp +qrc_qresource.cpp: qresource.qrc \ + images/icon.png + /Volumes/LostDrive-6/Users/jared/usr.local/local/Cellar/qt/4.8.7_2/bin/rcc -name qresource qresource.qrc -o qrc_qresource.cpp + +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_rez_source_make_all: +compiler_rez_source_clean: +compiler_uic_make_all: +compiler_uic_clean: +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: compiler_moc_header_clean compiler_rcc_clean + +####### Compile + +main.o: main.cpp qtheaders.h \ + main_window.h \ + new_dialog.h \ + display_window.h \ + playback_thread.h \ + search_box.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp + +main_window.o: main_window.cpp main_window.h \ + qtheaders.h \ + new_dialog.h \ + display_window.h \ + playback_thread.h \ + search_box.h \ + plugin.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main_window.o main_window.cpp + +new_dialog.o: new_dialog.cpp new_dialog.h \ + qtheaders.h \ + main_window.h \ + display_window.h \ + playback_thread.h \ + search_box.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o new_dialog.o new_dialog.cpp + +plugin.o: plugin.cpp plugin.h \ + qtheaders.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o plugin.o plugin.cpp + +select_image.o: select_image.cpp select_image.h \ + qtheaders.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o select_image.o select_image.cpp + +display_window.o: display_window.cpp display_window.h \ + qtheaders.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o display_window.o display_window.cpp + +playback_thread.o: playback_thread.cpp playback_thread.h \ + qtheaders.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o playback_thread.o playback_thread.cpp + +search_box.o: search_box.cpp search_box.h \ + qtheaders.h \ + main_window.h \ + new_dialog.h \ + display_window.h \ + playback_thread.h \ + tokenize.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o search_box.o search_box.cpp + +moc_main_window.o: moc_main_window.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_main_window.o moc_main_window.cpp + +moc_new_dialog.o: moc_new_dialog.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_new_dialog.o moc_new_dialog.cpp + +moc_display_window.o: moc_display_window.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_display_window.o moc_display_window.cpp + +moc_playback_thread.o: moc_playback_thread.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_playback_thread.o moc_playback_thread.cpp + +moc_search_box.o: moc_search_box.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_search_box.o moc_search_box.cpp + +qrc_qresource.o: qrc_qresource.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o qrc_qresource.o qrc_qresource.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/windows/Acid.Cam.Qt.Windows.Project/README.md b/windows/Acid.Cam.Qt.Windows.Project/README.md new file mode 100755 index 0000000..a14f974 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/README.md @@ -0,0 +1,12 @@ +# Example pro file for Windows + +Replace the hardcoded paths with the ones you have for your current version of OpenCV compiled with Visual Studio. +Copy this pro into a new directory with the source files and qrc file. + +Also copy ac.h ac.cpp fractal.h fractal.cpp from libacidcam into the directory as well they can be found here: + +https://github.com/lostjared/libacidcam/tree/master/source + +Using Qt Creator call qmake on the file and it will build Makefiles for Visual Studio. + + diff --git a/windows/Acid.Cam.Qt.Windows.Project/ac-alpha.cpp b/windows/Acid.Cam.Qt.Windows.Project/ac-alpha.cpp new file mode 100755 index 0000000..8fd1cdd --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/ac-alpha.cpp @@ -0,0 +1,511 @@ +/* + * Software written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + + +#include "ac.h" + +// variables for changePixel +int current_filterx = 0; +int bytesPerSample = 0; +int bytesPerRow = 0; +int width = 0; +int height = 0; +int red = 0; +int green = 0; +int blue = 0; +int offset = 0; +int randomNumber = 0; +int reverse = 0; +bool negate = false; + +// changePixel for Alpha Flame Filters +// this function is called once for each pixel in the source image +void changePixel(cv::Mat &full_buffer, int i, int z, cv::Vec3b &buffer, double pos, double *count) { + //each case is a different operation on the RGB pixel values stored in buffer + switch(current_filterx) { + case 0: + { + double value = pos; + buffer[0] = static_cast(value*buffer[0]); + buffer[1] = static_cast(value*buffer[1]); + buffer[2] = static_cast(value*buffer[2]); + } + break; + case 1: + { + double value = pos; + buffer[0] = static_cast(value*buffer[0]); + buffer[1] = static_cast((-value)*buffer[1]); + buffer[2] = static_cast(value*buffer[2]); + } + break; + case 2: + { + buffer[0] += static_cast(buffer[0]*-pos); + buffer[1] += static_cast(buffer[1]*pos); + buffer[2] += static_cast(buffer[2]*-pos); + } + break; + case 3: + { + int current_pos = static_cast(pos*0.2f); + buffer[0] = static_cast((i*current_pos)+buffer[0]); + buffer[2] = static_cast((z*current_pos)+buffer[2]); + buffer[1] = static_cast((current_pos*buffer[1])); + } + break; + case 4: + { + int current_pos = static_cast(pos*0.2f); + buffer[0] = static_cast((z*current_pos)+buffer[0]); + buffer[1] = static_cast((i*current_pos)+buffer[1]); + buffer[2] = static_cast(((i+z)*current_pos)+buffer[2]); + } + break; + case 5: + { + int current_pos = static_cast(pos*0.2f); + buffer[0] = static_cast(-(z*current_pos)+buffer[0]); + buffer[1] = static_cast(-(i*current_pos)+buffer[1]); + buffer[2] = static_cast(-((i+z)*current_pos)+buffer[2]); + } + break; + + case 6: + { + int zq = z+1, iq = i+1; + if(zq > height-1 || iq > width-1) return; + cv::Vec3b &temp = full_buffer.at(zq, iq); + buffer[0] += static_cast((i*pos)+temp[0]); + buffer[1] += static_cast((z*pos)+temp[1]); + buffer[2] += static_cast((i/(z+1))+temp[2]); + } + break; + case 7: + { + unsigned char colv[4], cola[4]; + colv[0] = buffer[0]; + colv[1] = buffer[1]; + colv[2] = buffer[2]; + cola[0] = buffer[2]; + cola[1] = buffer[1]; + cola[2] = buffer[0]; + int alpha = (int)pos; + int red_values[] = { colv[0]+cola[2], colv[1]+cola[1], colv[2]+cola[0], 0 }; + int green_values[] = { colv[2]+cola[0], colv[1]+cola[1], colv[0]+cola[2], 0 }; + int blue_values[] = { colv[1]+cola[1], colv[0]+cola[2], colv[2]+cola[0], 0 }; + unsigned char R = 0,G = 0,B = 0; + for(int iq = 0; iq <= 2; ++iq) { + R += red_values[iq]; + R /= 3; + G += green_values[iq]; + G /= 3; + B += blue_values[iq]; + B /= 3; + } + buffer[0] += static_cast(alpha*R); + buffer[1] += static_cast(alpha*G); + buffer[2] += static_cast(alpha*B); + } + break; + case 8: + { + unsigned char colv[4], cola[4]; + colv[0] = buffer[0]; + colv[1] = buffer[1]; + colv[2] = buffer[2]; + int iq = (width-i-1); + int zq = (height-z-1); + cv::Vec3b &t = full_buffer.at(zq, iq); + cola[0] = t[0]; + cola[1] = t[1]; + cola[2] = t[2]; + int alpha = (int)pos; + int red_values[] = { colv[0]+cola[2], colv[1]+cola[1], colv[2]+cola[0], 0 }; + int green_values[] = { colv[2]+cola[0], colv[1]+cola[1], colv[0]+cola[2], 0 }; + int blue_values[] = { colv[1]+cola[1], colv[0]+cola[2], colv[2]+cola[0], 0 }; + unsigned char R = 0,G = 0,B = 0; + for(int iq = 0; iq <= 2; ++iq) { + R += red_values[iq]; + R /= 3; + G += green_values[iq]; + G /= 3; + B += blue_values[iq]; + B /= 3; + } + buffer[0] += static_cast(alpha*R); + buffer[1] += static_cast(alpha*G); + buffer[2] += static_cast(alpha*B); + } + break; + case 9: + { + double alpha = pos; + unsigned char colorz[3][3]; + colorz[0][0] = buffer[0]; + colorz[0][1] = buffer[1]; + colorz[0][2] = buffer[2]; + int total_r = colorz[0][0] +colorz[0][1]+colorz[0][2]; + total_r /= 3; + total_r *= static_cast(alpha); + int iq = i+1; + if(iq > width) return; + int zq = z; + cv::Vec3b &temp = full_buffer.at(zq, iq); + colorz[1][0] = temp[0]; + colorz[1][1] = temp[1]; + colorz[1][2] = temp[2]; + int total_g = colorz[1][0]+colorz[1][1]+colorz[1][2]; + total_g /= 3; + total_g *= static_cast(alpha); + buffer[0] = static_cast(total_r); + buffer[1] = static_cast(total_g); + buffer[2] = static_cast(total_r+total_g*alpha); + + } + break; + case 10: + { + buffer[0] = static_cast(((i+z)*pos)/(i+z+1)+buffer[0]*pos); + buffer[1] += static_cast(((i*pos)/(z+1))+buffer[1]); + buffer[2] += static_cast(((z*pos)/(i+1))+buffer[2]); + } + break; + case 11: + { + buffer[0] += static_cast((buffer[2]+(i*pos))/(pos+1)); + buffer[1] += static_cast((buffer[1]+(z*pos))/(pos+1)); + buffer[2] += buffer[0]; + } + break; + case 12: + { + buffer[0] += static_cast((i/(z+1))*pos+buffer[0]); + buffer[1] += static_cast((z/(i+1))*pos+buffer[1]); + buffer[2] += static_cast(((i+z)/(pos+1)+buffer[2])); + } + break; + case 13: + { + buffer[0] += static_cast((pos*(i/(pos+1))+buffer[2])); + buffer[1] += static_cast((pos*(z/(pos+1))+buffer[1])); + buffer[2] += static_cast((pos*((i*z)/(pos+1)+buffer[0]))); + } + break; + case 14: + { + buffer[0] = static_cast(((i+z)*pos)/(i+z+1)+buffer[0]*pos); + buffer[1] += static_cast((buffer[1]+(z*pos))/(pos+1)); + buffer[2] += static_cast(((i+z)/(pos+1)+buffer[2])); + } + break; + case 15: + { + buffer[0] = static_cast((i%(z+1))*pos+buffer[0]); + buffer[1] = static_cast((z%(i+1))*pos+buffer[1]); + buffer[2] = static_cast((i+z%((int)pos+1))+buffer[2]); + } + break; + case 16: + { + int r = 0; + r = (buffer[0]+buffer[1]+buffer[2])/3; + buffer[0] += static_cast(pos*r); + buffer[1] += static_cast(-(pos*r)); + buffer[2] += static_cast(pos*r); + } + break; + case 17: + { + unsigned long r = 0;; + r = static_cast((buffer[0]+buffer[1]+buffer[2])/(pos+1)); + buffer[0] += static_cast(r*pos); + r = (buffer[0]+buffer[1]+buffer[2])/3; + buffer[1] += static_cast(r*pos); + r = (buffer[0]+buffer[1]+buffer[2])/5; + buffer[2] += static_cast(r*pos); + } + break; + case 18: + { + buffer[0] += static_cast(1+(sin(pos))*z); + buffer[1] += static_cast((1+cos(pos))*i); + buffer[2] += static_cast(((buffer[0]+buffer[1]+buffer[2])/3)); + } + break; + case 19: + { + buffer[0] += static_cast(((buffer[2]-i)*((((int)pos+1)%15)+2))); + buffer[1] += static_cast(((buffer[1]-z)*((((int)pos+1)%15)+2))); + buffer[2] += static_cast((buffer[0]-(i+z)*((((int)pos+1)%15)+2))); + } + break; + case 20: + { + buffer[0] += static_cast((buffer[0]+buffer[1]-buffer[2])/3*pos); + buffer[1] -= static_cast((buffer[0]-buffer[1]+buffer[2])/6*pos); + buffer[2] += static_cast((buffer[0]-buffer[1]-buffer[2])/9*pos); + } + break; + case 21: + { + int iq = i, zq = z+1; + if(zq > height-2) return; + cv::Vec3b &temp = full_buffer.at(zq, iq); + zq = z+2; + if(zq > height-2) return; + cv::Vec3b &temp2 = full_buffer.at(zq, iq); + int ir, ig, ib; + ir = buffer[0]+temp[0]-temp2[0]; + ig = buffer[1]-temp[1]+temp2[1]; + ib = buffer[2]-temp[2]-temp2[2]; + if(z%2 == 0) { + if(i%2 == 0) { + buffer[0] = static_cast(ir+(0.5*pos)); + buffer[1] = static_cast(ig+(0.5*pos)); + buffer[2] = static_cast(ib+(0.5*pos)); + } else { + buffer[0] = static_cast(ir+(1.5*pos)); + buffer[1] = static_cast(ig+(1.5*pos)); + buffer[2] = static_cast(ib+(1.5*pos)); + } + } else { + if(i%2 == 0) { + buffer[0] += static_cast(ir+(0.1*pos)); + buffer[1] += static_cast(ig+(0.1*pos)); + buffer[2] += static_cast(ib+(0.1*pos)); + } else { + buffer[0] -= static_cast(ir+(i*pos)); + buffer[1] -= static_cast(ig+(z*pos)); + buffer[2] -= static_cast(ib+(0.1*pos)); + } + } + } + break; + case 22: + { + if((i%2) == 0) { + if((z%2) == 0) { + buffer[0] = static_cast(1-pos*buffer[0]); + buffer[2] = static_cast((i+z)*pos); + } else { + buffer[0] = static_cast(pos*buffer[0]-z); + buffer[2] = static_cast((i-z)*pos); + } + } else { + if((z%2) == 0) { + buffer[0] = static_cast(pos*buffer[0]-i); + buffer[2] = static_cast((i-z)*pos); + } else { + buffer[0] = static_cast(pos*buffer[0]-z); + buffer[2] = static_cast((i+z)*pos); + } + } + } + break; + case 23: + { + buffer[0] = static_cast(buffer[0]+buffer[1]*2+pos); + buffer[1] = static_cast(buffer[1]+buffer[0]*2+pos); + buffer[2] = static_cast(buffer[2]+buffer[0]+pos); + } + break; + case 24: + { + buffer[0] += static_cast(buffer[2]+pos); + buffer[1] += static_cast(buffer[1]+pos); + buffer[2] += static_cast(buffer[0]+pos); + } + break; + case 25: + { + buffer[0] += static_cast((buffer[2]*pos)); + buffer[1] += static_cast((buffer[0]*pos)); + buffer[2] += static_cast((buffer[1]*pos)); + } + break; + case 26: + { + buffer[0] += static_cast((buffer[2]*pos)+i); + buffer[1] += static_cast((buffer[0]*pos)+z); + buffer[2] += static_cast((buffer[1]*pos)+i-z); + } + break; + case 27: + { + buffer[0] = static_cast((-buffer[2])+z); + buffer[1] = static_cast((-buffer[0])+i); + buffer[2] = static_cast((-buffer[1])+pos); + } + break; + case 28: + { + buffer[0] = static_cast(buffer[2]+(1+(i*z)/pos)); + buffer[1] = static_cast(buffer[1]+(1+(i*z)/pos)); + buffer[2] = static_cast(buffer[0]+(1+(i*z)/pos)); + } + break; + case 29: + { + int iq = i, zq = z+1; + if(zq > height-2) return; + cv::Vec3b &temp = full_buffer.at(zq, iq); + zq = z+2; + if(zq > height-2) return; + cv::Vec3b &temp2 = full_buffer.at(zq, iq); + zq = z+3; + if(zq > height-2) return; + cv::Vec3b &temp3 = full_buffer.at(zq, iq); + zq = z+4; + if(zq > height-2) return; + cv::Vec3b &temp4 = full_buffer.at(zq, iq); + unsigned char col[4]; + col[0] = static_cast((temp[0]+temp2[0]+temp3[0]+temp4[0])/4); + col[1] = static_cast((temp[1]+temp2[1]+temp3[1]+temp4[1])/4); + col[2] = static_cast((temp[2]+temp2[2]+temp3[2]+temp4[2])/4); + buffer[0] = static_cast(col[0]*pos); + buffer[1] = static_cast(col[1]*pos); + buffer[2] = static_cast(col[2]*pos); + } + break; + case 30: + { + double rad = 100.0; + double degree = 0.01*pos; + int x = static_cast(rad * (cos(degree))); + int y = static_cast(rad * sin(degree)); + int z = static_cast(rad * tan(degree)); + buffer[0] = static_cast(buffer[0]+x); + buffer[2] = static_cast(buffer[1]+y); + buffer[1] = static_cast(buffer[1]+z); + } + break; + case 31: + { + int average= static_cast((buffer[0]+buffer[1]+buffer[2]+1)/3); + buffer[0] += static_cast(buffer[2]+average*(pos)); + buffer[1] += static_cast(buffer[0]+average*(pos)); + buffer[2] += static_cast(buffer[1]+average*(pos)); + } + break; + case 32: + { + int value = 0; + value = ~buffer[0] + ~buffer[1] + ~buffer[2]; + value /= 2; + buffer[0] = static_cast(buffer[0]+value*pos); + value /= 2; + buffer[1] = static_cast(buffer[1]+value*pos); + value /= 2; + buffer[2] = static_cast(buffer[2]+value*pos); + } + break; + case 33: + { + buffer[0] += static_cast(*count*pos); + buffer[1] += static_cast(*count*pos); + buffer[2] += static_cast(*count*pos); + *count += 0.00001f; + if(*count > 255) *count = 0; + } + break; + case 34: + { + buffer[0] += static_cast(pos*(randomNumber+pos)); + buffer[1] += static_cast(pos*(randomNumber+z)); + buffer[2] += static_cast(pos*(randomNumber+i)); + } + break; + case 35: + { + buffer[0] += static_cast(*count *z); + buffer[1] += static_cast(*count *pos); + buffer[2] += static_cast(*count *z); + *count += 0.0000001f; + } + break; + case 36: + { + buffer[0] += static_cast(sin(3.14+pos)*pos); + buffer[1] += static_cast(cos(3.14+pos)*pos); + buffer[2] += static_cast(tan(3.14+pos)*pos); + } + break; + } + buffer[0] += red; + buffer[1] += green; + buffer[2] += blue; + if(negate == true) { + buffer[0] = ~buffer[0]; + buffer[1] = ~buffer[1]; + buffer[2] = ~buffer[2]; + } + unsigned char buf[3]; + buf[0] = buffer[0]; + buf[1] = buffer[1]; + buf[2] = buffer[2]; + switch(reverse) { + case 0://normal + break; + case 1: + buffer[0] = buf[2]; + buffer[1] = buf[1]; + buffer[2] = buf[0]; + break; + case 2: + buffer[0] = buf[1]; + buffer[1] = buf[2]; + buffer[2] = buf[0]; + break; + case 3: + buffer[0] = buf[2]; + buffer[1] = buf[0]; + buffer[2] = buf[1]; + break; + case 4: + buffer[0] = buf[1]; + buffer[1] = buf[0]; + buffer[2] = buf[2]; + break; + } +} diff --git a/windows/Acid.Cam.Qt.Windows.Project/ac-basic.cpp b/windows/Acid.Cam.Qt.Windows.Project/ac-basic.cpp new file mode 100755 index 0000000..ffce546 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/ac-basic.cpp @@ -0,0 +1,987 @@ +/* + * Software written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + +#include"ac.h" +#include"fractal.h" + +// SelfAlphaBlend - Perform out of Bounds AlphaBlend on source image +void ac::SelfAlphaBlend(cv::Mat &frame) { + double alpha_inc = 0.1; + if(alpha_increase != 0) { + alpha_inc = alpha_increase; + } else { + alpha_inc = 0.1; + } + for(int z = 0; z < frame.rows; ++z) {// from top to bottom + for(int i = 0; i < frame.cols; ++i) {// from left to right + cv::Vec3b &colorval = frame.at(z, i);// at x,y + colorval[0] += static_cast(colorval[0]*alpha); + colorval[1] += static_cast(colorval[1]*alpha); + colorval[2] += static_cast(colorval[2]*alpha); + swapColors(frame, z, i);// swap colors + if(isNegative == true) { // if negative + invert(frame, z, i);// invert + } + } + } + static int direction = 1;// direction equals 1 + if(direction == 1) {// if direction equals 1 + alpha += alpha_inc; // plus equal 0.1 + // if alpha greater than 10 + if(alpha > 10) { alpha = 10; direction = 2; } + } else { + alpha -= alpha_inc; // minus equal 0.05 + // if alpha <= 0.1f + if(alpha <= 0.1f) { alpha = 0.1f; direction = 1; } + } + resetAlpha(direction, alpha); +} +// Self Scale - Scale pixel values by double +// Takes cv::Mat reference +void ac::SelfScale(cv::Mat &frame) { + double inc_alpha = 0.05; + if(alpha_increase != 0) + inc_alpha = alpha_increase; + else + inc_alpha = 0.05; + static double pos = 1.0; // pos the scale + int w = frame.cols; // width variable + int h = frame.rows; // height variable + for(int z = 0; z < h; ++z) {// top to bottom + for(int i = 0; i < w; ++i) { // left to right + // current pixel at x,y + cv::Vec3b &pixel = frame.at(z, i); + // scale each rgb value by pos + pixel[0] = static_cast(pixel[0] * pos); + pixel[1] = static_cast(pixel[1] * pos); + pixel[2] = static_cast(pixel[2] * pos); + swapColors(frame, z, i);// swap colors + // if is negative set, invert pixel + if(isNegative) invert(frame, z, i); + } + } + // static direction variable + static int direction = 1; + static double pos_max = 7.0f; // position max + if(direction == 1) { // direction equals 1 + pos += inc_alpha; // pos plus equal 0.05 + if(pos > pos_max) { // pos greater than pos_max + pos = pos_max; // set pos to pos_max + direction = 0; // set direction to zero + pos_max += 0.5f; // add 0.5 to pos_max + } + } else if(direction == 0) { // direction is zero + pos += -inc_alpha; // minus equal 0.05 + if(pos <= 1.0) { // pos <= 1.0 + if(pos_max > 15) pos_max = 1.0f; // reset pos if greater than 15 + direction = 1;// set direction to 1 + } + } + resetAlpha(direction, pos); +} +// StrobeEffect - Change frame values by passIndex, incrememnt each frame +void ac::StrobeEffect(cv::Mat &frame) { + static int passIndex = 0;// passIndex variable + static double alpha = 1.0f;// alpha is 1.0 + for (int z = 0; z < frame.cols - 2; ++z) { + for (int i = 0; i < frame.rows - 2; ++i) { + + cv::Vec3b &colors = frame.at(i, z); // current pixel + + switch (passIndex) { + case 0: // pass 0 set color values + colors[0] = static_cast(colors[0] * (-alpha)); + colors[1] = static_cast(colors[1] * alpha); + colors[2] = static_cast(colors[2] * alpha); + break; + case 1: // pass 1 set color values + colors[0] += static_cast(colors[0] * alpha); + colors[1] += static_cast(colors[1] * (-alpha)); + colors[2] += static_cast(colors[2] * alpha); + break; + case 2: // pass 2 set color values + colors[0] = static_cast(colors[0] * alpha); + colors[1] = static_cast(colors[1] * alpha); + colors[2] = static_cast(colors[2] * (-alpha)); + break; + case 3: { // pass 3 grab pixels +1, and +2 ahead and use for colors + cv::Vec3b &color1 = frame.at(i + 1, z);// x,y + 1 + cv::Vec3b &color2 = frame.at(i + 2, z);// x,y + 2 + // set colors accordingly + colors[0] += static_cast(colors[0] * alpha); + colors[1] += static_cast(color1[1] * alpha); + colors[2] += static_cast(color2[2] * alpha); + break; + } + } + // swap colors + swapColors(frame, i, z); + if(isNegative == true) { // if negative variable set + invert(frame, i, z);//invert pixel + } + } + } + ++passIndex; // pass index increased once each frame + if(passIndex > 3) passIndex = 0; // if greater than 3 set back to zero + static double max = 4.0f;// max + if(alpha < 0) // alpha less than zero + tr = translation_variable; // set as translation variable + else if(alpha > max) { // greater than max + tr = -translation_variable; // negative translation variable + max += 3.0f;// max plus equal 3.0 + if(max > 23) max = 4.0f;// max greater than twenty three max equal four + } + alpha += tr; // change position +} + +// Blend3 +// takes cv::Mat as reference +void ac::Blend3(cv::Mat &frame) { + static int i=0,z=0;// set i,z to zero + static double rValue[3] = { 0, 0, 0 }; + for (z = 0; z < frame.cols; ++z) { + for (i = 0; i < frame.rows; ++i) { + cv::Vec3b &color_value = frame.at(i, z); // get pixel value + for (int j = 0; j < 3; ++j) + color_value[j] += static_cast(color_value[j] * rValue[j]); // loop through each color multiply by rValue + // swap colors + swapColors(frame, i, z); + if(isNegative == true) {// if isNegative true + invert(frame, i, z);// invert pixel + } + } + } + // change rValue array based on random function + // set to either -0.1 or 0.1 + double alpha_inc = 0.1; + if(alpha_increase != 0) + alpha_inc = alpha_increase; + else + alpha_inc = 0.1; + + + for (int q = 0; q < 3; ++q) + rValue[q] += ((rand() % 10) > 5) ? -alpha_inc : alpha_inc; +} +// takes cv::Mat reference +void ac::NegParadox(cv::Mat &frame) { + static double alpha = 1.0f; // alpha equals 1.0 + for (int z = 0; z < frame.cols - 3; ++z) { // left to right + for (int i = 0; i < frame.rows - 3; ++i) { // top to bottom + cv::Vec3b colors[4];// vector array + colors[0] = frame.at(i, z);// grab pixels + colors[1] = frame.at(i + 1, z); + colors[2] = frame.at(i + 2, z); + colors[3] = frame.at(i + 3, z); + cv::Vec3b &color_value = frame.at(i, z);// grab pixel + // set final pixel color values + color_value[0] += static_cast((colors[0][0] * alpha) + (colors[1][0] * alpha)); + color_value[1] += static_cast((colors[1][1] * alpha) + (colors[3][1] * alpha)); + color_value[2] += static_cast((colors[1][2] * alpha) + (colors[2][2] * alpha)); + swapColors(frame, i, z); // swap the colors + if(isNegative == true) { // if negative is true + invert(frame, i, z);// invert pixel + } + } + } + static double trans_var = 0.1f; // translation variable + double translation_variable = (alpha_increase != 0) ? alpha_increase :0.1; + if (alpha < 0) + trans_var = translation_variable;// increase + else if (alpha > 15) + trans_var = -translation_variable; // decrease + alpha += trans_var; // add variable + + resetAlpha(alpha); +} + +// Thought Mode +// takes cv::Mat reference +void ac::ThoughtMode(cv::Mat &frame) { + static double alpha = 1.0f, trans_var = 0.1f; // alpha + static int mode = 0;// current mode + static int sw = 1, tr = 1; + for(int z = 2; z < frame.cols-2; ++z) { + for(int i = 2; i < frame.rows-4; ++i) { + cv::Vec3b &color_value = frame.at(i, z); // current pixel + // set pixel rgb values + if(sw == 1) color_value[0] += static_cast(color_value[mode]*alpha); + if(tr == 0) color_value[mode] -= static_cast(color_value[rand()%2]*alpha); + color_value[mode] += static_cast(color_value[mode]*alpha); + mode++; // increase mode + if(mode >= 3) mode = 0; // reset mode if greater than equal three + swapColors(frame, i, z);// swap colors + if(isNegative == true) { // if is negative true + invert(frame, i, z);// invert pixel + } + } + } + sw = !sw;// not sw + tr = !tr;// not tr + static double max = 4.0f; + if(alpha < 0) + trans_var = translation_variable; + else if(alpha > max) { + trans_var = -translation_variable; + max += 3.0f; + if(max > 23) max = 4.0f; + } + alpha += trans_var; // add to alpha + resetAlpha(alpha); +} +// blend with original pixel +void ac::Pass2Blend(cv::Mat &frame) { + for(int z = 0; z < frame.rows; ++z) { // top to bottom + for(int i = 0; i < frame.cols; ++i) { // left to right + if(!frame.empty() && !orig_frame.empty()) { + cv::Vec3b &color1 = frame.at(z, i);// current pixel + cv::Vec3b color2 = orig_frame.at(z, i);// original frame pixel + for(int q = 0; q < 3; ++q) + color1[q] = static_cast(color2[q]+(color1[q]*ac::pass2_alpha));// multiply + } + } + } +} + +// Takes cv::Mat reference +void ac::RandTriBlend(cv::Mat &frame) { + static double alpha = 1.0f;//alpha equals 1.0 + static int i = 0, z = 0;// i,z loop variables + int counter = 0;// center variable + cv::Vec3b colors[6];// array of six colors + for (z = 2; z < frame.cols - 2; ++z) { + for (i = 2; i < frame.rows - 2; ++i) { + // grab pixels + colors[0] = frame.at(i, z); + colors[1] = frame.at(i + 1, z); + colors[2] = frame.at(i + 2, z); + // chaos + counter = rand() % 3; + if (counter == 0) { // if counter equals zero + // set pixel values + colors[3][0] = static_cast((colors[0][0] + colors[1][0] + colors[2][0]*alpha)); + colors[3][1] = static_cast((colors[0][1] + colors[1][1]) * alpha); + colors[3][2] = static_cast((colors[0][2]) * alpha); + counter++; // increase counter + } else if (counter == 1) { // if counter equals one + // set pixel values + colors[3][0] = static_cast((colors[0][0]) * alpha); + colors[3][1] = static_cast((colors[0][1] + colors[1][1]) * alpha); + colors[3][2] = static_cast((colors[0][2] + colors[1][2] + colors[2][2]) * alpha); + counter++; // increase counter + } else { + // set pixel values + colors[3][0] = static_cast((colors[0][0]) * alpha); + colors[3][2] = static_cast((colors[0][1] + colors[1][1]) * alpha); + colors[3][1] = static_cast((colors[0][2] + colors[1][2] + colors[2][2]) * alpha); + } + cv::Vec3b &color_value = frame.at(i, z);// grab current pixel + color_value = colors[3];// assign pixel + swapColors(frame, i, z);// swap colors + if(isNegative == true) { // if isNegative + invert(frame, i, z);// invert pixel + } + } + } + static double max = 4.0f, trans_var = translation_variable;// max, translation variable + if (alpha < 0) // if alpha less than zero + trans_var = translation_variable; + else if (alpha > max) { + trans_var = -translation_variable; + max += 3.0f; + if (max > 23) + max = 4.0f; + } + alpha += trans_var;// add to alpha translation variable + resetAlpha(alpha); +} + +// Blank +// takes cv::Mat reference +void ac::Blank(cv::Mat &frame) { + static double alpha = 1.0f; // static alpha set to 1.0 + static unsigned char val[3] = { 0 };// val array set to zero + static bool color_switch = false;// color switch set to false + for(int z = 0; z < frame.cols; ++z) {// left to right + for(int i = 0; i < frame.rows; ++i) { // top to bottom + cv::Vec3b &color_value = frame.at(i, z); // current pixel + for(int j = 0; j < 3; ++j) { + // process pixel values + val[j] = static_cast((alpha*color_value[j]) / (2-j+1)); + color_value[j] += static_cast(val[2-j] / (j+1)); + if(color_switch == true) color_value[j] = static_cast(-color_value[j]); + } + swapColors(frame, i, z); + if(isNegative == true) { + invert(frame, i, z); // invert pixel + } + } + } + color_switch = !color_switch;// not color switch + static double max = 4.0f, trans_var = translation_variable; + if (alpha < 0) + trans_var = translation_variable; // positive (up) + else if (alpha > max) { + trans_var = -translation_variable; // negative (down) + max += 3.0f; + if (max > 23) + max = 4.0f; + } + alpha += trans_var; // add to alpha trans_Var + resetAlpha(alpha); +} +// Tri +// takes cv::Mat reference +void ac::Tri(cv::Mat &frame) { + static double alpha = 1.0f;// static alpha set to 1 + for(int z = 0; z < frame.cols-3; ++z) {// left to right + for(int i = 0; i < frame.rows-3; ++i) {// top to bottom + cv::Vec3b &color_value = frame.at(i, z);// current pixel + cv::Vec3b colors[2];// colors + // grab pixels + colors[0] = frame.at(i+1, z); + colors[1] = frame.at(i+2, z); + // set pixels + color_value[0] += static_cast(color_value[0]*alpha); + color_value[1] += static_cast(color_value[1]+colors[0][1]+colors[1][1]*alpha); + color_value[2] += static_cast(color_value[2]+colors[0][2]+colors[1][2]*alpha); + swapColors(frame, i, z);// swap + if(isNegative == true) { + invert(frame, i, z); // invert pixel + } + } + } + static double max = 4.0f, trans_var = 0.1f; + if (alpha < 0) + trans_var = translation_variable; // positive (up) + else if (alpha > max) { + trans_var = -translation_variable; // negative (down) + max += 3.0f; + if (max > 23) + max = 4.0f; + } + alpha += trans_var;// add to alpha trans var + resetAlpha(alpha); +} +// Distort +// takes cv::Mat reference +void ac::Distort(cv::Mat &frame) { + static double alpha = 1.0f; // static alpha set to 1 + static int i = 0, z = 0;// loop variables + for(z = 0; z < frame.cols; ++z) { // left to right + for(i = 0; i < frame.rows; ++i) {// top to bottom + cv::Vec3b &color_value = frame.at(i, z); + // set pixel values + color_value[0] = static_cast((i*alpha)+color_value[0]); + color_value[2] = static_cast((z*alpha)+color_value[2]); + color_value[1] = static_cast((alpha*color_value[1])); + if(strobe_It == true) color_value[1] = static_cast(((i+z)*alpha)+color_value[1]); + swapColors(frame, i, z); //swap + if(isNegative == true) { + invert(frame, i, z);// invert + } + } + } + static double max = 4.0f, trans_var = 0.1f; + if (alpha < 0) + trans_var = 0.1f; + else if (alpha > max) { + trans_var = -0.1f; + max += 3.0f; + if (max > 23) + max = 4.0f; + } + alpha += trans_var;// add translation to alpha + resetAlpha(alpha); +} +// takes cv::Mat reference +void ac::CDraw(cv::Mat &frame) { + static int i=0,z=0;// loop variables + static double rad = 80.0f;// radius + static double deg = 1.0f;// degrees + for(z = 0; z < frame.cols; ++z) { // left to right + for(i = 0; i < frame.rows; ++i) {// top to bottom + int cX = static_cast((rad * cos(deg))); + int cY = static_cast((rad * sin(deg))); + cv::Vec3b &color_value = frame.at(i, z); // grab pixel reference + // set values + color_value[0] = static_cast(color_value[0]*(cX * alpha)); + color_value[1] = static_cast(color_value[1]*(cY * alpha)); + color_value[2] = static_cast(color_value[2]*alpha); + deg += 0.1f; + swapColors(frame, i, z);// swap + if(isNegative) invert(frame, i, z);// if isNegative invert + } + } + alpha += 0.1f;// add to alpha + rad += 0.1f;// add to rad + if(rad > 90) rad = 0;// greater than 90 reset + if(alpha > 20) alpha = 0;// greater than 20 reset + resetAlpha(alpha); +} +// Light Strobe +// first cycle through the image +// add a variable to each individual pixel (the input sould be different each frame) +// reason for this is adding to the captured image each frame causes a animation a distortion +// each frame the largest value is calculated by adding the rgb values together for one element each iteration. +// test this first +void ac::Type(cv::Mat &frame) { + int i = 0, z = 0;// loop variables + static double add_r = 1.0; // add_r + static int off = 0;// off variable + for(z = 0; z < frame.rows; ++z) { // top to bottom + for(i = 0; i < frame.cols; ++i) {// left to right + cv::Vec3b ¤t = frame.at(z, i); // grab pixel reference + // set pixel values + current[0] += static_cast(add_r+current[0]); + current[1] += static_cast(add_r+current[1]); + current[2] += static_cast(add_r+current[2]); + // set value indexed by off which changes each frame + current[off] = current[0]+current[1]+current[2]; + swapColors(frame, z, i);// swap the colors + if(isNegative) invert(frame, z, i); // invert pixel + } + } + ++off;// increase off + if(off > 2) off = 0;// greater than two set to zero + add_r += rand()%255;// random distortion plus equals random number + if(add_r > 255) add_r = 0;// greater than 255 set to zero +} +// New One +// takes cv::Mat reference +void ac::NewOne(cv::Mat &frame) { + for(int z = 0; z < frame.cols; ++z) {// left to right + for(int i = 1; i < frame.rows-1; ++i) {// top to bottom + cv::Vec3b &colv = frame.at(i, z);// get pixels + cv::Vec3b &cola = frame.at((frame.rows-1)-i, (frame.cols-1)-z);//frame.at((frame.cols-1)-z, (frame.rows-1)-i); + // set arrays + int red_values[] = { colv[0]+cola[2], colv[1]+cola[1], colv[2]+cola[0], 0 }; + int green_values[] = { colv[2]+cola[0], colv[1]+cola[1], colv[0]+cola[2], 0 }; + int blue_values[] = { colv[1]+cola[1], colv[0]+cola[2], colv[2]+cola[0], 0 }; + unsigned char R = 0,G = 0,B = 0; + // loop through arrays + for(int iq = 0; iq <= 2; ++iq) { + R += red_values[iq]; + R /= 3; + G += green_values[iq]; + G /= 3; + B += blue_values[iq]; + B /= 3; + } + // set pixel values + colv[0] += static_cast(alpha*R); + colv[1] += static_cast(alpha*G); + colv[2] += static_cast(alpha*B); + swapColors(frame, i, z);//swap colors + if(isNegative) invert(frame, i, z); // if isNegative invert pixel + } + } + static double max = 8.0f, trans_var = 0.1f;// max and translation + if (alpha < 0) + trans_var = 0.1f; + else if (alpha > max) { + trans_var = -0.1f; + max += 3.0f; + if (max > 23) + max = 4.0f; + } + alpha += trans_var;// add translation variable + resetAlpha(alpha); + +} +// draw a fractal +void ac::blendFractal(cv::Mat &frame) { + frac::FractalLogic(); + frac::DrawFractal(frame, ac::isNegative); +} + +// draw a fractal with background color blended +void ac::blendFractalMood(cv::Mat &frame) { + // random + unsigned char color = 0; + color = rand()%255; + static bool shift = true; + static bool shift_value = true; + for(int z = 0; z < frame.cols; ++z) {// left to right + for(int i = 0; i < frame.rows; ++i) {// top to bottom + cv::Vec3b &color_value = frame.at(i, z);// grab pixel + // set pixel values + color_value[0] += (shift == shift_value) ? color : -color; + color_value[1] += (shift == shift_value) ? -color : color; + color_value[2] += (shift == shift_value) ? color : -color; + shift_value = !shift_value;// not shift value + } + } + shift = ! shift;// not shift value + frac::FractalLogic(); + frac::DrawFractal(frame, ac::isNegative); // draw fractal +} + +// blend with Image functions Resize X +inline int ac::GetFX(cv::Mat &frame, int x, int nw) { + double xp = (double)x * (double)frame.rows / (double)nw; + return (int)xp; +} +// blend with Image function Resize Y +inline int ac::GetFY(cv::Mat &frame, int y, int nh) { + double yp = (double)y * (double)frame.cols / (double)nh; + return (int)yp; +} +// blend with Image function +// takes cv::Mat as reference +void ac::blendWithImage(cv::Mat &frame) { + if(!blendW_frame.data) // if image not loaded return + return; + static double alpha = 1.0f; // set alpha to 1 + static double beta = 1.0f; // set beta to 1 + for(int z = 0; z < frame.cols; ++z) {// left to right + for(int i = 0; i < frame.rows; ++i) {// top to bottom + // get resized pixel values + int q = GetFX(blendW_frame, i, frame.rows); + int j = GetFY(blendW_frame, z, frame.cols); + // grab pixels + cv::Vec3b &frame_one = frame.at(i, z); + cv::Vec3b &frame_two = blendW_frame.at(q, j); + // set pixel values + for(int p = 0; p < 3; ++p) + frame_one[p] += static_cast((frame_one[p]*alpha)+(frame_two[p]*beta)); + swapColors(frame, i, z); // swap colors + if(isNegative == true) { + invert(frame, i, z);// invert pixel + } + } + } + // move alpha and beta values up and down + static double max = 4.0f, trans_var = 0.1f; + if (alpha < 0) + trans_var = translation_variable; + else if (alpha > max) { + trans_var = -translation_variable; + max += 3.0f; + if (max > 23) + max = 4.0f; + } + alpha += trans_var; + beta += -trans_var; +} +// triBlend with Image unused +void ac::triBlendWithImage(cv::Mat &frame) { + if(images_Enabled == false) return; + static double alpha = 1.0f, beta = 1.0f; + static int i = 0, z = 0, j = 0; + for(z = 0; z < frame.cols; ++z) { + for(i = 0; i < frame.rows; ++i) { + cv::Vec3b colors[3]; + cv::Vec3b &color_value = frame.at(i, z); + int cx[3] = { ac::GetFX(image_files[0], i, frame.rows), ac::GetFX(image_files[1], i, frame.rows), ac::GetFX(image_files[2], i, frame.rows) }; + int cy[3] = { ac::GetFY(image_files[0], z, frame.cols), ac::GetFY(image_files[1], z, frame.cols), ac::GetFY(image_files[2], z, frame.cols) }; + for(j = 0; j < 3; ++j) { + colors[j] = image_files[j].at(cx[j], cy[j]); + } + color_value[0] = static_cast(((color_value[0]+colors[0][0])/2)*alpha); + color_value[1] += static_cast(((color_value[1]+colors[0][1])/2)*alpha); + color_value[2] = static_cast(((color_value[2]+colors[0][2]+colors[1][2]+colors[2][2])/3)*beta); + swapColors(frame, i, z); + if(isNegative == true) { + invert(frame, i, z); + } + } + } + static double max = 4.0f, trans_var = 0.1f; + if (alpha < 0) + trans_var = translation_variable; + else if (alpha > max) { + trans_var = -translation_variable; + max += 3.0f; + if (max > 23) + max = 4.0f; + } + alpha += trans_var; + beta += -trans_var; +} + +// Image Strobe - unused +void ac::imageStrobe(cv::Mat &frame) { + if(images_Enabled == false) return; + static double alpha = 1.0f; + static int i = 0, z = 0, j = 0, image_offset = 0; + for(z = 0; z < frame.cols; ++z) { + for(i = 0; i < frame.rows; ++i) { + cv::Vec3b colors[3]; + cv::Vec3b &color_value = frame.at(i, z); + int cx[3] = { ac::GetFX(image_files[0], i, frame.rows), ac::GetFX(image_files[1], i, frame.rows), ac::GetFX(image_files[2], i, frame.rows) }; + int cy[3] = { ac::GetFY(image_files[0], z, frame.cols), ac::GetFY(image_files[1], z, frame.cols), ac::GetFY(image_files[2], z, frame.cols) }; + for(j = 0; j < 3; ++j) + colors[j] = image_files[j].at(cx[j], cy[j]); + for(j = 0; j < 3; ++j) + color_value[j] += static_cast((colors[image_offset][j]*alpha)); + swapColors(frame, i, z); + if(isNegative == true) { + invert(frame, i, z); + } + } + } + ++image_offset; + if(image_offset >= 4) image_offset = 0; + static double max = 4.0f, trans_var = 0.1f; + if (alpha < 0) + trans_var = translation_variable; + else if (alpha > max) { + trans_var = -translation_variable; + max += 3.0f; + if (max > 23) + max = 4.0f; + } + alpha += trans_var; + resetAlpha(alpha); +} +// Image distraction - unused +void ac::imageDistraction(cv::Mat &frame) { + if(images_Enabled == false) return; + static double alpha = 1.0f; + static int i = 0, z = 0, im_off = 2; + for(z = 0; z < frame.cols; ++z) { + for(i = 0; i < frame.rows; ++i) { + cv::Vec3b &color_value = frame.at(i, z); + int cX = GetFX(image_files[im_off], i, frame.rows), cY = GetFY(image_files[im_off], z, frame.cols); + cv::Vec3b manip_color = image_files[im_off].at(cX, cY); + color_value[0] = static_cast((z*alpha)+color_value[0]); + color_value[1] = static_cast(manip_color[1]*alpha); + color_value[2] = static_cast((i*alpha)+color_value[2]); + swapColors(frame, i, z); + if(isNegative) invert(frame, i, z); + } + } + ++im_off; + if(im_off >= 4) im_off = 0; + static double max = 4.0f, trans_var = 0.1f; + if (alpha < 0) + trans_var = 0.1f; + else if (alpha > max) { + trans_var = -0.1f; + max += 3.0f; + if (max > 23) + max = 4.0f; + } + alpha += trans_var; + resetAlpha(alpha); +} + +// Cos Sin Mulitply draw gradients +// takes cv::Mat reference +void ac::cossinMultiply(cv::Mat &frame) { + static double alpha = 1.0f;// set static alpha to 1.0 + static int i = 0, z = 0;// loop variables + for(z = 0; z < frame.cols; ++z) {// left to right + for(i = 0; i < frame.rows; ++i) {// top to bottom + cv::Vec3b &buffer = frame.at(i, z); // grab pixel + // set pixel values + buffer[0] += static_cast(1+static_cast((sin(alpha))*z)); + buffer[1] += static_cast(1+static_cast((cos(alpha))*i)); + buffer[2] += static_cast((buffer[0]+buffer[1]+buffer[2])/3); + swapColors(frame, i, z);// swap colors + if(isNegative) invert(frame, i, z);// invert pixel + } + } + // add alpha up to 24 return to zero when greater + static double trans_var = 0.05f; + if(alpha > 24) alpha = 1.0f; + alpha += trans_var; + resetAlpha(alpha); +} +// Color Accumulate 1 +void ac::colorAccumulate1(cv::Mat &frame) { + static double alpha = 1.0f; // alpha to 1.0 + static int i = 0, z = 0; // static loop variables + for(z = 0; z < frame.cols; ++z) {// left to right + for(i = 0; i < frame.rows; ++i) {// top to bottom + cv::Vec3b &buffer = frame.at(i, z);// current pixel + // set pixel values + buffer[0] += static_cast((buffer[2]*alpha)); + buffer[1] += static_cast((buffer[0]*alpha)); + buffer[2] += static_cast((buffer[1]*alpha)); + swapColors(frame, i, z); // swap colors + if(isNegative) invert(frame, i, z);// invert pixel + } + } + // increase alpha until 24 then reset + static double trans_var = 0.05f; + alpha += trans_var; + if(alpha > 24) alpha = 1.0f; + resetAlpha(alpha); +} +// Color Accumulate 2 +void ac::colorAccumulate2(cv::Mat &frame) { + static double alpha = 1.0f;// static alpha set to 1.0 + static int i = 0, z = 0;// loop variables + for(z = 0; z < frame.cols; ++z) {// left to right + for(i = 0; i < frame.rows; ++i) {// top to bottom + // grab pixel + cv::Vec3b &buffer = frame.at(i, z); + // set pixel rgb values + buffer[0] += static_cast((buffer[2]*alpha)+i); + buffer[1] += static_cast((buffer[0]*alpha)+z); + buffer[2] += static_cast((buffer[1]*alpha)+i-z); + swapColors(frame, i, z);// swap + if(isNegative) invert(frame, i, z);// if isNegative invert + } + } + static double trans_var = 0.05f;// translation variable + alpha += trans_var;// alpha plus equal translation variable + if(alpha > 24) alpha = 1.0f;// if alpha greater than 24 reset to 1 + resetAlpha(alpha); +} +// Color Accumulate #3 +// takes cv::Mat reference +void ac::colorAccumulate3(cv::Mat &frame) { + static double alpha = 1.0f;// set alpha to 1.0 + static int i = 0, z = 0;// loop variables + for(z = 0; z < frame.cols; ++z) {// from left to right + for(i = 0; i < frame.rows; ++i) {// from top to bottom + cv::Vec3b &buffer = frame.at(i, z);// grab pixel reference + // set rgb values + buffer[0] = static_cast((-buffer[2])+z); + buffer[1] = static_cast((-buffer[0])+i); + buffer[2] = static_cast((-buffer[1])+alpha); + swapColors(frame, i, z);// swap colors + if(isNegative) invert(frame, i, z);// if isNegative true invert pixel + } + } + static double trans_var = 0.05f;// 0.05 variable + alpha += trans_var;// alpha plus equal translation variable + if(alpha > 24) alpha = 1.0f;// alpha greater than 24 set to 1 (reset) + resetAlpha(alpha); +} + +// takes cv::Mat reference +void ac::filter8(cv::Mat &frame) { + static double alpha = 1.0f;// set static alpha to 1.0 + static int i = 0, z = 0, q = 0;// loop variable + for(z = 0; z < frame.cols; ++z) {// from left to right + for(i = 0; i < frame.rows; ++i) {// from top to bottom + cv::Vec3b &buffer = frame.at(i, z);// grab pixel + for(q = 0; q < 3; ++q) {// loop each rgb value + buffer[q] = static_cast(buffer[q]+((i+z)*alpha));// preform calculation + + } + swapColors(frame, i, z);// swap colors + if(isNegative) invert(frame, i, z);// if isNegative invert + } + } + // static direction equals 1 + static int direction = 1; + if(direction == 1) {// if direction equals 1 + alpha += 0.05f;// alpha plus equal 0.05 + if(alpha > 3) { alpha = 3; direction = 2; }// alpha greater than 3 set direction to 2 + } else { + alpha -= 0.05f;// alpha minus equal 0.05 + if(alpha <= 0.1f) { alpha = 0.1f; direction = 1; }//alpha greater than 3 set direction to 1 + } + resetAlpha(direction, alpha); +} + +// takes cv::Mat reference +void ac::filter3(cv::Mat &frame) { + static double alpha = 1.0f;// set static alpha to 1.0 + static int i = 0, z = 0, q = 0;// loop variables + for(z = 0; z < frame.cols; ++z) {// left to right + for(i = 0; i < frame.rows; ++i) {// top to bottom + cv::Vec3b &buffer = frame.at(i, z);// grab pixel reference + for(q = 0; q < 3; ++q) {// loop through rgb values + buffer[q] = static_cast(buffer[0]+(buffer[q])*(alpha));// preform calculation + } + swapColors(frame, i, z);// swap colors + if(isNegative) invert(frame, i, z);// if isNegative invert pixel + } + } + // direction equals 1 + static int direction = 1; + if(direction == 1) { // if direction equals 1 + alpha += 0.1f;// alpha plus equal 0.1 + if(alpha > 6) { alpha = 6; direction = 2; } // if alpha greater than 6 set alpha to 6 direction to 2 + } else { + alpha -= 0.05f;// alpha minus equal 0.1 + if(alpha <= 0.1f) { alpha = 0.1f; direction = 1; } // if alpha lses than equal 0.1 set to 0.1 direction equals 1 + } + resetAlpha(direction, alpha); +} + +// takes cv::Mat as reference +// uses 3 static variables to represent the RGB values +// to mulitply by the alpha variable +// each frame they either increase or are reset to a random number when set to zero +// when they reach a number greater than 255 they are reset to zero +void ac::rainbowBlend(cv::Mat &frame) { + static double alpha = 1.0f;// set static alpha to 1.0 + static int rb = 0, gb = 0, bb = 0;// set static integer r,g,b values + if(rb == 0) // if rb equals 0 + rb = rand()%255;// set rb to random number + else ++rb;// else increase rb + if(gb == 0) // if gb equals 0 + gb = rand()%255;// gb equals random number + else ++gb;// else gb increases + if(bb == 0) // if bb equals 0 + bb = rand()%255;// bb equals random number + else ++bb;// else increase bb + static int i = 0, z = 0;// loop variables + for(z = 0; z < frame.cols; ++z) {// left to right + for(i = 0; i < frame.rows; ++i) {// top to bottom + // grab pixel as cv::Vec3b reference + cv::Vec3b &buffer = frame.at(i, z); + // add to rgb values alpha * rb,gb,bb variables + buffer[0] += static_cast(alpha*rb); + buffer[1] += static_cast(alpha*gb); + buffer[2] += static_cast(alpha*bb); + swapColors(frame, i, z);// swap colors + if(isNegative) invert(frame, i, z);// if isNegative invert pixel + } + } + // if rb greater than 255 set to zero + if(rb > 255) rb = 0; + // if gb greater than 255 set to zero + if(gb > 255) gb = 0; + // if bb greater than 255 set to zero + if(bb > 255) bb = 0; + // static int direction equals 1 + static int direction = 1; + if(direction == 1) {// if direction equals 1 + alpha += 0.1f;// increase alpha + // alpha greater than 6 change direction + if(alpha > 6) { alpha = 6; direction = 2; } + } else { + // decrease alpha + alpha -= 0.05f; + // if alpha <= 0.1 change direction + if(alpha <= 0.1f) { alpha = 0.1f; direction = 1; } + } + resetAlpha(direction, alpha); +} + +// random pixel value added to each pixel RGB value each frame +// takes cv::Mat reference +void ac::randBlend(cv::Mat &frame) { + unsigned char rr = rand()%255;// random Red + unsigned char rg = rand()%255;// random Green + unsigned char rb = rand()%255;// random Blue + static int i = 0, z = 0;// i,z loop variables + for(z = 0; z < frame.cols; ++z) {// from left to right + for(i = 0; i < frame.rows; ++i) {// from top to bottom + cv::Vec3b &buffer = frame.at(i, z);// pixel at + buffer[0] += rr;// add random R + buffer[1] += rg;// add random G + buffer[2] += rb;// add random B + swapColors(frame, i, z);// swap colors + if(isNegative) invert(frame, i, z);// if negative, invert pixel + } + } +} + +// takes cv::Mat reference +void ac::newBlend(cv::Mat &frame) { + static int pos = 300; // static int pos equal 300 + static int i = 0, z = 0;// loop variables + for(z = 0; z < frame.cols; ++z) {// left to right + for(i = 0; i < frame.rows; ++i) {// top to bottom + // grab pixel + cv::Vec3b &buffer = frame.at(i, z); + // set pixel RGB values + buffer[0] = static_cast(buffer[2]+(1+(i*z)/pos)); + buffer[1] = static_cast(buffer[1]+(1+(i*z)/pos)); + buffer[2] = static_cast(buffer[0]+(1+(i*z)/pos)); + swapColors(frame, i, z);// swap colors + if(isNegative) invert(frame, i, z);// if(isNegative) invert pixel + } + } + static int dir = 1;// static direction equals 1 + if(dir == 1) {// dir equals 1 + pos += 25;// pos plus equal 25 + if(pos > 1024) {// greater than 1024 + pos = 1024; + dir = 2;// set direction to 2 + } + } + else {// direction != 1 + pos -= 25;// minus 25 + if(pos < 100) {// less than 100 + pos = 100; + dir = 1;// set direction to 1 + } + } +} +// pixelScale +// takes cv::Mat reference +void ac::pixelScale(cv::Mat &frame) { + static double pos = 1.0f;// pos equals 1.0 + static int i = 0, z = 0;// loop variables + for(z = 0; z < frame.cols; ++z) {// left to right + for(i = 0; i < frame.rows; ++i) {// top to bottom + // grab pixel reference + cv::Vec3b &buffer = frame.at(i, z); + cv::Vec3b buf = buffer;// temp pixel + // set RGB pixel values + buffer[0] = static_cast((buf[0]*pos)+(buf[0]-buffer[2])); + buffer[1] = static_cast((buf[1]*pos)+(buf[1]+buffer[1])); + buffer[2] = static_cast((buf[2]*pos)+(buf[2]-buffer[0])); + swapColors(frame, i, z);// swap colors + if(isNegative) invert(frame, i, z);// if isNegative invert pixel + } + } + static int direction = 1;// direction equals 1 + static double pos_max = 3.0f;// pos_max equals 3.0 + if(direction == 1) {// direction equals 1 + pos += 0.1f;// plus equal 0.1 + if(pos > pos_max) {// greater than pos_max + pos = pos_max; + direction = 0;// set direction to zero + pos_max += 0.5f;// increase pos_max + } + } else if(direction == 0) {// direction equals 0 + pos -= 0.1f;// pos minus equal 0.1 + if(pos <= 0) {// pos less than equal 0 + if(pos_max > 15) pos_max = 1.0f;// pos_max > 14 reset + direction = 1;// direction set back to 1 + } + } + resetAlpha(direction, pos); + +} diff --git a/windows/Acid.Cam.Qt.Windows.Project/ac-box.cpp b/windows/Acid.Cam.Qt.Windows.Project/ac-box.cpp new file mode 100755 index 0000000..fda8ecd --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/ac-box.cpp @@ -0,0 +1,103 @@ +/* + * Software written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + +#include"ac.h" + +int ac::Box::frame_width = 0; +int ac::Box::frame_height = 0; + +void ac::Box::initBox(int width, int height) { + x = (rand()%width); + y = (rand()%height); + w = rand()%25; + h = rand()%25; + steps = rand()%10; + index = 0; + do { + frame_index = rand()%28; + } while(frame_index == 13 || frame_index == 14); +} + +void ac::Box::drawBox(cv::Mat &frame) { + cv::Mat temp; + temp.create(cvSize(w, h), CV_8UC3); + for(int yy = y, pos_y = 0; yy < y+h && yy < frame_height; ++yy, ++pos_y) { + for(int ii = x,pos_x = 0; ii < x+w && ii < frame_width; ++ii, ++pos_x) { + cv::Vec3b pixel = frame.at(yy, ii); + cv::Vec3b &target = temp.at(pos_y, pos_x); + target = pixel; + } + } + ac::draw_func[frame_index](temp); + for(int z = y, pos_y = 0; z < y+h && z < frame_height; ++z, ++pos_y) { + for(int i = x, pos_x = 0; i < x+w && i < frame_width; ++i, ++pos_x) { + if(i < frame.cols && z < frame.rows) { + cv::Vec3b &pixel = frame.at(z, i); + pixel = temp.at(pos_y,pos_x); + } + } + } +} + +void ac::Box::sizeBox() { + if(index > steps) { + initBox(frame_width, frame_height); + return; + } + ++index; + int r1 = rand()%10; + int r2 = rand()%10; + if(w+r1 > frame_width) { + initBox(frame_width, frame_height); + return; + } else { + w += r1; + } + if(h+r2 > frame_height) { + initBox(frame_width, frame_height); + return; + } else { + h += r2; + } +} + diff --git a/windows/Acid.Cam.Qt.Windows.Project/ac-filter1.cpp b/windows/Acid.Cam.Qt.Windows.Project/ac-filter1.cpp new file mode 100755 index 0000000..4964094 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/ac-filter1.cpp @@ -0,0 +1,263 @@ +/* + * Software written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + +#include "ac.h" +// Acid Cam namespace +namespace ac { +#if defined(__APPLE__) + const std::string version="2.5.8 (macOS)"; +#elif defined(__linux__) + const std::string version="2.5.8 (Linux)"; +#elif defined(_WIN32) + const std::string version="2.5.8 (Windows)"; +#else + const std::string version="2.5.8 (Generic)"; +#endif + // variables + int swapColor_r = 0, swapColor_g = 0, swapColor_b = 0; + bool isNegative = false, noRecord = false, pass2_enabled = false, blendW = false, slide_Show = false, slide_Rand = false, strobe_It = false, switch_Back = false, blur_First = false; + bool images_Enabled = false, fps_force = false,iRev = false; + bool blur_Second = false; + int set_color_map = 0; + cv::Mat orig_frame; + cv::Mat blendW_frame; + cv::Mat image_files[4]; + double alpha = 1.0f, tr = 0.01f; + double fps = 29.97; + int draw_offset = 0; + bool snapShot = false; + int color_order = 0; + int snapshot_Type = 0; + bool in_custom = false; + cv::Size resolution(0, 0); + std::string fileName ="VideoFile.avi"; + std::string draw_strings_value[] = { "Self AlphaBlend", "Self Scale", "StrobeEffect", "Blend #3", "Negative Paradox","ThoughtMode", "RandTriBlend", "Blank", "Tri", "Distort", "CDraw", "Type", "NewOne", "Blend Fractal","Blend Fractal Mood", "CosSinMultiply", "Color Accumlate1", "Color Accumulate2", "Color Accumulate3", "Filter8","Filter3","Rainbow Blend","Rand Blend","New Blend", "Alpha Flame Filters", "Pixel Scale", "PixelSort", "GlitchSort","Random Filter", "Random Flash", "Blend with Image", "Blend with Image #2", "Blend with Image #3", "Blend with Image #4", "GaussianBlur", "Median Blur", "Blur Distortion", "Diamond Pattern","MirrorBlend","Pulse","Sideways Mirror","Mirror No Blend","Sort Fuzz","Fuzz","Double Vision","RGB Shift","RGB Sep","Graident Rainbow","Gradient Rainbow Flash", "Reverse", "Scanlines", "TV Static", "Mirror Average", "Mirror Average Mix", "Mean", "Laplacian", "Bitwise_XOR", "Bitwise_AND","Bitwise_OR","Equalize", "Channel Sort", "Reverse_XOR", "Combine Pixels", "FlipTrip", "Canny","Boxes","Boxes Fade", "Flash Black","SlideRGB","Side2Side","Top2Bottom","Strobe Red Then Green Then Blue","Blend_Angle", "Outward", "Outward Square","ShiftPixels", "ShiftPixelsDown", "XorMultiBlend", "Bitwise_Rotate", "Bitwise_Rotate Diff","HPPD","FuzzyLines","GradientLines","GradientSelf","GradientSelfVertical","GradientDown","GraidentHorizontal","GradientRGB","Inter","UpDown","LeftRight","StrobeScan","BlendedScanLines","GradientStripes","XorSine","SquareSwap","SquareSwap4x2","SquareSwap8x4","SquareSwap16x8","SquareSwap64x32","SquareBars","SquareBars8","SquareSwapRand16x8","SquareVertical8","SquareVertical16","SquareVertical_Roll","SquareSwapSort_Roll","SquareVertical_RollReverse","SquareSwapSort_RollReverse","Circular","WhitePixel","FrameBlend","FrameBlendRGB","TrailsFilter","TrailsFilterIntense","TrailsFilterSelfAlpha","TrailsFilterXor","ColorTrails","MoveRed","MoveRGB","MoveRedGreenBlue","BlurSim","Block","BlockXor","BlockScale","BlockStrobe","PrevFrameBlend","Wave","HighWave","VerticalSort","VerticalChannelSort","HorizontalBlend","VerticalBlend","OppositeBlend","DiagonalLines","HorizontalLines","InvertedScanlines","Soft_Mirror","KanapaTrip","ColorMorphing","ScanSwitch","ScanAlphaSwitch","NegativeStrobe", "XorAddMul","ParticleRelease", "BlendSwitch", "All Red", "All Green", "All Blue","LineRGB","PixelRGB","BoxedRGB","KruegerSweater","RGBFlash","IncreaseBlendHorizontal","BlendIncrease","GradientReverse","GradientReverseVertical","GradientReverseBox","GradientNewFilter","ReinterpretDouble","ReinterpSelfScale","AverageLines","ImageFile","ImageXor","ImageAlphaBlend","ColorRange","ImageInter","TrailsInter","TrailsBlend","TrailsNegate","InterReverse","InterMirror","InterFullMirror","MirrorRGB","RGBStatic1","RGBStatic2","VectorIncrease","LineByLineReverse","RandomIntertwine","RandomFour","BlendThree","AcidTrails","RandomTwo","HorizontalTrailsInter","Trails","BlendTrails","Negate","RandomFilteredSquare","ImageX","RandomQuads","QuadCosSinMultiply","QuadRandomFilter","RollRandom","AverageRandom","HorizontalStripes","DiamondStrobe","SmoothTrails","GridFilter8x","GridFilter16x","GridFilter8xBlend","GridRandom","GridRandomPixel","Dual_SelfAlphaRainbow","Dual_SelfAlphaBlur","SurroundPixelXor","Darken","WeakBlend","AverageVertical","RandomCollectionAverage","RandomCollectionAverageMax","SmoothTrailsSelfAlphaBlend","SmoothTrailsRainbowBlend","MedianBlend","SmoothRandomImageBlend","SmoothImageAlphaBlend","RandomAlphaBlend","RandomTwoFilterAlphaBlend","PixelatedSquare","AlphaBlendPosition","BlendRowAlpha", "BlendRow","BlendRowByVar","BlendRowByDirection","BlendAlphaXor","SelfXorScale","BitwiseXorScale","XorTrails", "RainbowTrails","NegativeTrails","IntenseTrails","SelfAlphaRGB","BlendImageOnOff","XorSelfAlphaImage","BitwiseXorStrobe","AlphaBlendRandom","ChannelSortAlphaBlend","XorChannelSort","GradientColors","GradientColorsVertical","Bitwise_XOR_Average","NotEqual","ImageShiftUpLeft","GradientXorSelfScale","SmoothSourcePixel","StrobeBlend","FrameBars","Sort_Vertical_Horizontal","Sort_Vertical_Horizontal_Bitwise_XOR","Scalar_Average_Multiply","Scalar_Average","Total_Average","AlphaBlendImageXor","FlashWhite","FlashBlackAndWhite","GaussianBlend","RandomXor","RandomXorFlash","RandomAmountMedianBlur","SoftXor","SelfXorBlend","SelfXorDoubleFlash","SelfOrDoubleFlash","BlendRowCurvedSqrt","CycleShiftRGB","CycleShiftRandomRGB","CycleShiftRandomRGB_XorBlend","CycleShiftRandomAlphaBlend","VerticalColorBars","GradientLeftRight","GraidentUpDown","GradientLeftRightInOut","GradientUpDownInOut","Lines","ColorLines","WhiteLines","ThickWhiteLines","UseLineObject","TanAlphaGrid","MedianBlendAnimation","FibFlash", "ScaleFlash","LeftLines","Curtain","RandomCurtain","CurtainVertical","RandomCurtainVertical","inOrder","inOrderBySecond","DarkenFilter","RandomFilterBySecond","ThreeRandom","inOrderAlpha","inOrderAlphaXor","SlideFilter","SlideFilterXor", "RandomSlideFilter","SlideUpDown","SlideUpDownXor", "SlideUpDownRandom","SlideSubFilter", "SlideSubUpDownFilter","ParticleBlend","ParticleFlash","ExactImage","ParticleAlpha","BlendInAndOut","BlendScaleInAndOut","AcidGlitch","XorBackwards","LiquidFilter","MatrixXorAnd","XorAlpha","AlphaAcidTrails","SelfXorAverage","RandomXorBlend","RGBVerticalXor","RGBVerticalXorScale","RGBHorizontalXor","RGBHorizontalXorScale","FadeStrobe","RGBMirror","MirrorStrobe","AndStrobe","AndStrobeScale", "AndPixelStrobe","AndOrXorStrobe","AndOrXorStrobeScale","FadeInAndOut","BrightStrobe","DarkStrobe","ParticleFast","RandomXorOpposite","StrobeTransform","InitBlend","MoveUpLeft","RandomStrobe","RandomBlur","Stuck","StuckStrobe","OrStrobe","LagBlend","SubFilter","AddFilter","BlendImageXor","BlendImageAround_Median","ImageBlendTransform","RGBTrails","RGBTrailsDark","RGBTrailsAlpha","RGBTrailsNegativeAlpha","MovementRGBTrails","RGBTrailsXor","DifferenceStrobe","BlackAndWhiteDifferenceStrobe","DifferenceXor","DifferenceRand", "DifferenceBrightStrobe","PsycheTrails","FourSquare","EightSquare","DiagonalSquare","DiagonalSquareRandom","SquareStretchDown","SquareStretchRight","SquareStretchUp","SquareStretchLeft","DarkTrails","SoftFeedback","SoftFeedbackFrames","ResizeSoftFeedback","SoftFeedback8","SoftFeedbackFrames8","ResizeSoftFeedback8","ResizeSoftFeedbackSubFilter","SoftFeedbackRandFilter","SoftFeedback32","SoftFeedbackFrames32","ResizeSoftFeedback32","SoftFeedbackRandFilter32","SoftFeedbackSubFilter","SoftFeedbackResizeSubFilter","SoftFeedbackResize64","SoftFeedbackResizeSubFilter64","SoftFeedbackReszieSubFilter64_Negate","SoftFeedbackReszieSubFilter64_Mirror","HalfNegateStrobe","MedianBlurXor","NegateTrails","RandomGradient","RandomStrobeFlash","RandomMirror","RandomOther","RandomXorFilter","RandomMirrorBlend","RandomMirrorAlphaBlend","Bitwise_XOR_AlphaSubFilter","AlphaBlendSubFilter","GradientSubFilterXor","XorBlend_SubFilter","SmoothSubFilterAlphaBlend","SmoothSubFilterXorBlend","IntertwineSubFilter","RandBlend","EveryOther","EveryOtherSubFilter","SmoothRandomFilter","RandomFilterRandomTimes","RandomSubFilterRandomTimes","AddToFrameSubFilter","MirrorXor","MirrorXorAll","MirrorXorScale","EnergyMirror","SmoothSubFilter","EnergizeSubFilter","SmoothSubFilter16","EnergizeSubFilter16","EnergizeSubFilter32","SmoothSubFilter32","HalfAddSubFilter","HalfXorSubFilter","StaticXorBlend","PsycheSort","XorScale","ChannelMedianSubFilter","GaussianStrobe","StrobeSort","GlitchSortStrobe","Bitwise_XOR_Blend","Bitwise_XOR_Sort","Bitwise_OR_Blend","Bitwise_AND_Blend","BitwiseColorMatrix","PixelReverseXor","PixelatedSubFilterSort","SilverBlend","RandomPixelOrderSort","ImageXorAlpha","ImageAverageXor","PixelXorBlend","SelfAlphaScale","SelfScaleAlpha","RainbowXorBlend","FrameDifference","SmallDiffference","FadeBlend","FilteredDifferenceSubFilter","ExpandSquareSubFilter","ExpandSquareBlendSubFilter","ExpandSquareVerticalSubFilter","DarkImageMedianBlend","GammaDarken5","GammaDarken10","SelfAlphaScaleBlend","FadeBars","MirrorXorAlpha","MirrorEnergizeSubFilter","StrobeXor","IntertwinedMirror","BlurredMirror","ShadeRGB","InterRGB_SubFilter","InterSmoothSubFilter","InterRGB_Bars_XY","InterRGB_Bars_X","InterRGB_Bars_Y","StoredFramesAlphaBlend_SubFilter","BlendSubFilter","BlendAlphaSubFilter","ReverseFrameBlend","ReverseFrameBlendSwitch","DoubleRandomMirror","Blend_AlphaSubFilter","RandomBlendFilter","DoubleRandomBlendFilter","FlipBlendW","FlipBlendWH", "FlipBlendH", "FlipBlendAll","FrameMedianBlendSubFilter","FrameBlurSubFilter","ImageBlendSubFilter","ImageBlendXorSubFilter","ImageCollectionSubFilter","SelfScaleXorIncrease","Blend_RedGreenBlue","XorBlend_RedGreenBlue","BlendIncrease_RedGreenBlue","Blend_RedReenBlue_Dark","DarkModBlend","PictureBuzz","IncDifference","IncDifferenceAlpha","MirrorMedianBlend","SubFilterMedianBlend","DarkenBlend","DarkCollectionSubFilter","ChannelSort_NoBlend_Descending", "ChannelSort_NoBlend_Ascending","Headrush","DarkSmooth_Filter","DarkSelfAlpha","FlipMedian","FlipMedianSubFilter","FlipMirror","FlipMirrorAverage","FlipMirrorSubFilter","ShuffleMedian","ShuffleRGB","ParticleSnow","RandomPixels","DarkRandomPixels","MedianBlurSubFilter","Bars","ShuffleAlpha","AlphaMorph","ShuffleSelf", + "No Filter", + "Blend with Source", "Plugin", "Custom","Blend With Image #1","TriBlend with Image", "Image Strobe", "Image distraction" }; + // draw strings + std::string *draw_strings = draw_strings_value; + + + // filter callback functions + DrawFunction draw_func_value[] = { SelfAlphaBlend, SelfScale, StrobeEffect, Blend3, NegParadox, ThoughtMode, RandTriBlend, Blank,Tri,Distort,CDraw,Type,NewOne,blendFractal,blendFractalMood,cossinMultiply,colorAccumulate1,colorAccumulate2,colorAccumulate3,filter8,filter3,rainbowBlend,randBlend,newBlend,alphaFlame,pixelScale,pixelSort,glitchSort,randomFilter,randomFlash,imageBlend,imageBlendTwo,imageBlendThree,imageBlendFour,GaussianBlur,MedianBlur,BlurDistortion,DiamondPattern,MirrorBlend,Pulse,SidewaysMirror,MirrorNoBlend,SortFuzz,Fuzz,DoubleVision,RGBShift,RGBSep,GradientRainbow,GradientRainbowFlash,Reverse,Scanlines,TVStatic,MirrorAverage,MirrorAverageMix,Mean,Laplacian,Bitwise_XOR,Bitwise_AND,Bitwise_OR,Equalize,ChannelSort,Reverse_XOR,CombinePixels,FlipTrip,Canny,Boxes,BoxesFade,FlashBlack,SlideRGB,Side2Side,Top2Bottom,StrobeRedGreenBlue,Blend_Angle,Outward,OutwardSquare,ShiftPixels,ShiftPixelsDown,XorMultiBlend,BitwiseRotate,BitwiseRotateDiff,HPPD,FuzzyLines,GradientLines,GradientSelf,GradientSelfVertical,GradientDown,GraidentHorizontal,GradientRGB,Inter,UpDown,LeftRight,StrobeScan,BlendedScanLines,GradientStripes,XorSine,SquareSwap,SquareSwap4x2,SquareSwap8x4,SquareSwap16x8,SquareSwap64x32,SquareBars,SquareBars8,SquareSwapRand16x8,SquareVertical8,SquareVertical16,SquareVertical_Roll,SquareSwapSort_Roll,SquareVertical_RollReverse,SquareSwapSort_RollReverse,Circular,WhitePixel,FrameBlend,FrameBlendRGB,TrailsFilter,TrailsFilterIntense,TrailsFilterSelfAlpha,TrailsFilterXor,ColorTrails,MoveRed,MoveRGB,MoveRedGreenBlue,BlurSim,Block,BlockXor,BlockScale,BlockStrobe,PrevFrameBlend,Wave,HighWave,VerticalSort,VerticalChannelSort,HorizontalBlend,VerticalBlend,OppositeBlend,DiagonalLines,HorizontalLines,InvertedScanlines,Soft_Mirror,KanapaTrip,ColorMorphing,ScanSwitch,ScanAlphaSwitch,NegativeStrobe,XorAddMul,ParticleRelease,BlendSwitch,AllRed,AllGreen,AllBlue,LineRGB,PixelRGB,BoxedRGB,KruegerSweater,RGBFlash,IncreaseBlendHorizontal,BlendIncrease,GradientReverse,GradientReverseVertical,GradientReverseBox,GradientNewFilter,ReinterpretDouble,ReinterpSelfScale,AverageLines,ImageFile,ImageXor,ImageAlphaBlend,ColorRange,ImageInter,TrailsInter,TrailsBlend,TrailsNegate,InterReverse,InterMirror,InterFullMirror,MirrorRGB,RGBStatic1,RGBStatic2,VectorIncrease,LineByLineReverse,RandomIntertwine,RandomFour,BlendThree,AcidTrails,RandomTwo,HorizontalTrailsInter,Trails,BlendTrails,Negate,RandomFilteredSquare,ImageX,RandomQuads,QuadCosSinMultiply,QuadRandomFilter,RollRandom,AverageRandom,HorizontalStripes,DiamondStrobe,SmoothTrails,GridFilter8x,GridFilter16x,GridFilter8xBlend,GridRandom,GridRandomPixel,Dual_SelfAlphaRainbow,Dual_SelfAlphaBlur,SurroundPixelXor,Darken,WeakBlend,AverageVertical,RandomCollectionAverage,RandomCollectionAverageMax,SmoothTrailsSelfAlphaBlend,SmoothTrailsRainbowBlend,MedianBlend,SmoothRandomImageBlend,SmoothImageAlphaBlend,RandomAlphaBlend,RandomTwoFilterAlphaBlend,PixelatedSquare,AlphaBlendPosition,BlendRowAlpha,BlendRow,BlendRowByVar,BlendRowByDirection,BlendAlphaXor,SelfXorScale,BitwiseXorScale,XorTrails,RainbowTrails,NegativeTrails,IntenseTrails,SelfAlphaRGB,BlendImageOnOff,XorSelfAlphaImage,BitwiseXorStrobe,AlphaBlendRandom,ChannelSortAlphaBlend,XorChannelSort,GradientColors,GradientColorsVertical,Bitwise_XOR_Average,NotEqual,ImageShiftUpLeft,GradientXorSelfScale,SmoothSourcePixel,StrobeBlend,FrameBars,Sort_Vertical_Horizontal,Sort_Vertical_Horizontal_Bitwise_XOR,Scalar_Average_Multiply,Scalar_Average,Total_Average,AlphaBlendImageXor,FlashWhite,FlashBlackAndWhite,GaussianBlend,RandomXor,RandomXorFlash,RandomAmountMedianBlur,SoftXor,SelfXorBlend,SelfXorDoubleFlash,SelfOrDoubleFlash,BlendRowCurvedSqrt,CycleShiftRGB,CycleShiftRandomRGB,CycleShiftRandomRGB_XorBlend,CycleShiftRandomAlphaBlend,VerticalColorBars,GradientLeftRight,GraidentUpDown,GradientLeftRightInOut,GradientUpDownInOut,Lines,ColorLines,WhiteLines,ThickWhiteLines,UseLineObject,TanAlphaGrid,MedianBlendAnimation,FibFlash,ScaleFlash,LeftLines,Curtain,RandomCurtain,CurtainVertical,RandomCurtainVertical,inOrder,inOrderBySecond,DarkenFilter,RandomFilterBySecond,ThreeRandom,inOrderAlpha,inOrderAlphaXor,SlideFilter,SlideFilterXor,RandomSlideFilter,SlideUpDown,SlideUpDownXor,SlideUpDownRandom,SlideSubFilter,SlideSubUpDownFilter,ParticleBlend,ParticleFlash,ExactImage,ParticleAlpha,BlendInAndOut,BlendScaleInAndOut,AcidGlitch,XorBackwards,LiquidFilter,MatrixXorAnd,XorAlpha,AlphaAcidTrails,SelfXorAverage,RandomXorBlend,RGBVerticalXor,RGBVerticalXorScale,RGBHorizontalXor,RGBHorizontalXorScale,FadeStrobe,RGBMirror,MirrorStrobe,AndStrobe,AndStrobeScale,AndPixelStrobe,AndOrXorStrobe,AndOrXorStrobeScale,FadeInAndOut,BrightStrobe,DarkStrobe,ParticleFast,RandomXorOpposite,StrobeTransform,InitBlend,MoveUpLeft,RandomStrobe,RandomBlur,Stuck,StuckStrobe,OrStrobe,LagBlend,SubFilter,AddFilter,BlendImageXor,BlendImageAround_Median,ImageBlendTransform,RGBTrails,RGBTrailsDark,RGBTrailsAlpha,RGBTrailsNegativeAlpha,MovementRGBTrails,RGBTrailsXor,DifferenceStrobe,BlackAndWhiteDifferenceStrobe,DifferenceXor,DifferenceRand,DifferenceBrightStrobe,PsycheTrails,FourSquare,EightSquare,DiagonalSquare,DiagonalSquareRandom,SquareStretchDown,SquareStretchRight,SquareStretchUp,SquareStretchLeft,DarkTrails,SoftFeedback,SoftFeedbackFrames,ResizeSoftFeedback,SoftFeedback8,SoftFeedbackFrames8,ResizeSoftFeedback8,ResizeSoftFeedbackSubFilter,SoftFeedbackRandFilter,SoftFeedback32,SoftFeedbackFrames32,ResizeSoftFeedback32,SoftFeedbackRandFilter32,SoftFeedbackSubFilter,SoftFeedbackResizeSubFilter,SoftFeedbackResize64,SoftFeedbackResizeSubFilter64,SoftFeedbackReszieSubFilter64_Negate,SoftFeedbackReszieSubFilter64_Mirror,HalfNegateStrobe,MedianBlurXor,NegateTrails,RandomGradient,RandomStrobeFlash,RandomMirror,RandomOther,RandomXorFilter,RandomMirrorBlend,RandomMirrorAlphaBlend,Bitwise_XOR_AlphaSubFilter,AlphaBlendSubFilter,GradientSubFilterXor,XorBlend_SubFilter,SmoothSubFilterAlphaBlend,SmoothSubFilterXorBlend,IntertwineSubFilter,RandBlend,EveryOther,EveryOtherSubFilter,SmoothRandomFilter,RandomFilterRandomTimes,RandomSubFilterRandomTimes,AddToFrameSubFilter,MirrorXor,MirrorXorAll,MirrorXorScale,EnergyMirror,SmoothSubFilter,EnergizeSubFilter,SmoothSubFilter16,EnergizeSubFilter16,EnergizeSubFilter32,SmoothSubFilter32,HalfAddSubFilter,HalfXorSubFilter,StaticXorBlend,PsycheSort,XorScale,ChannelMedianSubFilter,GaussianStrobe,StrobeSort,GlitchSortStrobe,Bitwise_XOR_Blend,Bitwise_XOR_Sort,Bitwise_OR_Blend,Bitwise_AND_Blend,BitwiseColorMatrix,PixelReverseXor,PixelatedSubFilterSort,SilverBlend,RandomPixelOrderSort,ImageXorAlpha,ImageAverageXor,PixelXorBlend,SelfAlphaScale,SelfScaleAlpha,RainbowXorBlend,FrameDifference,SmallDiffference,FadeBlend,FilteredDifferenceSubFilter,ExpandSquareSubFilter,ExpandSquareBlendSubFilter,ExpandSquareVerticalSubFilter,DarkImageMedianBlend,GammaDarken5,GammaDarken10,SelfAlphaScaleBlend,FadeBars,MirrorXorAlpha,MirrorEnergizeSubFilter,StrobeXor,IntertwinedMirror,BlurredMirror,ShadeRGB,InterRGB_SubFilter,InterSmoothSubFilter,InterRGB_Bars_XY,InterRGB_Bars_X,InterRGB_Bars_Y,StoredFramesAlphaBlend_SubFilter,BlendSubFilter,BlendAlphaSubFilter,ReverseFrameBlend,ReverseFrameBlendSwitch,DoubleRandomMirror,Blend_AlphaSubFilter,RandomBlendFilter,DoubleRandomBlendFilter,FlipBlendW,FlipBlendWH,FlipBlendH,FlipBlendAll,FrameMedianBlendSubFilter,FrameBlurSubFilter,ImageBlendSubFilter,ImageBlendXorSubFilter,ImageCollectionSubFilter,SelfScaleXorIncrease,Blend_RedGreenBlue,XorBlend_RedGreenBlue,BlendIncrease_RedGreenBlue,Blend_RedReenBlue_Dark,DarkModBlend,PictureBuzz,IncDifference,IncDifferenceAlpha,MirrorMedianBlend,SubFilterMedianBlend,DarkenBlend,DarkCollectionSubFilter,ChannelSort_NoBlend_Descending,ChannelSort_NoBlend_Ascending,Headrush,DarkSmooth_Filter,DarkSelfAlpha,FlipMedian,FlipMedianSubFilter,FlipMirror,FlipMirrorAverage,FlipMirrorSubFilter,ShuffleMedian,ShuffleRGB,ParticleSnow,RandomPixels,DarkRandomPixels,MedianBlurSubFilter,Bars,ShuffleAlpha,AlphaMorph,ShuffleSelf, + NoFilter, + BlendWithSource,plugin,custom,blendWithImage, triBlendWithImage,imageStrobe, imageDistraction,0}; + // draw functions + DrawFunction *draw_func = draw_func_value; + // number of filters + int draw_max = 525; + // variables + double translation_variable = 0.001f, pass2_alpha = 0.75f; + // swap colors inline function + std::unordered_map filter_map; + bool color_map_set = false; + DrawFunction custom_callback = 0; + DrawFunction plugin_func = 0; + int colors[3] = {rand()%255, rand()%255, rand()%255}; + int proc_mode = 0; + bool reset_filter = false; + double alpha_increase = 0; + + FilterType filters[] = { + {"Self AlphaBlend",SelfAlphaBlend}, {"Self Scale", SelfScale}, {"StrobeEffect", StrobeEffect}, {"Blend #3", Blend3}, {"Negative Paradox", NegParadox}, {"ThoughtMode", ThoughtMode}, {"RandTriBlend", RandTriBlend}, {"Blank", Blank}, {"Tri",Tri}, {"Distort",Distort}, {"CDraw",CDraw}, {"Type",Type}, {"NewOne",NewOne}, {"Blend Fractal",blendFractal}, {"Blend Fractal Mood",blendFractalMood}, {"CosSinMultiply",cossinMultiply}, {"Color Accumlate1",colorAccumulate1}, {"Color Accumulate2",colorAccumulate2}, {"Color Accumulate3",colorAccumulate3}, {"Filter8",filter8}, {"Filter3",filter3}, {"Rainbow Blend",rainbowBlend}, {"Rand Blend",randBlend}, {"New Blend",newBlend}, {"Alpha Flame Filters",alphaFlame}, {"Pixel Scale",pixelScale}, {"PixelSort",pixelSort}, {"GlitchSort",glitchSort}, {"Random Filter",randomFilter}, {"Random Flash",randomFlash}, {"Blend with Image",imageBlend}, {"Blend with Image #2",imageBlendTwo}, {"Blend with Image #3",imageBlendThree}, {"Blend with Image #4",imageBlendFour}, {"GaussianBlur",GaussianBlur}, {"Median Blur",MedianBlur}, {"Blur Distortion",BlurDistortion}, {"Diamond Pattern",DiamondPattern}, {"MirrorBlend",MirrorBlend}, {"Pulse",Pulse}, {"Sideways Mirror",SidewaysMirror}, {"Mirror No Blend",MirrorNoBlend}, {"Sort Fuzz",SortFuzz}, {"Fuzz",Fuzz}, {"Double Vision",DoubleVision}, {"RGB Shift",RGBShift}, {"RGB Sep",RGBSep}, {"Graident Rainbow",GradientRainbow}, {"Gradient Rainbow Flash",GradientRainbowFlash}, {"Reverse",Reverse}, {"Scanlines",Scanlines}, {"TV Static",TVStatic}, {"Mirror Average",MirrorAverage}, {"Mirror Average Mix",MirrorAverageMix}, {"Mean",Mean}, {"Laplacian",Laplacian}, {"Bitwise_XOR",Bitwise_XOR}, {"Bitwise_AND",Bitwise_AND}, {"Bitwise_OR",Bitwise_OR}, {"Equalize",Equalize}, {"Channel Sort",ChannelSort}, {"Reverse_XOR",Reverse_XOR}, {"Combine Pixels",CombinePixels}, {"FlipTrip",FlipTrip}, {"Canny",Canny}, {"Boxes",Boxes}, {"Boxes Fade",BoxesFade}, {"Flash Black",FlashBlack}, {"SlideRGB",SlideRGB}, {"Side2Side",Side2Side}, {"Top2Bottom",Top2Bottom}, {"Strobe Red Then Green Then Blue",StrobeRedGreenBlue}, {"Blend_Angle",Blend_Angle}, {"Outward",Outward}, {"Outward Square",OutwardSquare}, {"ShiftPixels",ShiftPixels}, {"ShiftPixelsDown",ShiftPixelsDown}, {"XorMultiBlend",XorMultiBlend}, {"Bitwise_Rotate",BitwiseRotate}, {"Bitwise_Rotate Diff",BitwiseRotateDiff}, {"HPPD",HPPD}, {"FuzzyLines",FuzzyLines}, {"GradientLines",GradientLines}, {"GradientSelf",GradientSelf}, {"GradientSelfVertical",GradientSelfVertical}, {"GradientDown",GradientDown}, {"GraidentHorizontal",GraidentHorizontal}, {"GradientRGB",GradientRGB}, {"Inter",Inter}, {"UpDown",UpDown}, {"LeftRight",LeftRight}, {"StrobeScan",StrobeScan}, {"BlendedScanLines",BlendedScanLines}, {"GradientStripes",GradientStripes}, {"XorSine",XorSine}, {"SquareSwap",SquareSwap}, {"SquareSwap4x2",SquareSwap4x2}, {"SquareSwap8x4",SquareSwap8x4}, {"SquareSwap16x8",SquareSwap16x8}, {"SquareSwap64x32",SquareSwap64x32}, {"SquareBars",SquareBars}, {"SquareBars8",SquareBars8}, {"SquareSwapRand16x8",SquareSwapRand16x8}, {"SquareVertical8",SquareVertical8}, {"SquareVertical16",SquareVertical16}, {"SquareVertical_Roll",SquareVertical_Roll}, {"SquareSwapSort_Roll",SquareSwapSort_Roll}, {"SquareVertical_RollReverse",SquareVertical_RollReverse}, {"SquareSwapSort_RollReverse",SquareSwapSort_RollReverse}, {"Circular",Circular}, {"WhitePixel",WhitePixel}, {"FrameBlend",FrameBlend}, {"FrameBlendRGB",FrameBlendRGB}, {"TrailsFilter",TrailsFilter}, {"TrailsFilterIntense",TrailsFilterIntense}, {"TrailsFilterSelfAlpha",TrailsFilterSelfAlpha}, {"TrailsFilterXor",TrailsFilterXor}, {"ColorTrails",ColorTrails}, {"MoveRed",MoveRed}, {"MoveRGB",MoveRGB}, {"MoveRedGreenBlue",MoveRedGreenBlue}, {"BlurSim",BlurSim}, {"Block",Block}, {"BlockXor",BlockXor}, {"BlockScale",BlockScale}, {"BlockStrobe",BlockStrobe}, {"PrevFrameBlend",PrevFrameBlend}, {"Wave",Wave}, {"HighWave",HighWave}, {"VerticalSort",VerticalSort}, {"VerticalChannelSort",VerticalChannelSort}, {"HorizontalBlend",HorizontalBlend}, {"VerticalBlend",VerticalBlend}, {"OppositeBlend",OppositeBlend}, {"DiagonalLines",DiagonalLines}, {"HorizontalLines",HorizontalLines}, {"InvertedScanlines",InvertedScanlines}, {"Soft_Mirror",Soft_Mirror}, {"KanapaTrip",KanapaTrip}, {"ColorMorphing",ColorMorphing}, {"ScanSwitch",ScanSwitch}, {"ScanAlphaSwitch",ScanAlphaSwitch}, {"NegativeStrobe",NegativeStrobe}, {"XorAddMul",XorAddMul}, {"ParticleRelease",ParticleRelease}, {"BlendSwitch",BlendSwitch}, {"All Red",AllRed}, {"All Green",AllGreen}, {"All Blue",AllBlue}, {"LineRGB",LineRGB}, {"PixelRGB",PixelRGB}, {"BoxedRGB",BoxedRGB}, {"KruegerSweater",KruegerSweater}, {"RGBFlash",RGBFlash}, {"IncreaseBlendHorizontal",IncreaseBlendHorizontal}, {"BlendIncrease",BlendIncrease}, {"GradientReverse",GradientReverse}, {"GradientReverseVertical",GradientReverseVertical}, {"GradientReverseBox",GradientReverseBox}, {"GradientNewFilter",GradientNewFilter}, {"ReinterpretDouble",ReinterpretDouble}, {"ReinterpSelfScale",ReinterpSelfScale}, {"AverageLines",AverageLines}, {"ImageFile",ImageFile}, {"ImageXor",ImageXor}, {"ImageAlphaBlend",ImageAlphaBlend}, {"ColorRange",ColorRange}, {"ImageInter",ImageInter}, {"TrailsInter",TrailsInter}, {"TrailsBlend",TrailsBlend}, {"TrailsNegate",TrailsNegate}, {"InterReverse",InterReverse}, {"InterMirror",InterMirror}, {"InterFullMirror",InterFullMirror}, {"MirrorRGB",MirrorRGB}, {"RGBStatic1",RGBStatic1}, {"RGBStatic2",RGBStatic2}, {"VectorIncrease",VectorIncrease}, {"LineByLineReverse",LineByLineReverse}, {"RandomIntertwine",RandomIntertwine}, {"RandomFour",RandomFour}, {"BlendThree",BlendThree}, {"AcidTrails",AcidTrails}, {"RandomTwo",RandomTwo}, {"HorizontalTrailsInter",HorizontalTrailsInter}, {"Trails",Trails}, {"BlendTrails",BlendTrails}, {"Negate",Negate}, {"RandomFilteredSquare",RandomFilteredSquare}, {"ImageX",ImageX}, {"RandomQuads",RandomQuads}, {"QuadCosSinMultiply",QuadCosSinMultiply}, {"QuadRandomFilter",QuadRandomFilter}, {"RollRandom",RollRandom}, {"AverageRandom",AverageRandom}, {"HorizontalStripes",HorizontalStripes}, {"DiamondStrobe",DiamondStrobe}, {"SmoothTrails",SmoothTrails}, {"GridFilter8x",GridFilter8x}, {"GridFilter16x",GridFilter16x}, {"GridFilter8xBlend",GridFilter8xBlend}, {"GridRandom",GridRandom}, {"GridRandomPixel",GridRandomPixel}, {"Dual_SelfAlphaRainbow",Dual_SelfAlphaRainbow}, {"Dual_SelfAlphaBlur",Dual_SelfAlphaBlur}, {"SurroundPixelXor",SurroundPixelXor}, {"Darken",Darken}, {"WeakBlend",WeakBlend}, {"AverageVertical",AverageVertical}, {"RandomCollectionAverage",RandomCollectionAverage}, {"RandomCollectionAverageMax",RandomCollectionAverageMax}, {"SmoothTrailsSelfAlphaBlend",SmoothTrailsSelfAlphaBlend}, {"SmoothTrailsRainbowBlend",SmoothTrailsRainbowBlend}, {"MedianBlend",MedianBlend}, {"SmoothRandomImageBlend",SmoothRandomImageBlend}, {"SmoothImageAlphaBlend",SmoothImageAlphaBlend}, {"RandomAlphaBlend",RandomAlphaBlend}, {"RandomTwoFilterAlphaBlend",RandomTwoFilterAlphaBlend}, {"PixelatedSquare",PixelatedSquare}, {"AlphaBlendPosition",AlphaBlendPosition}, {"BlendRowAlpha",BlendRowAlpha}, {"BlendRow",BlendRow}, {"BlendRowByVar",BlendRowByVar}, {"BlendRowByDirection",BlendRowByDirection}, {"BlendAlphaXor",BlendAlphaXor}, {"SelfXorScale",SelfXorScale}, {"BitwiseXorScale",BitwiseXorScale}, {"XorTrails",XorTrails}, {"RainbowTrails",RainbowTrails}, {"NegativeTrails",NegativeTrails}, {"IntenseTrails",IntenseTrails}, {"SelfAlphaRGB",SelfAlphaRGB}, {"BlendImageOnOff",BlendImageOnOff}, {"XorSelfAlphaImage",XorSelfAlphaImage}, {"BitwiseXorStrobe",BitwiseXorStrobe}, {"AlphaBlendRandom",AlphaBlendRandom}, {"ChannelSortAlphaBlend",ChannelSortAlphaBlend}, {"XorChannelSort",XorChannelSort}, {"GradientColors",GradientColors}, {"GradientColorsVertical",GradientColorsVertical}, {"Bitwise_XOR_Average",Bitwise_XOR_Average}, {"NotEqual",NotEqual}, {"ImageShiftUpLeft",ImageShiftUpLeft}, {"GradientXorSelfScale",GradientXorSelfScale}, {"SmoothSourcePixel",SmoothSourcePixel}, {"StrobeBlend",StrobeBlend}, {"FrameBars",FrameBars}, {"Sort_Vertical_Horizontal",Sort_Vertical_Horizontal}, {"Sort_Vertical_Horizontal_Bitwise_XOR",Sort_Vertical_Horizontal_Bitwise_XOR}, {"Scalar_Average_Multiply",Scalar_Average_Multiply}, {"Scalar_Average",Scalar_Average}, {"Total_Average",Total_Average}, {"AlphaBlendImageXor",AlphaBlendImageXor}, {"FlashWhite",FlashWhite}, {"FlashBlackAndWhite",FlashBlackAndWhite}, {"GaussianBlend",GaussianBlend}, {"RandomXor",RandomXor}, {"RandomXorFlash",RandomXorFlash}, {"RandomAmountMedianBlur",RandomAmountMedianBlur}, {"SoftXor",SoftXor}, {"SelfXorBlend",SelfXorBlend}, {"SelfXorDoubleFlash",SelfXorDoubleFlash}, {"SelfOrDoubleFlash",SelfOrDoubleFlash}, {"BlendRowCurvedSqrt",BlendRowCurvedSqrt}, {"CycleShiftRGB",CycleShiftRGB}, {"CycleShiftRandomRGB",CycleShiftRandomRGB}, {"CycleShiftRandomRGB_XorBlend",CycleShiftRandomRGB_XorBlend}, {"CycleShiftRandomAlphaBlend",CycleShiftRandomAlphaBlend}, {"VerticalColorBars",VerticalColorBars}, {"GradientLeftRight",GradientLeftRight}, {"GraidentUpDown",GraidentUpDown}, {"GradientLeftRightInOut",GradientLeftRightInOut}, {"GradientUpDownInOut",GradientUpDownInOut}, {"Lines",Lines}, {"ColorLines",ColorLines}, {"WhiteLines",WhiteLines}, {"ThickWhiteLines",ThickWhiteLines}, {"UseLineObject",UseLineObject}, {"TanAlphaGrid",TanAlphaGrid}, {"MedianBlendAnimation",MedianBlendAnimation}, {"FibFlash",FibFlash}, {"ScaleFlash",ScaleFlash}, {"LeftLines",LeftLines}, {"Curtain",Curtain}, {"RandomCurtain",RandomCurtain}, {"CurtainVertical",CurtainVertical}, {"RandomCurtainVertical",RandomCurtainVertical}, {"inOrder",inOrder}, {"inOrderBySecond",inOrderBySecond}, {"DarkenFilter",DarkenFilter}, {"RandomFilterBySecond",RandomFilterBySecond}, {"ThreeRandom",ThreeRandom}, {"inOrderAlpha",inOrderAlpha}, {"inOrderAlphaXor",inOrderAlphaXor}, {"SlideFilter",SlideFilter}, {"SlideFilterXor",SlideFilterXor}, {"RandomSlideFilter",RandomSlideFilter}, {"SlideUpDown",SlideUpDown}, {"SlideUpDownXor",SlideUpDownXor}, {"SlideUpDownRandom",SlideUpDownRandom}, {"SlideSubFilter",SlideSubFilter}, {"SlideSubUpDownFilter",SlideSubUpDownFilter}, {"ParticleBlend",ParticleBlend}, {"ParticleFlash",ParticleFlash}, {"ExactImage",ExactImage}, {"ParticleAlpha",ParticleAlpha}, {"BlendInAndOut",BlendInAndOut}, {"BlendScaleInAndOut",BlendScaleInAndOut}, {"AcidGlitch",AcidGlitch}, {"XorBackwards",XorBackwards}, {"LiquidFilter",LiquidFilter}, {"MatrixXorAnd",MatrixXorAnd}, {"XorAlpha",XorAlpha}, {"AlphaAcidTrails",AlphaAcidTrails}, {"SelfXorAverage",SelfXorAverage}, {"RandomXorBlend",RandomXorBlend}, {"RGBVerticalXor",RGBVerticalXor}, {"RGBVerticalXorScale",RGBVerticalXorScale}, {"RGBHorizontalXor",RGBHorizontalXor}, {"RGBHorizontalXorScale",RGBHorizontalXorScale}, {"FadeStrobe",FadeStrobe}, {"RGBMirror",RGBMirror}, {"MirrorStrobe",MirrorStrobe}, {"AndStrobe",AndStrobe}, {"AndStrobeScale",AndStrobeScale}, {"AndPixelStrobe",AndPixelStrobe}, {"AndOrXorStrobe",AndOrXorStrobe}, {"AndOrXorStrobeScale",AndOrXorStrobeScale}, {"FadeInAndOut",FadeInAndOut}, {"BrightStrobe",BrightStrobe}, {"DarkStrobe",DarkStrobe}, {"ParticleFast",ParticleFast}, {"RandomXorOpposite",RandomXorOpposite}, {"StrobeTransform",StrobeTransform}, {"InitBlend",InitBlend}, {"MoveUpLeft",MoveUpLeft}, {"RandomStrobe",RandomStrobe}, {"RandomBlur",RandomBlur}, {"Stuck",Stuck}, {"StuckStrobe",StuckStrobe}, {"OrStrobe",OrStrobe}, {"LagBlend",LagBlend}, {"SubFilter",SubFilter}, {"AddFilter",AddFilter}, {"BlendImageXor",BlendImageXor}, {"BlendImageAround_Median",BlendImageAround_Median}, {"ImageBlendTransform",ImageBlendTransform}, {"RGBTrails",RGBTrails}, {"RGBTrailsDark",RGBTrailsDark}, {"RGBTrailsAlpha",RGBTrailsAlpha}, {"RGBTrailsNegativeAlpha",RGBTrailsNegativeAlpha}, {"MovementRGBTrails",MovementRGBTrails}, {"RGBTrailsXor",RGBTrailsXor}, {"DifferenceStrobe",DifferenceStrobe}, {"BlackAndWhiteDifferenceStrobe",BlackAndWhiteDifferenceStrobe}, {"DifferenceXor",DifferenceXor}, {"DifferenceRand",DifferenceRand}, {"DifferenceBrightStrobe",DifferenceBrightStrobe}, {"PsycheTrails",PsycheTrails}, {"FourSquare",FourSquare}, {"EightSquare",EightSquare}, {"DiagonalSquare",DiagonalSquare}, {"DiagonalSquareRandom",DiagonalSquareRandom}, {"SquareStretchDown",SquareStretchDown}, {"SquareStretchRight",SquareStretchRight}, {"SquareStretchUp",SquareStretchUp}, {"SquareStretchLeft",SquareStretchLeft}, {"DarkTrails",DarkTrails}, {"SoftFeedback",SoftFeedback}, {"SoftFeedbackFrames",SoftFeedbackFrames}, {"ResizeSoftFeedback",ResizeSoftFeedback}, {"SoftFeedback8",SoftFeedback8}, {"SoftFeedbackFrames8",SoftFeedbackFrames8}, {"ResizeSoftFeedback8",ResizeSoftFeedback8}, {"ResizeSoftFeedbackSubFilter",ResizeSoftFeedbackSubFilter}, {"SoftFeedbackRandFilter",SoftFeedbackRandFilter}, {"SoftFeedback32",SoftFeedback32}, {"SoftFeedbackFrames32",SoftFeedbackFrames32}, {"ResizeSoftFeedback32",ResizeSoftFeedback32}, {"SoftFeedbackRandFilter32",SoftFeedbackRandFilter32}, {"SoftFeedbackSubFilter",SoftFeedbackSubFilter}, {"SoftFeedbackResizeSubFilter",SoftFeedbackResizeSubFilter},{"SoftFeedbackResize64",SoftFeedbackResize64}, {"SoftFeedbackResizeSubFilter64",SoftFeedbackResizeSubFilter64}, {"SoftFeedbackReszieSubFilter64_Negate",SoftFeedbackReszieSubFilter64_Negate}, {"SoftFeedbackReszieSubFilter64_Mirror",SoftFeedbackReszieSubFilter64_Mirror}, {"HalfNegateStrobe",HalfNegateStrobe},{"MedianBlurXor", MedianBlurXor},{"NegateTrails", NegateTrails},{"RandomGradient", RandomGradient},{"RandomStrobeFlash", RandomStrobeFlash}, {"RandomMirror", RandomMirror},{"RandomOther", RandomOther},{"RandomXorFilter", RandomXorFilter},{"RandomMirrorBlend", RandomMirrorBlend},{"RandomMirrorAlphaBlend", RandomMirrorAlphaBlend}, {"Bitwise_XOR_AlphaSubFilter", Bitwise_XOR_AlphaSubFilter}, {"AlphaBlendSubFilter", AlphaBlendSubFilter},{"GradientSubFilterXor", GradientSubFilterXor},{"XorBlend_SubFilter", XorBlend_SubFilter},{"SmoothSubFilterAlphaBlend", SmoothSubFilterAlphaBlend},{"SmoothSubFilterXorBlend", SmoothSubFilterXorBlend},{"IntertwineSubFilter", IntertwineSubFilter},{"RandBlend", RandBlend},{"EveryOther", EveryOther},{"EveryOtherSubFilter", EveryOtherSubFilter},{"SmoothRandomFilter", SmoothRandomFilter},{"RandomFilterRandomTimes", RandomFilterRandomTimes},{"RandomSubFilterRandomTimes", RandomSubFilterRandomTimes},{"AddToFrameSubFilter",AddToFrameSubFilter},{"MirrorXor", MirrorXor},{"MirrorXorAll", MirrorXorAll}, {"MirrorXorScale", MirrorXorScale},{"EnergyMirror",EnergyMirror},{"SmoothSubFilter", SmoothSubFilter},{"EnergizeSubFilter", EnergizeSubFilter},{"SmoothSubFilter16", SmoothSubFilter16},{"EnergizeSubFilter16", EnergizeSubFilter16},{"EnergizeSubFilter32", EnergizeSubFilter32},{"SmoothSubFilter32", SmoothSubFilter32},{"HalfAddSubFilter", HalfAddSubFilter},{"HalfXorSubFilter", HalfXorSubFilter},{"StaticXorBlend", StaticXorBlend},{"PsycheSort", PsycheSort},{"XorScale", XorScale},{"ChannelMedianSubFilter", ChannelMedianSubFilter},{"GaussianStrobe", GaussianStrobe},{"StrobeSort", StrobeSort},{"GlitchSortStrobe", GlitchSortStrobe},{"Bitwise_XOR_Blend",Bitwise_XOR_Blend},{"Bitwise_XOR_Sort", Bitwise_XOR_Sort},{"Bitwise_OR_Blend", Bitwise_OR_Blend},{"Bitwise_AND_Blend", Bitwise_AND_Blend},{"BitwiseColorMatrix", BitwiseColorMatrix},{"PixelReverseXor", PixelReverseXor},{"PixelatedSubFilterSort", PixelatedSubFilterSort},{"SilverBlend", SilverBlend},{"RandomPixelOrderSort", RandomPixelOrderSort},{"ImageXorAlpha", ImageXorAlpha},{"ImageAverageXor", ImageAverageXor},{"PixelXorBlend", PixelXorBlend},{"SelfAlphaScale", SelfAlphaScale},{"SelfScaleAlpha", SelfScaleAlpha},{"RainbowXorBlend", RainbowXorBlend},{"FrameDifference", FrameDifference},{"SmallDiffference", SmallDiffference},{"FadeBlend", FadeBlend},{"FilteredDifferenceSubFilter", FilteredDifferenceSubFilter},{"ExpandSquareSubFilter", ExpandSquareSubFilter}, {"ExpandSquareBlendSubFilter", ExpandSquareBlendSubFilter},{"ExpandSquareVerticalSubFilter", ExpandSquareVerticalSubFilter},{"DarkImageMedianBlend", DarkImageMedianBlend},{"GammaDarken5", GammaDarken5},{"GammaDarken10", GammaDarken10},{"SelfAlphaScaleBlend", SelfAlphaScaleBlend},{"FadeBars", FadeBars},{"MirrorXorAlpha", MirrorXorAlpha},{"MirrorEnergizeSubFilter", MirrorEnergizeSubFilter},{"StrobeXor", StrobeXor},{"IntertwinedMirror", InterMirror}, {"BlurredMirror", BlurredMirror},{"ShadeRGB", ShadeRGB},{"InterRGB_SubFilter", InterRGB_SubFilter},{"InterSmoothSubFilter", InterSmoothSubFilter},{"InterRGB_Bars_XY", InterRGB_Bars_XY},{"InterRGB_Bars_X",InterRGB_Bars_X},{"InterRGB_Bars_Y", InterRGB_Bars_Y},{"StoredFramesAlphaBlend_SubFilter", StoredFramesAlphaBlend_SubFilter},{"BlendSubFilter", BlendSubFilter},{"BlendAlphaSubFilter", BlendAlphaSubFilter},{"ReverseFrameBlend", ReverseFrameBlend},{"ReverseFrameBlendSwitch", ReverseFrameBlendSwitch},{"DoubleRandomMirror", DoubleRandomMirror},{"Blend_AlphaSubFilter", Blend_AlphaSubFilter},{"RandomBlendFilter", RandomBlendFilter},{"DoubleRandomBlendFilter", DoubleRandomBlendFilter},{"FlipBlendW", FlipBlendW},{"FlipBlendWH", FlipBlendWH}, {"FlipBlendH", FlipBlendH}, {"FlipBlendAll", FlipBlendAll},{"FrameMedianBlendSubFilter", FrameMedianBlendSubFilter}, {"FrameBlurSubFilter", FrameBlurSubFilter},{"ImageBlendSubFilter", ImageBlendSubFilter},{"ImageBlendXorSubFilter", ImageBlendXorSubFilter},{"ImageCollectionSubFilter", ImageCollectionSubFilter},{"SelfScaleXorIncrease", SelfScaleXorIncrease},{"Blend_RedGreenBlue", Blend_RedGreenBlue},{"XorBlend_RedGreenBlue", XorBlend_RedGreenBlue},{"BlendIncrease_RedGreenBlue", BlendIncrease_RedGreenBlue},{"Blend_RedReenBlue_Dark", Blend_RedReenBlue_Dark},{"DarkModBlend", DarkModBlend}, {"PictureBuzz", PictureBuzz},{"IncDifference", IncDifference},{"IncDifferenceAlpha", IncDifferenceAlpha},{"MirrorMedianBlend", MirrorMedianBlend},{"SubFilterMedianBlend", SubFilterMedianBlend},{"DarkenBlend", DarkenBlend},{"DarkCollectionSubFilter", DarkCollectionSubFilter},{"ChannelSort_NoBlend_Descending", ChannelSort_NoBlend_Descending}, {"ChannelSort_NoBlend_Ascending", ChannelSort_NoBlend_Ascending},{"Headrush", Headrush},{"DarkSmooth_Filter", DarkSmooth_Filter},{"DarkSelfAlpha", DarkSelfAlpha},{"FlipMedian", FlipMedian},{"FlipMedianSubFilter", FlipMedianSubFilter},{"FlipMirror", FlipMirror},{"FlipMirrorAverage", FlipMirrorAverage},{"FlipMirrorSubFilter", FlipMirrorSubFilter},{"ShuffleMedian", ShuffleMedian},{"ShuffleRGB", ShuffleRGB},{"ParticleSnow", ParticleSnow},{"RandomPixels", RandomPixels},{"DarkRandomPixels", DarkRandomPixels},{"MedianBlurSubFilter", MedianBlurSubFilter},{"Bars", Bars},{"ShuffleAlpha", ShuffleAlpha},{"AlphaMorph", AlphaMorph},{"ShuffleSelf", ShuffleSelf}, + {"No Filter",NoFilter}, + {"Blend with Source",BlendWithSource}, {"Plugin",plugin}, {"Custom",custom}, {"Blend With Image #1",blendWithImage}, {"TriBlend with Image", triBlendWithImage}, {"Image Strobe",imageStrobe}}; + + FilterType *filter_array = filters; + FilterType filterByIndex(const int &num) { + return filter_array[num]; + } + FilterType filterByString(const std::string &num) { + return filter_array[ac::filter_map[num]]; + } +} + +cv::Mat blend_image, color_image; +bool blend_set = false; +bool colorkey_set = false; + +// return version info +std::string ac::getVersion() { + return version; +} +// be sure to call this on startup +void ac::fill_filter_map() { + for(int i = 0; i < ac::draw_max; ++i) + filter_map[draw_strings[i]] = i; +} + +void ac::DrawFilter(const std::string &name, const cv::Mat &frame, cv::Mat &outframe) { + outframe = frame.clone(); + ac::draw_func[filter_map[name]](outframe); +} + +void ac::DrawFilter(int index, const cv::Mat &frame, cv::Mat &outframe) { + outframe = frame.clone(); + ac::draw_func[index](outframe); +} +void ac::DrawFilter(int index, cv::Mat &frame) { + ac::draw_func[index](frame); + +} +void ac::DrawFilter(const std::string &name, cv::Mat &frame) { + ac::draw_func[filter_map[name]](frame); +} + +bool ac::CallFilter(int index, cv::Mat &frame) { + if(index >= 0 && index < ac::draw_max) { + filterByIndex(index).second(frame); + return true; + } + return false; +} + +bool ac::CallFilter(const std::string &name, cv::Mat &frame) { + int index = ac::filter_map[name]; + if(index >= 0 && index < ac::draw_max) { + filterByString(name).second(frame); + return true; + } + return false; +} + +void ac::swapColors(cv::Mat &frame, int y, int x) { + if(in_custom == true) return; + if(color_order == 0 && swapColor_r == 0 && swapColor_g == 0 && swapColor_b == 0) return; // if no swap needed return + if(set_color_map > 0 && color_map_set == false) { + return; + } + swapColors_(frame, y, x); +} + +void ac::swapColors_(cv::Mat &frame, int y, int x) { + cv::Vec3b &cur = frame.at(y,x); + cur[0] += swapColor_b; + cur[1] += swapColor_g; + cur[2] += swapColor_r; + cv::Vec3b temp;// temp + temp = cur;// temp = cur + // Default color order is BGR + // swap RGB orders + switch(color_order) { + case 1: // RGB + cur[0] = temp[2]; + cur[1] = temp[1]; + cur[2] = temp[0]; + break; + case 2:// GBR + cur[0] = temp[1]; + cur[1] = temp[0]; + break; + case 3:// BRG + cur[1] = temp[2]; + cur[2] = temp[1]; + break; + case 4: // GRB + cur[0] = temp[1]; + cur[1] = temp[2]; + cur[2] = temp[0]; + break; + } +} +// invert pixel in frame at x,y +void ac::invert(cv::Mat &frame, int y, int x) { + if(in_custom == true) return; + cv::Vec3b &cur = frame.at(y,x);// cur pixel + cur[0] = ~cur[0]; // bit manipulation sets opposite + cur[1] = ~cur[1]; + cur[2] = ~cur[2]; +} + +// proc position +void ac::procPos(int &direction, double &pos, double &pos_max, const double max_size, double iter) { + if(alpha_increase != 0) iter = alpha_increase; + switch(proc_mode) { + case 0: { // move in - increase move out movin - increase move out + // static int direction + // pos max + // if direction equals 1 + if(direction == 1) { + pos += iter; // pos plus equal 0.05 + if(pos > pos_max) { // if pos > pos max + pos = pos_max; // pos = pos_max + direction = 0;// direction equals 0 + pos_max += 0.5; // pos_max increases by 0.5 + } + } else if(direction == 0) {// direction equals 0 + pos -= iter;// pos -= 0.05 + if(pos <= 1.0) {// if pos <= 1.0 + if(pos_max > max_size) pos_max = 1.0;// if pos max at maxmium + // set to 1.0 + direction = 1;// set direction back to 1 + } + } + } + break; + case 1: { // flat fade in fade out + if(direction == 1) { + pos += iter; + if(pos > max_size) direction = 0; + + } else if(direction == 0) { + pos -= iter; + if(pos <= 1) direction = 1; + } + + } + break; + case 2: { + pos += iter; + if(pos >= pos_max) { + pos = 1.0; + } + } + break; + } + resetAlpha(direction, pos); +} + + +void ac::setProcMode(int value) { + proc_mode = value; +} + diff --git a/windows/Acid.Cam.Qt.Windows.Project/ac-filter10.cpp b/windows/Acid.Cam.Qt.Windows.Project/ac-filter10.cpp new file mode 100755 index 0000000..669ffd3 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/ac-filter10.cpp @@ -0,0 +1,1145 @@ +/* + * Software written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + +#include"ac.h" + +void ac::ExpandSquareSubFilter(cv::Mat &frame) { + if(subfilter == -1 || ac::draw_strings[subfilter] == "ExpandSquareSubFilter") + return; + + static int start_x = frame.cols/2; + static int stop_x = frame.cols/2; + static int speed = frame.cols/24; + cv::Mat frame_copy = frame.clone(); + cv::Mat output; + CallFilter(subfilter, frame_copy); + for(int z = 0; z < frame.rows; ++z) { + for(int i = start_x; i < stop_x; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel = frame_copy.at(z, i); + } + } + static int dir = 1; + if(dir == 1) { + start_x -= speed; + stop_x += speed; + if(start_x <= 0 || stop_x > frame.cols-1) { + dir = 0; + } + } else { + start_x += speed; + stop_x -= speed; + if(start_x >= (frame.cols/2)-1 || stop_x <= (frame.cols/2)-1) { + dir = 1; + } + } + AddInvert(frame); +} + +void ac::ExpandSquareBlendSubFilter(cv::Mat &frame) { + if(subfilter == -1 || ac::draw_strings[subfilter] == "ExpandSquareSubFilter") + return; + static int start_x = frame.cols/2; + static int stop_x = frame.cols/2; + static int speed = frame.cols/24; + static double alpha = 1.0, alpha_max = 4.0; + cv::Mat frame_copy = frame.clone(); + cv::Mat output; + CallFilter(subfilter, frame_copy); + for(int z = 0; z < frame.rows; ++z) { + for(int i = start_x; i < stop_x; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast(pixel[j]*alpha) ^ static_cast(pix[j]*alpha); + } + } + static int dir = 1; + if(dir == 1) { + start_x -= speed; + stop_x += speed; + if(start_x <= 0 || stop_x > frame.cols-1) { + dir = 0; + } + } else { + start_x += speed; + stop_x -= speed; + if(start_x >= (frame.cols/2)-1 || stop_x <= (frame.cols/2)-1) { + dir = 1; + } + } + static int direction = 1; + procPos(direction, alpha, alpha_max); + AddInvert(frame); +} + +void ac::ExpandSquareVerticalSubFilter(cv::Mat &frame) { + if(subfilter == -1 || ac::draw_strings[subfilter] == "ExpandSquareVerticalSubFilter") + return; + static int start_x = frame.rows/2; + static int stop_x = frame.rows/2; + static int speed = frame.rows/24; + cv::Mat frame_copy = frame.clone(); + cv::Mat output; + CallFilter(subfilter, frame_copy); + for(int z = 0; z < frame.cols; ++z) { + for(int i = start_x; i < stop_x; ++i) { + cv::Vec3b &pixel = frame.at(i, z); + pixel = frame_copy.at(i, z); + } + } + static int dir = 1; + if(dir == 1) { + start_x -= speed; + stop_x += speed; + if(start_x <= 0 || stop_x > frame.rows-1) { + dir = 0; + } + } else { + start_x += speed; + stop_x -= speed; + if(start_x >= (frame.rows/2)-1 || stop_x <= (frame.rows/2)-1) { + dir = 1; + } + } + AddInvert(frame); +} + +void ac::DarkImageMedianBlend(cv::Mat &frame) { + if(blend_set == true) { + SmoothImageAlphaBlend(frame); + cv::Mat frame_copy = frame.clone(); + setGamma(frame_copy,frame,5); + MedianBlend(frame); + } +} + +void ac::GammaDarken5(cv::Mat &frame) { + cv::Mat frame_copy = frame.clone(); + setGamma(frame_copy, frame, 5); +} + +void ac::GammaDarken10(cv::Mat &frame) { + cv::Mat frame_copy = frame.clone(); + setGamma(frame_copy, frame, 10); +} + +void ac::SelfAlphaScaleBlend(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 4.0; + static MatrixCollection<4> collection; + collection.shiftFrames(frame); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + unsigned int val = 0; + for(int j = 0; j < 3; ++j) { + val += static_cast(pixel[j]*alpha); + pixel[j] = pixel[j]^val; + } + + } + } + static int dir = 1; + procPos(dir,alpha,alpha_max); + AddInvert(frame); +} + +void ac::FadeBars(cv::Mat &frame) { + unsigned char ch[3] = {static_cast(rand()%255), static_cast(rand()%255), static_cast(rand()%255)}; + static double alpha = 1.0, alpha_max = 4.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast((pixel[j]^ch[j])*alpha); + ++ch[j]; + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 5.0, 0.1); + AddInvert(frame); +} + +void ac::MirrorXorAlpha(cv::Mat &frame) { + static double alpha[3] = {1.0, 3.0, 1.0}, alpha_max = 3.0; + static cv::Vec3b color_(rand()%255, rand()%255, rand()%255); + cv::Mat frame_copy = frame.clone(); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b values[3]; + values[0] = frame_copy.at(frame.rows-z-1, frame.cols-i-1); + values[1] = frame_copy.at(frame.rows-z-1, i); + values[2] = frame_copy.at(z, frame.cols-i-1); + for(int j = 0; j < 3; ++j) { + pixel[j] = cv::saturate_cast(static_cast((pixel[j]*alpha[j])) ^ static_cast((values[0][j]*alpha[j])) ^ static_cast((values[1][j]*alpha[j])) ^ static_cast((values[2][j]*alpha[j]))); + pixel[j] = pixel[j]^color_[j]; + } + } + } + AddInvert(frame); + static int dir[3] = {1, 0, 1}; + for(int j = 0; j < 3; ++j) { + if(dir[j] == 1) { + color_[j] += 5; + } else if(dir[j] == 0) { + color_[j] -= 5; + } + procPos(dir[j], alpha[j], alpha_max, 4.0, 0.1); + } +} + +void ac::MirrorEnergizeSubFilter(cv::Mat &frame) { + if(subfilter == -1 || ac::draw_strings[subfilter] == "MirrorEnergizeSubFilter") + return; + DarkenImage(frame, 6); + MirrorXorAlpha(frame); + EnergizeSubFilter(frame); + AddInvert(frame); +} + +void ac::StrobeXor(cv::Mat &frame) { + cv::Vec3b pix(rand()%255, rand()%255, rand()%255); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = pixel[j]^pix[j]; + } + } + AddInvert(frame); +} + +void ac::IntertwinedMirror(cv::Mat &frame) { + cv::Mat frame_copy = frame.clone(); + int lines = 0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b values[3]; + values[0] = frame_copy.at(frame.rows-z-1, frame.cols-i-1); + values[1] = frame_copy.at(frame.rows-z-1, i); + values[2] = frame_copy.at(z, frame.cols-i-1); + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j]^values[lines][j]; + } + } + ++lines; + if(lines > 2) + lines = 0; + } + AddInvert(frame); +} + +void ac::BlurredMirror(cv::Mat &frame) { + cv::Mat frame_copy; + cv::medianBlur(frame, frame_copy, 3); + DarkenImage(frame_copy, 2); + DarkenImage(frame, 2); + static double alpha = 1.0, alpha_max = 4.0; + int lines = 0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b values[3]; + values[0] = frame_copy.at(frame.rows-z-1, frame.cols-i-1); + values[1] = frame_copy.at(frame.rows-z-1, i); + values[2] = frame_copy.at(z, frame.cols-i-1); + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast((pixel[j] * alpha)) ^ static_cast((values[lines][j]*alpha)); + } + ++lines; + if(lines > 2) + lines = 0; + } + MedianBlend(frame); + static int dir = 1; + procPos(dir, alpha, alpha_max); + AddInvert(frame); +} + +void ac::ShadeRGB(cv::Mat &frame) { + cv::Mat frame_copy; + frame_copy = frame.clone(); + DarkenImage(frame_copy, 2); + DarkenImage(frame, 2); + static double alpha = 1.0, alpha_max = 4.0; + int lines = 0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b values[6]; + values[0] = frame_copy.at(frame.rows-z-1, frame.cols-i-1); + values[1] = frame_copy.at(frame.rows-z-1, i); + values[2] = frame_copy.at(z, frame.cols-i-1); + if(lines <= 2) + pixel[lines] += static_cast((pixel[lines] * alpha)) ^ static_cast((values[lines][lines]*alpha)); + } + ++lines; + if(lines > 2) + lines = 0; + + } + MedianBlend(frame); + static int dir = 1; + procPos(dir, alpha, alpha_max); + AddInvert(frame); +} + +void ac::InterRGB_SubFilter(cv::Mat &frame) { + if(subfilter == -1 || ac::draw_strings[subfilter] == "InterRGB_SubFilter") + return; + cv::Mat frame_copy = frame.clone(); + CallFilter(subfilter, frame_copy); + int index = 0; + static double alpha = 1.0, alpha_max = 4.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + switch(index) { + case 0: + pixel[0] = static_cast(pixel[0]*alpha); + pixel[1] = pix[1]; + pixel[2] = pix[2]; + break; + case 1: + pixel[0] = pix[0]; + pixel[1] = static_cast(pixel[1]*alpha); + pixel[2] = pix[2]; + break; + case 2: + pixel[0] = pix[0]; + pixel[1] = pix[1]; + pixel[2] = static_cast(pixel[2]*alpha); + break; + } + } + ++index; + if(index > 2) + index = 0; + } + static int dir = 1.0; + procPos(dir, alpha, alpha_max, 4.1, 0.05); + AddInvert(frame); +} + +void ac::InterSmoothSubFilter(cv::Mat &frame) { + if(subfilter == -1 || ac::draw_strings[subfilter] == "InterSmoothSubFilter") + return; + static MatrixCollection<8> collection; + cv::Mat frame_copy = frame.clone(); + CallFilter(subfilter, frame_copy); + int index = 0; + static double alpha = 1.0, alpha_max = 4.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + switch(index) { + case 0: + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast(pixel[j]*alpha)^pix[j]; + break; + case 1: + pixel = pix; + break; + } + } + ++index; + if(index > 1) + index = 0; + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 4.1, 0.05); + collection.shiftFrames(frame); + Smooth(frame, &collection); + AddInvert(frame); +} + +void ac::InterRGB_Bars_XY(cv::Mat &frame) { + unsigned int index = 0; + static double alpha = 1.0, alpha_max = 4.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j]^static_cast((i+z)*alpha); + } + pixel[index] = 255; + } + ++index; + if(index > 2) + index = 0; + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 4.1, 0.05); + AddInvert(frame); +} + +void ac::InterRGB_Bars_X(cv::Mat &frame) { + unsigned int index = 0; + static double alpha = 1.0, alpha_max = 4.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j]^static_cast(i*alpha); + } + pixel[index] = 255; + } + ++index; + if(index > 2) + index = 0; + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 4.1, 0.05); + AddInvert(frame); +} + +void ac::InterRGB_Bars_Y(cv::Mat &frame) { + unsigned int index = 0; + static double alpha = 1.0, alpha_max = 4.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j]^static_cast(z*alpha); + } + pixel[index] = 255; + } + ++index; + if(index > 2) + index = 0; + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 4.1, 0.05); + AddInvert(frame); +} + +void ac::StoredFramesAlphaBlend_SubFilter(cv::Mat &frame) { + if(subfilter == -1 || ac::draw_strings[subfilter] == "StoredFramesAlphaBlend_SubFilter") + return; + static MatrixCollection<8> collection; + static double alpha = 1.0, alpha_max = 4.0; + cv::Mat frame_copy = frame.clone(); + CallFilter(subfilter, frame_copy); + cv::Mat fcopy = frame.clone(); + AlphaBlend(fcopy, frame_copy, frame, alpha); + collection.shiftFrames(frame); + Smooth(frame, &collection); + static int dir = 1; + procPos(dir, alpha, alpha_max, 4.1, 0.05); + AddInvert(frame); +} + +void ac::BlendSubFilter(cv::Mat &frame) { + if(subfilter == -1 || ac::draw_strings[subfilter] == "BlendSubFilter") + return; + cv::Mat frame_copy = frame.clone(); + CallFilter(subfilter, frame_copy); + int index = 0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + switch(index) { + case 0: + break; + case 1: + pixel = pix; + break; + } + ++index; + if(index > 1) + index = 0; + } + } + AddInvert(frame); +} + +void ac::BlendAlphaSubFilter(cv::Mat &frame) { + if(subfilter == -1 || ac::draw_strings[subfilter] == "BlendAlphaSubFilter") + return; + cv::Mat frame_copy = frame.clone(); + CallFilter(subfilter, frame_copy); + static double alpha = 1.0, alpha_max = 4.0; + int index = 0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + switch(index) { + case 0: + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast(pixel[j]*alpha) ^ static_cast(pix[j]*alpha); + break; + case 1: + pixel = pix; + break; + } + ++index; + if(index > 1) + index = 0; + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 4.1, 0.05); + AddInvert(frame); +} + +// duplicate for right now +void ac::ReverseFrameBlend(cv::Mat &frame) { + cv::Mat frame_copy = frame.clone(); + Reverse(frame_copy); + MedianBlend(frame_copy); + int index = 0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + switch(index) { + case 0: + break; + case 1: + pixel = pix; + break; + } + ++index; + if(index > 1) + index = 0; + } + } + AddInvert(frame); +} + +void ac::ReverseFrameBlendSwitch(cv::Mat &frame) { + cv::Mat frame_copy = frame.clone(); + Reverse(frame_copy); + MedianBlend(frame_copy); + static bool onval = true; + int index = 0; + if(onval == false) + index = 1; + onval = (onval == true) ? false : true; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + switch(index) { + case 0: + break; + case 1: + pixel = pix; + break; + } + ++index; + if(index > 1) + index = 0; + } + } + AddInvert(frame); +} + +void ac::DoubleRandomMirror(cv::Mat &frame) { + cv::Mat frame_copy1 = frame.clone(); + RandomMirror(frame_copy1); + RandomMirror(frame); + int index = 0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy1.at(z, i); + switch(index) { + case 0: + break; + case 1: + pixel = pix; + break; + } + ++index; + if(index > 1) + index = 0; + } + } + AddInvert(frame); +} + +void ac::Blend_AlphaSubFilter(cv::Mat &frame) { + + if(subfilter == -1 || ac::draw_strings[subfilter] == "Blend_AlphaSubFilter") + return; + + cv::Mat frame_copy1 = frame.clone(); + RandomBlendFilter(frame); + CallFilter(subfilter, frame_copy1); + int index = 0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy1.at(z, i); + switch(index) { + case 0: + break; + case 1: + pixel = pix; + break; + } + ++index; + if(index > 1) + index = 0; + } + } + AddInvert(frame); +} + +void ac::RandomBlendFilter(cv::Mat &frame) { + static std::vector vzBlend { "Self AlphaBlend", "Self Scale", "Blend #3", "Negative Paradox", "ThoughtMode", "RandTriBlend", "Filter3","Rainbow Blend","Rand Blend","Pixel Scale","Pulse", "Combine Pixels", "Blend_Angle", "XorMultiBlend", "UpDown","LeftRight", "BlendedScanLines","XorSine", "FrameBlend", "FrameBlendRGB", "PrevFrameBlend", "HorizontalBlend", "VerticalBlend", "OppositeBlend", "DiagonalLines", "HorizontalLines", "BlendSwitch", "IncreaseBlendHorizontal", "BlendIncrease", "ColorRange", "VectorIncrease", "BlendThree", "HorizontalStripes", "Dual_SelfAlphaRainbow", "Dual_SelfAlphaBlur", "SurroundPixelXor", "WeakBlend", "AverageVertical", "RandomAlphaBlend", "RandomTwoFilterAlphaBlend", "AlphaBlendPosition", "BlendRowAlpha", "BlendRow", "BlendRowByVar", "BlendRowByDirection", "BlendAlphaXor", "SelfXorScale", "SelfAlphaRGB", "XorSelfAlphaImage", "AlphaBlendRandom", "ChannelSortAlphaBlend", "RandomXor", "RandomXorFlash", "SoftXor", "SelfXorBlend", "SelfXorDoubleFlash", "SelfOrDoubleFlash", "BlendRowCurvedSqrt", "CycleShiftRandomAlphaBlend", "TanAlphaGrid", "BlendInAndOut", "BlendScaleInAndOut", "AcidGlitch", "LiquidFilter", "MatrixXorAnd", "XorAlpha", "SelfXorAverage", "RandomXorBlend", "RGBVerticalXor", "RGBVerticalXorScale", "RGBHorizontalXor", "RGBHorizontalXorScale", "FadeInAndOut", "InitBlend", "LagBlend", "AddFilter", "RandBlend", "EveryOther","StaticXorBlend", "XorScale", "Bitwise_XOR_Blend", "Bitwise_OR_Blend", "Bitwise_AND_Blend", "PixelReverseXor", "SilverBlend", "PixelXorBlend", "SelfAlphaScale", "SelfScaleAlpha", "RainbowXorBlend", "FadeBlend", "SelfAlphaScaleBlend", "FadeBars", "ShadeRGB", "InterRGB_Bars_XY", "InterRGB_Bars_X", "InterRGB_Bars_Y", "ReverseFrameBlend", "ReverseFrameBlendSwitch"}; + + CallFilter(vzBlend[rand()%vzBlend.size()], frame); + AddInvert(frame); +} + +void ac::DoubleRandomBlendFilter(cv::Mat &frame) { + cv::Mat frame_copy1 = frame.clone(); + RandomBlendFilter(frame_copy1); + RandomBlendFilter(frame); + int index = 0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy1.at(z, i); + switch(index) { + case 0: + break; + case 1: + pixel = pix; + break; + } + ++index; + if(index > 1) + index = 0; + } + } + AddInvert(frame); +} + +void ac::FlipBlendWH(cv::Mat &frame) { + cv::Mat frame_copy1; + cv::flip(frame, frame_copy1, -1); + int index = 0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy1.at(z, i); + switch(index) { + case 0: + break; + case 1: + pixel = pix; + break; + } + ++index; + if(index > 1) + index = 0; + } + } + AddInvert(frame); +} + +void ac::FlipBlendH(cv::Mat &frame) { + cv::Mat frame_copy1; + cv::flip(frame, frame_copy1, 0); + int index = 0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy1.at(z, i); + switch(index) { + case 0: + break; + case 1: + pixel = pix; + break; + } + ++index; + if(index > 1) + index = 0; + } + } + AddInvert(frame); +} + +void ac::FlipBlendW(cv::Mat &frame) { + cv::Mat frame_copy1; + cv::flip(frame, frame_copy1, 1); + int index = 0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy1.at(z, i); + switch(index) { + case 0: + break; + case 1: + pixel = pix; + break; + } + ++index; + if(index > 1) + index = 0; + } + } + AddInvert(frame); +} + +void ac::FlipBlendAll(cv::Mat &frame) { + cv::Mat frame_copy[3]; + cv::flip(frame, frame_copy[0], 0); + cv::flip(frame, frame_copy[1], 1); + cv::flip(frame, frame_copy[2], -1); + int index = 0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix[3]; + pix[0] = frame_copy[0].at(z, i); + pix[1] = frame_copy[1].at(z, i); + pix[2] = frame_copy[2].at(z, i); + switch(index) { + case 0: + break; + case 1: + pixel = pix[0]; + break; + case 2: + pixel = pix[1]; + break; + case 3: + pixel = pix[2]; + break; + } + ++index; + if(index > 3) + index = 0; + } + } + AddInvert(frame); +} + +void ac::FrameMedianBlendSubFilter(cv::Mat &frame) { + if(subfilter == -1 || ac::draw_strings[subfilter] == "FrameMedianBlendSubFilter") + return; + cv::Mat frame_copy; + cv::flip(frame, frame_copy, 1); + CallFilter(subfilter, frame_copy); + MedianBlend(frame_copy); + int index = 0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + switch(index) { + case 0: + break; + case 1: + pixel = pix; + break; + } + ++index; + if(index > 1) + index = 0; + } + } + MedianBlur(frame); + RainbowXorBlend(frame); + AddInvert(frame); +} + +void ac::FrameBlurSubFilter(cv::Mat &frame) { + if(subfilter == -1 || ac::draw_strings[subfilter] == "FrameBlurSubFilter") + return; + static double alpha = 1.0, alpha_max = 4.0; + cv::Mat frame_copy1 = frame.clone(); + cv::Mat frame_copy2 = frame.clone(); + MedianBlur(frame_copy1); + CallFilter(subfilter, frame_copy1); + MedianBlur(frame_copy1); + MedianBlur(frame_copy2); + AlphaBlend(frame_copy1, frame_copy2, frame, alpha); + MedianBlur(frame); + static int dir = 1; + procPos(dir, alpha, alpha_max, 4.1, 0.05); + AddInvert(frame); +} + +void ac::ImageBlendSubFilter(cv::Mat &frame) { + if(subfilter == -1 || ac::draw_strings[subfilter] == "ImageBlendSubFilter") + return; + + if(blend_set == true) { + cv::Mat frame_copy1 = frame.clone(); + ExactImage(frame_copy1); + CallFilter(subfilter, frame_copy1); + + int index = 0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix1 = frame_copy1.at(z, i); + switch(index) { + case 0: + break; + case 1: + pixel = pix1; + break; + } + ++index; + if(index > 1) + index = 0; + } + } + } + +} + +void ac::ImageBlendXorSubFilter(cv::Mat &frame) { + if(blend_set == false || subfilter == -1 || ac::draw_strings[subfilter] == "ImageBlendXorSubFilter") + return; + static double alpha = 1.0, alpha_max = 4.0; + cv::Mat frame_copy1 = frame.clone(); + cv::Mat frame_copy2 = frame.clone(); + ExactImage(frame_copy1); + CallFilter(subfilter, frame_copy2); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix[3]; + pix[0] = frame_copy1.at(z, i); + pix[1] = frame_copy2.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j]^static_cast(pix[0][j]*alpha)^pix[1][j]; + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 4.1, 0.05); +} + +void ac::ImageCollectionSubFilter(cv::Mat &frame) { + if(blend_set == false || subfilter == -1 || ac::draw_strings[subfilter] == "ImageBlendXorSubFilter") + return; + static double alpha = 1.0, alpha_max = 4.0; + static int dir = 1; + cv::Mat frame_copy1 = frame.clone(); + cv::Mat frame_copy2 = frame.clone(); + ExactImage(frame_copy1); + AlphaBlend(frame_copy1, frame_copy2, frame, alpha); + CallFilter(subfilter, frame); + static MatrixCollection<8> collection; + collection.shiftFrames(frame); + Smooth(frame, &collection); + procPos(dir, alpha, alpha_max, 4.1, 0.05); + AddInvert(frame); +} + +void ac::SelfScaleXorIncrease(cv::Mat &frame) { + static double alpha = 1.0, increase_val = 0.05, limit_start = 1.0, limit = limit_start,min_start = 4.0, min = min_start, max = 10.0, rev_max = 1.0; + if(alpha_increase != 0) + increase_val = alpha_increase; + else + increase_val = 0.05; + + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast(pixel[j]*alpha)^static_cast(alpha*15); + } + } + static int dir = 1; + if(dir == 1) { + alpha += increase_val; + if(alpha >= limit) { + dir = 0; + limit += 1.0; + if(limit > max) { + limit = limit_start; + } + } + } else if(dir == 0) { + alpha -= increase_val; + if(alpha <= min) { + dir = 1; + min -= 1.0; + if(min < rev_max) { + min = min_start; + } + } + } + AddInvert(frame); +} + +void ac::Blend_RedGreenBlue(cv::Mat &frame) { + static cv::Scalar values(rand()%255, rand()%255, rand()%255); + static double speed_val = 5.0; + if(reset_alpha) { + for(int j = 0; j < 3; ++j) + values[j] = rand()%255; + } + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] += values[j]; + } + } + } + for(int j = 0; j < 3; ++j) { + if(values[j] > 255) { + values[j] = 0; + break; + } else { + values[j] += speed_val; + } + } + AddInvert(frame); +} + +void ac::XorBlend_RedGreenBlue(cv::Mat &frame) { + static cv::Scalar values(rand()%255, rand()%255, rand()%255); + static double speed_val = 2.5; + if(reset_alpha) { + for(int j = 0; j < 3; ++j) + values[j] = rand()%255; + } + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j]^static_cast(0.5*values[j]); + } + } + } + for(int j = 0; j < 3; ++j) { + if(values[j] > 255) { + values[j] = 0; + break; + } else { + values[j] += speed_val; + } + } + AddInvert(frame); + +} + +void ac::BlendIncrease_RedGreenBlue(cv::Mat &frame) { + static bool values_dir[3]; + static cv::Scalar values(rand()%255, rand()%255, rand()%255); + static double speed_val = 1.5; + if(reset_alpha) { + for(int j = 0; j < 3; ++j) + values[j] = rand()%255; + } + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] += static_cast(0.5 * values[j]); + } + } + } + for(int j = 0; j < 3; ++j) { + if(values[j] > 255) { + if(values_dir[j] == true) + values_dir[j] = false; + else + values_dir[j] = true; + break; + } else { + if(values_dir[j] == true) + values[j] += speed_val; + else + values[j] -= speed_val; + } + } + AddInvert(frame); +} + +void ac::Blend_RedReenBlue_Dark(cv::Mat &frame) { + static cv::Scalar values(rand()%255, rand()%255, rand()%255); + static double speed_val = 5.0; + if(reset_alpha) { + for(int j = 0; j < 3; ++j) + values[j] = rand()%255; + } + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + unsigned int val = static_cast(values[j]); + if(pixel[j] == 0) pixel[j] = 1; + pixel[j] = val%pixel[j]; + } + } + } + for(int j = 0; j < 3; ++j) { + if(values[j] > 255) { + values[j] = 0; + break; + } else { + values[j] += speed_val; + } + } + AddInvert(frame); +} + +void ac::DarkModBlend(cv::Mat &frame) { + static cv::Scalar values(rand()%255, rand()%255, rand()%255); + static double speed_val = 5.0; + if(reset_alpha) { + for(int j = 0; j < 3; ++j) + values[j] = rand()%255; + } + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + unsigned int val = static_cast(values[j]); + if(pixel[j] == 0) pixel[j] = 1; + pixel[j] = (val^pixel[j]); + if(pixel[j] == 0) pixel[j] = 1; + pixel[j] = val%pixel[j]; + } + } + } + for(int j = 0; j < 3; ++j) { + if(values[j] > 255) { + for(int q = 0; q < 3; ++q) + values[j] = rand()%255; + values[j] = 0; + break; + } else { + values[j] += speed_val; + } + } + AddInvert(frame); +} + +void ac::PictureBuzz(cv::Mat &frame) { + static cv::Scalar values(rand()%255, rand()%255, rand()%255); + cv::Vec3b l_values; + static double speed_val = 0.01; + if(reset_alpha) { + for(int j = 0; j < 3; ++j) + values[j] = rand()%255; + } + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + l_values[j] += pixel[j]; + unsigned int val = static_cast(values[j]); + if(l_values[j] == 0) l_values[j] = 1; + pixel[j] += val%l_values[j]; + } + } + } + for(int j = 0; j < 3; ++j) { + if(values[j] > 1024) { + values[j] = 0; + break; + } else { + values[j] += speed_val; + } + } + AddInvert(frame); +} + +void ac::IncDifference(cv::Mat &frame) { + static cv::Mat fcopy = frame.clone(); + static cv::Size size_var; + if(fcopy.size() != frame.size()) { + fcopy = frame.clone(); + } + for(unsigned int z = 0; z < frame.rows; ++z) { + for(unsigned int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b back = pixel; + cv::Vec3b &pix_cp = fcopy.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] += pix_cp[j]; + pix_cp[j] = 255-back[j]; + } + } + } + AddInvert(frame); +} + +void ac::IncDifferenceAlpha(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 4.0; + static cv::Mat fcopy = frame.clone(); + static cv::Size size_var; + int index = rand()%3; + if(fcopy.size() != frame.size()) { + fcopy = frame.clone(); + } + for(unsigned int z = 0; z < frame.rows; ++z) { + for(unsigned int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b back = pixel; + cv::Vec3b &pix_cp = fcopy.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = pix_cp[j]%(1+(pixel[j])); + } + pix_cp[index] = 255-(back[index]*alpha); + } + } + ++index; + if(index > 2) + index = 0; + AddInvert(frame); + static int dir = 1; + procPos(dir, alpha, alpha_max); +} diff --git a/windows/Acid.Cam.Qt.Windows.Project/ac-filter11.cpp b/windows/Acid.Cam.Qt.Windows.Project/ac-filter11.cpp new file mode 100755 index 0000000..e95d4bb --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/ac-filter11.cpp @@ -0,0 +1,384 @@ +/* + * Software written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + +#include "ac.h" + + +void ac::MirrorMedianBlend(cv::Mat &frame) { + static MatrixCollection<8> collection; + cv::Mat mirror = frame.clone(); + RandomMirror(mirror); + collection.shiftFrames(mirror); + Smooth(frame, &collection); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = collection.frames[7].at(z, i); + cv::Vec3b fpixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = (pixel[j]^fpixel[j])/2; + } + } + } + MedianBlend(frame); + AddInvert(frame); +} + +void ac::SubFilterMedianBlend(cv::Mat &frame) { + if(subfilter == -1 || ac::draw_strings[subfilter] == "SubFilterMedianBlend") + return; + static MatrixCollection<8> collection; + cv::Mat mirror = frame.clone(); + CallFilter(subfilter, mirror); + collection.shiftFrames(mirror); + Smooth(frame, &collection); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = collection.frames[7].at(z, i); + cv::Vec3b fpixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = (pixel[j]^fpixel[j])/2; + } + } + } + MedianBlend(frame); + AddInvert(frame); +} + +void ac::DarkenBlend(cv::Mat &frame) { + static MatrixCollection<8> collection; + static int dark = 2; + cv::Mat copyf = frame.clone(); + cv::Mat copyo = frame.clone(); + DarkenImage(copyf, dark); + ++dark; + if(dark > 8) + dark = 2; + + collection.shiftFrames(copyf); + Smooth(copyo, &collection); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b cpypix = copyo.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = ((pixel[j]^cpypix[j])/2); + } + } + } + AddInvert(frame); +} + +void ac::DarkCollectionSubFilter(cv::Mat &frame) { + if(subfilter == -1 || ac::draw_strings[subfilter] == "DarkCollectionSubFilter") + return; + static MatrixCollection<8> collection; + cv::Mat copyf = frame.clone(); + CallFilter(subfilter, copyf); + DarkenFilter(copyf); + collection.shiftFrames(copyf); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Scalar s; + cv::Vec3b &pixel = frame.at(z, i); + for(int q = 1; q < collection.size(); ++q) { + cv::Vec3b pix = collection.frames[q].at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j]^pix[j]; + s[j] += pixel[j]; + } + } + for(int j = 0; j < 3; ++j) { + s[j] = s[j]/collection.size(); + pixel[j] = static_cast(s[j]); + } + } + } + AddInvert(frame); +} + + +void ac::ChannelSort_NoBlend_Descending(cv::Mat &frame) { + std::vector v; + cv::split(frame, v); + cv::Mat channels[3]; + cv::Mat output; + cv::sort(v[0], channels[0],cv::SORT_DESCENDING); + cv::sort(v[1], channels[1],cv::SORT_DESCENDING); + cv::sort(v[2], channels[2],cv::SORT_DESCENDING); + cv::merge(channels, 3, frame); + AddInvert(frame); +} + +void ac::ChannelSort_NoBlend_Ascending(cv::Mat &frame) { + std::vector v; + cv::split(frame, v); + cv::Mat channels[3]; + cv::Mat output; + cv::sort(v[0], channels[0],cv::SORT_ASCENDING); + cv::sort(v[1], channels[1],cv::SORT_ASCENDING); + cv::sort(v[2], channels[2],cv::SORT_ASCENDING); + cv::merge(channels, 3, frame); + AddInvert(frame); +} + +void ac::Headrush(cv::Mat &frame) { + static MatrixCollection<16> collection; + static int index = 0; + cv::Mat copyf = frame.clone(); + if(index == 0) { + ChannelSort_NoBlend_Descending(copyf); + index = 1; + } else { + ChannelSort_NoBlend_Ascending(copyf); + index = 0; + } + collection.shiftFrames(copyf); + cv::Mat total = frame.clone(); + Smooth(frame, &collection); + AddInvert(frame); +} + +void ac::DarkSmooth_Filter(cv::Mat &frame) { + static int dark = 2; + static MatrixCollection<8> collection; + collection.shiftFrames(frame); + static int dir = 1; + if(dir == 1) { + ++dark; + if(dark > 12) + dir = 0; + } else if(dir == 0) { + --dark; + if(dark <= 2) + dir = 1; + } + + DarkSmooth(frame, &collection, dark); + AddInvert(frame); +} + +void ac::DarkSelfAlpha(cv::Mat &frame) { + cv::Mat copyf = frame.clone(); + double alpha = 1.0, alpha_max = 4.0; + DarkenImage(copyf, 2); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b darkpixel = copyf.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast(pixel[j]*alpha) ^ static_cast(darkpixel[j]*alpha); + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 4.1, 0.05); + AddInvert(frame); +} + +void ac::FlipMedian(cv::Mat &frame) { + static MatrixCollection<8> collection; + cv::Mat copyf = frame.clone(); + static int index = 0; + switch(index) { + case 0: + FlipBlendAll(copyf); + break; + case 1: + FlipBlendW(copyf); + break; + case 2: + FlipBlendH(copyf); + break; + case 3: + FlipBlendWH(copyf); + break; + } + ++index; + if(index > 3) index = 0; + collection.shiftFrames(copyf); + Smooth(frame, &collection); + MedianBlend(frame); + AddInvert(frame); +} + +void ac::FlipMedianSubFilter(cv::Mat &frame) { + if(subfilter == -1 || ac::draw_strings[subfilter] == "FlipMedianSubFilter") + return; + static MatrixCollection<8> collection; + cv::Mat copyf = frame.clone(); + CallFilter(subfilter, copyf); + FlipBlendAll(copyf); + collection.shiftFrames(copyf); + Smooth(frame, &collection); + MedianBlend(frame); + AddInvert(frame); +} + +void ac::FlipMirror(cv::Mat &frame) { + DarkenFilter(frame); + MirrorXorAll(frame); + FlipBlendAll(frame); + MedianBlend(frame); + AddInvert(frame); +} + +void ac::FlipMirrorAverage(cv::Mat &frame) { + static MatrixCollection<8> collection; + cv::Mat copyf = frame.clone(); + DarkenFilter(copyf); + MirrorXorAll(copyf); + collection.shiftFrames(copyf); + Smooth(frame, &collection); + FlipBlendAll(frame); + MedianBlend(frame); + AddInvert(frame); +} + +void ac::FlipMirrorSubFilter(cv::Mat &frame) { + if(subfilter == -1 || ac::draw_strings[subfilter] == "FlipMirrorSubFilter") + return; + static MatrixCollection<8> collection; + cv::Mat copyf = frame.clone(); + DarkenFilter(copyf); + CallFilter(subfilter, copyf); + collection.shiftFrames(copyf); + Smooth(frame, &collection); + FlipBlendAll(frame); + MedianBlend(frame); + AddInvert(frame); +} + +void ac::ShuffleMedian(cv::Mat &frame) { + static std::vector filter_array{"MedianBlend","MedianBlurXor", "MirrorMedianBlend", "FlipMedian"}; + static int index = 0; + Shuffle(index, frame, filter_array); + +} + +void ac::ShuffleRGB(cv::Mat &frame) { + std::vector filter_array { "RGB Shift", "RGB Sep", "SlideRGB", "GradientRGB", "FrameBlendRGB", "MoveRGB", "LineRGB", "PixelRGB", "RGBFlash", "MirrorRGB", "RGBStatic1", "RGBStatic2", "SelfAlphaRGB", "CycleShiftRGB", "CycleShiftRandomRGB", "CycleShiftRandomRGB_XorBlend", "RGBVerticalXor", "RGBVerticalXorScale", "RGBHorizontalXor", "RGBHorizontalXorScale", "RGBMirror", "RGBTrails", "RGBTrailsDark", "RGBTrailsAlpha", "RGBTrailsNegativeAlpha", "MovementRGBTrails", "RGBTrailsXor", "ShadeRGB"}; + static int index = 0; + Shuffle(index, frame, filter_array); +} + +void ac::RandomPixels(cv::Mat &frame) { + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] += rand()%255; + } + } +} + +void ac::DarkRandomPixels(cv::Mat &frame) { + int max = 1+(rand()%255); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] += rand()%max; + pixel[j] /= 4; + } + } + } +} + +void ac::MedianBlurSubFilter(cv::Mat &frame) { + if(subfilter == -1 || ac::draw_strings[subfilter] == "MedianBlurSubFilter") + return; + static MatrixCollection<8> collection; + static int counter = 1; + cv::Mat copyf = frame.clone(); + for(int i = 0; i < counter; ++i) { + MedianBlur(copyf); + } + CallFilter(subfilter, copyf); + collection.shiftFrames(copyf); + ++counter; + if(counter > 3) + counter = 1; + Smooth(frame, &collection); +} + +void ac::Bars(cv::Mat &frame) { + static int start = rand()%3; + for(int z = 0; z < frame.rows; ++z) { + int index = start; + for(int i = 0; i < frame.cols; i += 3) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[index] = 255; + ++index; + if(index > 2) + index = 0; + } + } + ++start; + if(start > 2) + start = rand()%3; +} + +void ac::ShuffleAlpha(cv::Mat &frame) { + static std::vector filter_array {"Self AlphaBlend","ScanAlphaSwitch", "Dual_SelfAlphaRainbow", "Dual_SelfAlphaBlur","BlendAlphaXor","SmoothTrailsSelfAlphaBlend","SelfAlphaRGB","XorAlpha","SelfAlphaScale", "SelfScaleAlpha","DarkSelfAlpha"}; + static int index = 0; + Shuffle(index, frame, filter_array); +} + +void ac::AlphaMorph(cv::Mat &frame) { + static MatrixCollection<8> collection; + cv::Mat copyf = frame.clone(); + ShuffleAlpha(copyf); + DarkenFilter(copyf); + collection.shiftFrames(copyf); + cv::Mat copyr = frame.clone(); + Smooth(copyf, &collection); + static double alpha = 1.0, alpha_max = 4.0; + static int dir = 1; + AlphaBlend(copyf, copyr, frame, alpha); + procPos(dir, alpha, alpha_max, 4.1, 0.01); +} + +void ac::ShuffleSelf(cv::Mat &frame) { + static std::vector filter_array {"Self AlphaBlend", "Self Scale", "ReinterpSelfScale", "Dual_SelfAlphaRainbow", "Dual_SelfAlphaBlur","SelfXorScale", "SelfAlphaRGB", "GradientXorSelfScale", "SelfXorBlend", "SelfXorDoubleFlash", "SelfOrDoubleFlash", "SelfXorAverage", "SelfAlphaScale", "SelfScaleAlpha", "SelfAlphaScaleBlend", "SelfScaleXorIncrease", "DarkSelfAlpha"}; + static int index = 0; + Shuffle(index, frame, filter_array); +} diff --git a/windows/Acid.Cam.Qt.Windows.Project/ac-filter2.cpp b/windows/Acid.Cam.Qt.Windows.Project/ac-filter2.cpp new file mode 100755 index 0000000..6951419 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/ac-filter2.cpp @@ -0,0 +1,907 @@ +/* + * Software written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + +#include "ac.h" + +// glitchSort +// takes cv::Mat reference +void ac::glitchSort(cv::Mat &frame) { + static double pos = 1.0f; // static pos set to 1.0 + int w = frame.cols;// frame width + int h = frame.rows;// frame height + static std::vector v;// static vector of int + v.reserve(w);// reserve at least w bytes + for(int z = 0; z < h; ++z) {// top to bottom + for(int i = 0; i < w; ++i) { // left to right + // grab current pixel value reference + cv::Vec3b &value = frame.at(z, i); + // temporary int variable + unsigned int vv = 0; + // pointer to unsigned char * of vv variable + unsigned char *cv = (unsigned char*)&vv; + // set RGB values + cv[0] = value[0]; + cv[1] = value[1]; + cv[2] = value[2]; + cv[3] = 0; + v.push_back(vv);// push back into vector + } + std::sort(v.begin(), v.end());// sort the row of pixels + for(int i = 0; i < w; ++i) {// left to right + // pointer to integer stored at index i + unsigned char *value = (unsigned char*)&v[i]; + // grab current pixel reference as cv::Vec3b + cv::Vec3b &pixel = frame.at(z, i); + // alphablend pixel with values from v at index i + pixel[0] = static_cast(pixel[0] + (pos)*value[0]); + pixel[1] = static_cast(pixel[1] + (pos)*value[1]); + pixel[2] = static_cast(pixel[2] + (pos)*value[2]); + // swap the colors + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); // if isNegative invert pixel + + } + v.erase(v.begin(), v.end());// erase pixel data + } + static double pos_max = 7.0f;// pos_max = 7.0 + static int direction = 1; + procPos(direction, pos, pos_max); +} + +// takes cv::Mat reference +void ac::pixelSort(cv::Mat &frame) { + int w = frame.cols;// frame width + int h = frame.rows;// frame height + static std::vector v;// static vector of int + v.reserve(w);// reserve w bytes + for(int z = 0; z < h; ++z) { // top to bottom + for(int i = 0; i < w; ++i) { // left to right + //int value = frame.at(z, i); + // grab pixel reference + cv::Vec3b &value = frame.at(z, i); + unsigned int vv = 0; + // unsigned char * of vv + unsigned char *cv = (unsigned char*)&vv; + // set RGB values + cv[0] = value[0]; + cv[1] = value[1]; + cv[2] = value[2]; + cv[3] = 0; + // push back into vector v + v.push_back(vv); + } + // sort vector v + std::sort(v.begin(), v.end()); + for(int i = 0; i < w; ++i) {// left to right + // unsigned char pointer of vector v at index i + unsigned char *value = (unsigned char*)&v[i]; + // get pixel reference + cv::Vec3b &pixel = frame.at(z, i); + // add to pixel without scaling + pixel[0] += value[0]; + pixel[1] += value[1]; + pixel[2] += value[2]; + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// invert pixel + } + v.erase(v.begin(), v.end()); + } +} +// preform a random filter +void ac::randomFilter(cv::Mat &frame) { + if(testSize(frame) == false) + return; + int num; + do { + num = rand()%(draw_max-6); + size_t pos = 0; + pos = ac::draw_strings[num].find("Feedback"); + if(pos != std::string::npos) + continue; + + } while((ac::draw_strings[num] == "Random Filter") || (ac::draw_strings[num] == "RandomIntertwine") || (ac::draw_strings[num] == "RandomFour" || (ac::draw_strings[num] == "BlendThree") || (ac::draw_strings[num] == "RandomTwo") || ac::draw_strings[num] == "SoftFeedbackResizeSubFilter64" || ac::draw_strings[num] == "SoftFeedbackResizeSubFilter" || ac::draw_strings[num] == "SoftFeedbackSubFilter")); + + draw_func[num](frame); +} + +void ac::randomFlash(cv::Mat &frame) { + int w = frame.cols;// frame width + int h = frame.rows;// frame height + static double pos = 1.0;// pos index + // a random red,green,blue value + int random_r = rand()%255, random_g = rand()%255, random_b = rand()%255; + // top to bottom + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) {// left to right + // get pixel reference + cv::Vec3b &pixel = frame.at(z, i); + // calculate RGB values + pixel[0] += static_cast(pos*random_r); + pixel[1] += static_cast(pos*random_g); + pixel[2] += static_cast(pos*random_b); + // swap colors + swapColors(frame, z, i); + // if isNegative true invert pixel + if(isNegative) invert(frame, z, i); + } + } + static double pos_max = 7.0f; + static int direction = 1; + procPos(direction, pos, pos_max); +} + + + +// alpha flame filters +// a collection of filters +void ac::alphaFlame(cv::Mat &frame) { + static double pos = 1.0f;// pos set to 1 + double count = 1.0f;// count set to 1 + static int i = 0, z = 0;// i,z variables + width = frame.cols;// frame width + height = frame.rows;// frame height + for(z = 0; z < frame.cols; ++z) { + for(i = 0; i < frame.rows; ++i) { + // grab pixel reference as cv::Vec3b + cv::Vec3b &buffer = frame.at(i, z); + // call change pixel function + changePixel(frame, z, i, buffer, pos, &count); + } + } + // static direction set to 1 + static int direction = 1; + if(direction == 1) {// if direction is equal to 1 + pos += 0.1f;// pos plus equal 0.1 + if(pos > 512) {// pos greater than 512 + pos = 512;// pos equal 512 + direction = 0;// direction equals 0 + } + } + else { + pos -= 0.1f; // pos minus equal 0.1 + if(pos < 1) {// if pos less than 1 + pos = 1;// pos equal 1 + direction = 1;// direction set back to 1 + } + } + resetAlpha(direction, pos); +} + +// Resize X variable +int AC_GetFX(int oldw,int x, int nw) { + float xp = (float)x * (float)oldw / (float)nw; + return (int)xp; +} +// Resize Y Variable +int AC_GetFZ(int oldh, int y, int nh) { + float yp = (float)y * (float)oldh / (float)nh; + return (int)yp; +} + + +// preform GaussianBlur +void ac::GaussianBlur(cv::Mat &frame) { + cv::Mat out; + cv::GaussianBlur(frame, out, cv::Size(5, 5), 0, 0); + frame = out.clone(); +} +// preform MedianBlur +void ac::MedianBlur(cv::Mat &frame) { + cv::Mat out; + cv::medianBlur(frame, out, 5); + frame = out.clone(); +} +// Increase / Decrease GaussianBlur +// takes cv::Mat reference +void ac::BlurDistortion(cv::Mat &frame) { + cv::Mat out;// output + static int index = 1, direction = 1; + cv::GaussianBlur(frame, out, cv::Size(index, index), 0, 0);// output + if(direction == 1) {// if direction equals 1 + if(index >= 51) direction = 0;// if greater than 51 set to zero go + // opposite direction + else index += 2;// increase + } else { + if(index <= 1) direction = 1;// go opposite direction + else index -= 2;// decrease + } + frame = out.clone();// frame equals out +} + +// Draw gradient diamonds that grow and shrink and blend with source image +// takes cv::Mat reference +void ac::DiamondPattern(cv::Mat &frame) { + static double pos = 1.0;// set pos to 1.0 + int w = frame.cols;// frame width + int h = frame.rows;// frame height + for(int z = 0; z < h; ++z) {// from top to bottom + for(int i = 0; i < w; ++i) {// from left to right + cv::Vec3b &buffer = frame.at(z, i);// get current pixel + // calculate the colors of the gradient diamonds + if((i%2) == 0) {// if i % 2 equals 0 + if((z%2) == 0) {// if z % 2 equals 0 + // set pixel component values + buffer[0] = static_cast(1-pos*buffer[0]); + buffer[2] = static_cast((i+z)*pos); + } else { + // set pixel coomponent values + buffer[0] = static_cast(pos*buffer[0]-z); + buffer[2] = static_cast((i-z)*pos); + } + } else { + if((z%2) == 0) {// if z % 2 equals 0 + // set pixel component values + buffer[0] = static_cast(pos*buffer[0]-i); + buffer[2] = static_cast((i-z)*pos); + } else { + // set pixel component values + buffer[0] = static_cast(pos*buffer[0]-z); + buffer[2] = static_cast((i+z)*pos); + } + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel + } + } + // static direction starts off with 1 + static double pos_max = 7.0f;// pos maximum + static int direction = 1; + procPos(direction, pos, pos_max); +} +// Mirror blend +// blend current pixel in loop with current pixel +// on opposite side of image (width-x), (height-y) +// then increase / decrease the pixel colors +// takes cv::Mat reference +void ac::MirrorBlend(cv::Mat &frame) { + static double pos = 1.0; // pos set to 1.0 + int w = frame.cols;// frame width + int h = frame.rows;// frame height + cv::Mat orig;// unaltered image + orig = frame.clone();// clone to orig + for(int z = 2; z < h-3; ++z) { // from top to bottom + for(int i = 2; i < w-3; ++i) {// from left to right + cv::Vec3b &buffer = frame.at(z, i); // get pixel at i,z + cv::Vec3b &pix1 = orig.at((h-z), (w-i));// get pixel at w-i, h-z + // set pixel rgb components + buffer[0] += static_cast(pix1[0]*pos); + buffer[1] += static_cast(pix1[1]*pos); + buffer[2] += static_cast(pix1[2]*pos); + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i); // invert if isNegative true + } + } + // static direction variable + static int direction = 1; + double inc_double = (alpha_increase != 0) ? alpha_increase : 0.1; + + static double pos_max = 2.0f; // position maximum + if(direction == 1) {// if direction is equal to 1 + pos += inc_double;// pos plus equal 0.1 + if(pos > pos_max) {// pos greater than pos max + pos = pos_max;// pos = pos max + direction = 0;// direction equals 0 + pos_max += 1.0f;// pos max pluse qual 1.0 + } + } else if(direction == 0) {// if direction equals zero + pos -= inc_double;// pos plus equal 0.1 + if(pos <= 1.0) {// pos less than 1.0 + if(pos_max > 2.0f) pos_max = 1.0f;// pos max greater than 2, pos_max set to 1 + direction = 1;// direction set back to 1 + } + } + resetAlpha(direction, pos); +} + +// Pulse color in and out +// takes cv::Mat reference +void ac::Pulse(cv::Mat &frame) { + static double pos = 1.0; // index + int w = frame.cols;// width variable + int h = frame.rows;// height variable + for(int z = 0; z < h; ++z) { // from top to bottom + for(int i = 0; i < w; ++i) { // from left to right + // current pixel reference cv::Vec3b + cv::Vec3b &buffer = frame.at(z, i); + // pixel rgb components plus equal multiplied by pos + buffer[0] += static_cast(buffer[0]*pos); + buffer[1] += static_cast(buffer[1]*pos); + buffer[2] += static_cast(buffer[2]*pos); + // swap colors + swapColors(frame, z, i); + // if negative variable true invert pixel + if(isNegative) invert(frame, z, i); + } + } + static int direction = 1; // current direction + static double pos_max = 3.0f; // maximum + if(direction == 1) { // direction equals 1 + pos += 0.1; // pos plus equal 0.1 + if(pos > pos_max) {// pos greater than pos max + pos = pos_max;// pos equals pox max + direction = 0; // direction is zero + pos_max += 1.0f; // pos max plus equal 1.0 + } + } else if(direction == 0) { // direction is 0 + pos -= 0.1; // pos minus equal 0.1 + if(pos <= 1.0) { // less thane equal 1 + // reset pos max + if(pos_max > 3.0f) pos_max = 1.0f; + direction = 1; // direction set to 1 + } + } + resetAlpha(direction, pos); +} + +// Sideways Mirror function +// takes reference cv::Mat (an image) +void ac::SidewaysMirror(cv::Mat &frame) { + static double pos = 1.0; + int w = frame.cols;// frame image width + int h = frame.rows;// frame image height + cv::Mat orig;// unaltered image matrix + orig = frame.clone();// clone frame to orig + for(int z = 2; z < h-3; ++z) {// loop from top to bottom + for(int i = 2; i < w-3; ++i) {// loop each row from left + // to right + // current pixel + cv::Vec3b &buffer = frame.at(z, i); + // h minus y, width minus x positioned pixel + cv::Vec3b &pix1 = orig.at((h-z), (w-i)); + // y and width minus x pixel + cv::Vec3b &pix2 = orig.at(z, (w-i)); + // current pixel compponents equal + // pix1[0] plus pix2[0] multiplied by kernel + buffer[0] += static_cast((pix1[0]+pix2[0])*pos); + // do the same for each component + buffer[1] += static_cast((pix1[1]+pix2[1])*pos); + buffer[2] += static_cast((pix1[2]+pix2[2])*pos); + // swap colors + swapColors(frame, z, i); + // if negative flag set invert frame + if(isNegative) invert(frame, z, i); + } + } + // max size + static double pos_max = 4.0f; + static int direction = 1; + procPos(direction, pos, pos_max); +} + +// Mirror function without blending +void ac::MirrorNoBlend(cv::Mat &frame) { + int w = frame.cols; // width of frame + int h = frame.rows; // height of frame + cv::Mat orig;// original image unaltered + orig = frame.clone(); // clone the frame to orig + for(int z = 2; z < h-3; ++z) { // loop through the height + for(int i = 2; i < w-3; ++i) {// go across each row + cv::Vec3b &buffer = frame.at(z, i);// current pixel + // opposite of current pixel + cv::Vec3b &pix1 = orig.at((h-z), (w-i)); + // opposite width, same height + cv::Vec3b &pix2 = orig.at(z, (w-i)); + // opposite height, same width + cv::Vec3b &pix3 = orig.at((h-z), i); + // current pixel components equal + // add each pixel value together + buffer[0] = (pix1[0]+pix2[0]+pix3[0]); + buffer[1] = (pix1[1]+pix2[1]+pix3[1]); + buffer[2] = (pix1[2]+pix2[2]+pix3[2]); + // swap RGB positions + swapColors(frame, z, i); + // if the negative switch is on, invert + if(isNegative) invert(frame, z, i); + } + } +} +// Sort the Fuzz +void ac::SortFuzz(cv::Mat &frame) { + int r = rand()%255; // random number betwen 0-254 + int w = frame.cols;// frame width + int h = frame.rows;// frame height + static std::vector v;// vector for row of bytes info + v.reserve(w);// reserve at least width bytes + for(int z = 0; z < h; ++z) { // loop: top to bottom + for(int i = 0; i < w; ++i) { // loop: left ro right + cv::Vec3b &value = frame.at(z, i); // current pixel + unsigned int vv = 0; // integer + unsigned char *cv = (unsigned char*)&vv; // pointer to unsigned char* + // set each byte + cv[0] = value[0]; + cv[1] = value[1]; + cv[2] = value[2]; + cv[3] = 0; + v.push_back(vv); // push back + } + std::sort(v.begin(), v.end());// sort greater + for(int i = 0; i < w; ++i) { // left to right + unsigned char *value = (unsigned char*)&v[i]; + cv::Vec3b &pixel = frame.at(z, i);// pixel at i,z + // pixel values plus equal value plus r + pixel[0] += static_cast(value[0]+r); + pixel[1] += static_cast(value[1]+r); + pixel[2] += static_cast(value[2]+r); + // swap colors + swapColors(frame, z, i); + // if negative variable set invert pixel + if(isNegative) invert(frame, z, i); + + } + v.erase(v.begin(), v.end()); // erase row + // repeat + } +} +// Fuzz filter +// takes cv::Mat reference +void ac::Fuzz(cv::Mat &frame) { + int w = frame.cols;// width of frame + int h = frame.rows;// height of frame + static int amount = 5; // num pixel distortion + for(int z = 0; z < h; ++z) {// loop top to bottom + for(int i = 0; i < w; ++i) { // loop from left ro gith + if((rand()%amount)==1) {// if random is true + cv::Vec3b &pixel = frame.at(z, i);// grab pixel + pixel[0] += rand()%255;// add random numbers + pixel[1] += rand()%255; + pixel[2] += rand()%255; + } + // swap colors + swapColors(frame, z, i); + // if negative invert pixel + if(isNegative) invert(frame, z, i); + } + } + // direction equals 1 to start + static int direction = 1; + if(direction == 1) {// if direction equals 1 + ++amount; // increase amount + if(amount >= 10) direction = 0; // greater than ten lower to zero + } else { + --amount;// decrease amount + if(amount <= 5) direction = 1;// less than five direction equals 1 + } +} + +// Double vision +// takes cv::Mat by refrence +void ac::DoubleVision(cv::Mat &frame) { + static double pos = 1.0; // index + int w = frame.cols;// frame width + int h = frame.rows;// frame height + cv::Mat orig = frame.clone(); // clone frame to orig + for(int z = 3; z < h-3; ++z) {// top to bottom + for(int i = 3; i < w-3; ++i) { // left to right + // current pixel + cv::Vec3b &buffer = frame.at(z, i); + cv::Vec3b &g = orig.at((h-z), i); // pixel at h-y, x + cv::Vec3b &b = orig.at(z, (w-i)); // pixel at y, w-x + // this is what gives the diamond image + if((i%2) == 0) {// if modulus i by two returns zero + if((z%2) == 0) {// modulus z by two returns zero + buffer[2] += static_cast((i+z)*pos);// buffer[2] plus equals (i plus z) multiplied by pos + } else { + buffer[2] += static_cast((i-z)*pos); // buffer[2] plus equals (i minus z) mulitplied by pos + } + } else { + if((z%2) == 0) {// modulus z by two equals zero + buffer[2] += static_cast((i-z)*pos); // buffer[2] plus equals (i minus z) multiplied by pos + } else { + buffer[2] += static_cast((i+z)*pos); // buffer[2] plus equals (i plus z) multiplied by pos + } + } + // this is what adds the rgb from other positions + buffer[0] += g[0]; + buffer[1] += b[1]; + // swap colors + swapColors(frame, z, i); + // if negative variable set invert pixel + if(isNegative) invert(frame, z, i); + } + } + // static int direction + // pos max + static double pos_max = 7.0f; + static int direction = 1; + procPos(direction, pos, pos_max); +} +// RGB Shift +// takes cv::Mat reference +void ac::RGBShift(cv::Mat &frame) { + int w = frame.cols; // frame width + int h = frame.rows;// frame height + cv::Mat orig = frame.clone();// clone frame to orig + static int shift = 0;// shift equals 0 + for(int z = 3; z < h-3; ++z) {// top to bottom + for(int i = 3; i < w-3; ++i) {// left to right + // grab pixel values + cv::Vec3b &buffer = frame.at(z, i); + cv::Vec3b &g = orig.at((h-z), i); + cv::Vec3b &b = orig.at(z, (w-i)); + cv::Vec3b &r = orig.at((h-z), (w-i)); + // switch shift, each state preforms addition on different + // pixel component values + switch(shift) { + case 0: + buffer[0] += r[0]; + buffer[1] += g[1]; + buffer[2] += b[2]; + case 1: + buffer[0] += g[0]; + buffer[1] += b[1]; + buffer[2] += r[2]; + break; + case 2: + buffer[0] += b[0]; + buffer[1] += r[1]; + buffer[2] += g[2]; + break; + } + swapColors(frame, z, i);// swap the colors + if(isNegative) invert(frame, z, i);// invert current pixel + } + } + ++shift;// increase shift + if(shift > 2) shift = 0;// shift greater than two reset shift +} +// RGB Seperation +// takes cv::Mat +void ac::RGBSep(cv::Mat &frame) { + int w = frame.cols;// frame width + int h = frame.rows;// frame height + cv::Mat orig = frame.clone();// orig is clone of frame + for(int z = 3; z < h-3; ++z) {// top to bottom + for(int i = 3; i < w-3; ++i) {// left to right + // grab pixel values + cv::Vec3b &buffer = frame.at(z, i); + cv::Vec3b &g = orig.at((h-z), i); + cv::Vec3b &b = orig.at(z, (w-i)); + // set pixel values + buffer[0] += g[0]; + buffer[2] += b[2]; + swapColors(frame, z, i); // swap colors + if(isNegative) invert(frame, z, i); // invert pixel + } + } +} +// Gradient Rainbow +// takes cv::Mat reference +void ac::GradientRainbow(cv::Mat &frame) { + int w = frame.cols;// frame width + int h = frame.rows;// frame height + // start color double + double start_color = (1+(rand()%255))* 0.5; + + for(int z = 0; z < h; ++z) { // top to bottom + for(int i = 0; i < w; ++i) {// left to right + // reference to current pixel + cv::Vec3b &pixel = frame.at(z, i); + // color RGB variables + int color_R = static_cast(start_color * 4), color_G = static_cast(start_color * 6), color_B = static_cast(start_color * 8); + // add to pixel color + pixel[0] += static_cast(color_R); + pixel[1] += static_cast(color_G); + pixel[2] += static_cast(color_B); + // swap colors + swapColors(frame, z, i); + // if isNegative true invert pixel + if(isNegative) invert(frame, z, i); + } + start_color += 0.1;// increase start_color + } +} +// Flash +// takes cv::Mat +void ac::GradientRainbowFlash(cv::Mat &frame) { + int w = frame.cols;// frame width + int h = frame.rows;// frame height + static double pos = 0.1; + static int shift = 0; + // start color double + double start_color = (1+(rand()%255)) * pos; + for(int z = 0; z < h; ++z) { // top to bottom + for(int i = 0; i < w; ++i) {// left to right + // reference to current pixel + cv::Vec3b &pixel = frame.at(z, i); + // color RGB variables + int color_R = static_cast(start_color * 4), color_G = static_cast(start_color * 6), color_B = static_cast(start_color * 8); + // add to pixel colors + pixel[2] += static_cast(color_R); + pixel[1] += static_cast(color_G); + pixel[0] += static_cast(color_B); + // flash + if(shift == 0) { + pixel[2] = ~pixel[2]; + pixel[1] = ~pixel[1]; + pixel[0] = ~pixel[0]; + } + + // swap colors + swapColors(frame, z, i); + // if isNegative true invert pixel + if(isNegative) invert(frame, z, i); + } + start_color += 0.050;// increase start_color + } + shift = !shift; + // static int direction + static int direction = 1; + // pos max + // if direction equals 1 + if(direction == 1) { + pos += 0.05; // pos plus equal 0.05 + if(pos > 1.0) { // if pos > pos max + pos = 1.0; + direction = 0;// direction equals 0 + } + } else if(direction == 0) {// direction equals 1 + pos -= 0.05;// pos -= 0.05 + if(pos <= 0.1) {// if pos <= 1.0 + // set to 1.0 + direction = 1;// set direction back to 1 + pos = 0.1; + } + } + resetAlpha(direction, pos); +} +// Reverse Frame +// takes cv::Mat reference +void ac::Reverse(cv::Mat &frame) { + cv::Mat output;//output matrix + cv::flip(frame, output, 1); // flip image + frame = output.clone(); // set frame to output +} +// Scanlines - Draws scanlines like a CRT. +void ac::Scanlines(cv::Mat &frame) { + int w = frame.cols;// width + int h = frame.rows;// height + for(int z = 0; z < h; z += 2) {// top to bottom step by 2 + for(int i = 0; i < w; ++i) {// left to right + cv::Vec3b &pix = frame.at(z, i);// current pixel + pix[0] = pix[1] = pix[2] = 0;// set to zero + } + } +} +// Random Pixels +void ac::TVStatic(cv::Mat &frame) { + int w = frame.cols;// frame width + int h = frame.rows;// frame height + static int dir = 0; + for(int z = dir; z < h; z += 2) {// top to bottom step by 2 pixels + for(int i = 0; i < w; ++i) {// left to right + cv::Vec3b &pix = frame.at(z, i);// current pixel + if(rand()%2>0) { + pix[0] = pix[1] = pix[2] = 0; + } else { + pix[0] = pix[1] = pix[2] = 255; + } + } + } + ++dir; + if(dir >= 2) dir = 0; +} +// Mirror Average +// takes cv::Mat reference +void ac::MirrorAverage(cv::Mat &frame) { + int w = frame.cols;// frame width + int h = frame.rows;// frame height + cv::Mat orig = frame.clone(); // clone original frame (make a copy) + static double pos = 1.0f; // current index + for(int z = 1; z < h-1; ++z) { // top to bottom + for(int i = 1; i < w-1; ++i) {// left to right + // refernce to current pixel located at i,z + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b mir_pix[3]; // array of Vec3b variables + mir_pix[0] = orig.at((h-z), (w-i)); // pixel at w-i, h-z + mir_pix[1] = orig.at((h-z), i); // pixel at i, h-z + mir_pix[2] = orig.at(z,(w-i)); // pixel at w-i, z + // take each component from mir_pix and find the average + // with the same index from each variable in the mir_pix array + // then multiply it by the position index (pos) then add it + // to current pixel + pixel[0] += static_cast(((mir_pix[0][0]+mir_pix[1][0]+mir_pix[2][0])/3)*pos); + pixel[1] += static_cast(((mir_pix[0][1]+mir_pix[1][1]+mir_pix[2][1])/3)*pos); + pixel[2] += static_cast(((mir_pix[0][2]+mir_pix[1][2]+mir_pix[2][2])/3)*pos); + + // swap colors + swapColors(frame, z, i); + // if isNegative true invert pixel + if(isNegative) invert(frame, z, i); + } + } + // move up and down the color scale + + static double pos_max = 7.0; + static int direction = 1; + procPos(direction, pos, pos_max); +} +// Mirror Average Mix +// Takes cv::Mat matrix +void ac::MirrorAverageMix(cv::Mat &frame) { + int w = frame.cols;// frame width + int h = frame.rows;// frame height + cv::Mat orig = frame.clone(); // clone original frame + static double pos = 1.0; // position index floating point + for(int z = 1; z < h-1; ++z) { // loop from top to bottom + for(int i = 1; i < w-1; ++i) { // loop from left to right + cv::Vec3b &pixel = frame.at(z, i); // current pixel at i,z + cv::Vec3b mir_pix[3]; // array of 3 cv::Vec3b vectors + mir_pix[0] = orig.at((h-z), (w-i)); // pixel at w-i, h-z + mir_pix[1] = orig.at((h-z), i); // pixel at i, h-z + mir_pix[2] = orig.at(z,(w-i)); // pixel at w-i, z + // take each pixel and average together mulitply by pos + // and add its value to different components in + // pixel reference vector + pixel[0] += static_cast(((mir_pix[0][0]+mir_pix[0][1]+mir_pix[0][2])/3)*pos); + pixel[1] += static_cast(((mir_pix[1][0]+mir_pix[1][1]+mir_pix[1][2])/3)*pos); + pixel[2] += static_cast(((mir_pix[2][0]+mir_pix[2][1]+mir_pix[2][2])/3)*pos); + // swap colors + swapColors(frame, z, i); + // if isNegative true invert pixel + if(isNegative) invert(frame, z, i); + } + } + // pos max + static double pos_max = 7.0; + static int direction = 1; + procPos(direction, pos, pos_max); +} +// Mean takes cv::Mat reference +void ac::Mean(cv::Mat &frame) { + static double pos = 1.0; // position index floating point + int w = frame.cols;// frame width + int h = frame.rows;// frame height + cv::Scalar s = cv::mean(frame); + for(int z = 0; z < h; ++z) { // from top to bottom + for(int i = 0; i < w; ++i) {// from left to right + cv::Vec3b &pixel = frame.at(z, i); // pixel at (i,z) + // add to pixel values + pixel[0] += static_cast(pos*s[0]); + pixel[1] += static_cast(pos*s[1]); + pixel[2] += static_cast(pos*s[2]); + swapColors(frame, z, i); + // if isNegative true invert pixel + if(isNegative) invert(frame, z, i); + } + } + // position movement + static double pos_max = 7.0; + static int direction = 1; + procPos(direction, pos, pos_max); +} + +// Laplacian - takes cv::Mat reference +void ac::Laplacian(cv::Mat &frame) { + cv::Mat out; + cv::Laplacian(frame, out, CV_8U); + frame = out.clone(); + AddInvert(frame); +} + +// XOR - takes cv::Mat reference +void ac::Bitwise_XOR(cv::Mat &frame) { + static cv::Mat initial;// set initial frame + if(reset_filter == true || frames_released == true || initial.empty() || (initial.size() != frame.size())) { + initial = frame.clone(); // did frame resize? if so set the new frame value + reset_filter = false; + } + cv::Mat start = frame.clone(); // clone frame (make a copy) + cv::Mat output = frame.clone();// output variable + cv::bitwise_xor(frame, initial, output); // OpenCV function bitwise_and + initial = start.clone();// set initial to start + frame = output.clone(); // set frame to output + AddInvert(frame); +} + +// And takes cv::Mat reference +void ac::Bitwise_AND(cv::Mat &frame) { + static cv::Mat initial;// set initial frame + if(reset_filter == true || frames_released == true || initial.empty() || (initial.size() != frame.size())) { + initial = frame.clone(); // did frame resize? if so set the new frame value + reset_filter = false; + } + cv::Mat start = frame.clone(); // clone frame (make a copy) + cv::Mat output = frame.clone();// output variable + cv::bitwise_and(frame, initial, output); // OpenCV function bitwise_and + initial = start.clone();// set initial to start + frame = output.clone(); // set frame to output + AddInvert(frame); +} +// takes cv::Mat reference +void ac::Bitwise_OR(cv::Mat &frame) { + static cv::Mat initial;// set initial frame + if(reset_filter == true || frames_released == true || initial.empty() || (initial.size() != frame.size())) { + initial = frame.clone(); // did frame resize? if so set the new frame value + reset_filter = false; + } + cv::Mat start = frame.clone(); // clone frame (make a copy) + cv::Mat output = frame.clone();// output variable + cv::bitwise_or(frame, initial, output); // OpenCV function bitwise_and + initial = start.clone();// set initial to start + frame = output.clone(); // set frame to output + AddInvert(frame); +} +// takes cv::Mat reference +// Equalize image +void ac::Equalize(cv::Mat &frame) { + cv::Mat output[3]; // array of cv::Mat + std::vector v; // vector to hold cv::Mat values + cv::split(frame, v);// split b,g,r values + cv::equalizeHist(v[0], output[0]);// equalize + cv::equalizeHist(v[1], output[1]); + cv::equalizeHist(v[2], output[2]); + cv::merge(output,3,frame);// merge back to create final output + AddInvert(frame); +} + +// Channel sort - takes cv::Mat reference +void ac::ChannelSort(cv::Mat &frame) { + static double pos = 1.0; // color scale + std::vector v; // to hold the Matrix for split + cv::split(frame, v);// split the channels into seperate matrices + cv::Mat channels[3]; // output channels + cv::Mat output; // for merge + cv::sort(v[0], channels[0],cv::SORT_ASCENDING); // sort each matrix + cv::sort(v[1], channels[1],cv::SORT_ASCENDING); + cv::sort(v[2], channels[2],cv::SORT_ASCENDING); + cv::merge(channels, 3, output); // combine the matrices + for(int z = 0; z < frame.rows; ++z) { // top to bottom + for(int i = 0; i < frame.cols; ++i) { // left to right + cv::Vec3b &pixel = frame.at(z, i); // get reference to pixel + cv::Vec3b &ch_pixel = output.at(z, i); // get reference to pixel + // add and multiply components to channels + pixel[0] += static_cast(ch_pixel[0]*pos); + pixel[1] += static_cast(ch_pixel[1]*pos); + pixel[2] += static_cast(ch_pixel[2]*pos); + // swap colors + swapColors(frame, z, i); + // if isNegative true invert pixel + if(isNegative) invert(frame, z, i); + } + } + // pos max + static double pos_max = 7.0; + static int direction = 1; + procPos(direction, pos, pos_max); +} + diff --git a/windows/Acid.Cam.Qt.Windows.Project/ac-filter3.cpp b/windows/Acid.Cam.Qt.Windows.Project/ac-filter3.cpp new file mode 100755 index 0000000..15499da --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/ac-filter3.cpp @@ -0,0 +1,1882 @@ +/* + * Software written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + +#include "ac.h" + +// takes cv::Mat reference +void ac::Reverse_XOR(cv::Mat &frame) { + static cv::Mat initial = frame; + if(initial.cols != frame.cols || initial.rows != frame.rows) { + initial = frame; + } + static double pos = 1.0; + cv::Mat start = frame.clone(); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b &in_pixel = initial.at(z, i); + pixel[0] ^= in_pixel[2]; + pixel[1] ^= in_pixel[1]; + pixel[2] ^= in_pixel[0]; + // swap colors + swapColors(frame, z, i); + // if isNegative true invert pixel + if(isNegative) invert(frame, z, i); + } + } + initial = start; + static double pos_max = 7.0; + static int direction = 1; + procPos(direction, pos, pos_max); +} + +// takes cv::Mat reference +void ac::CombinePixels(cv::Mat &frame) { + static double pos = 1.0, pos_max = 7.0; + static int direction = 1; + cv::Scalar s(1.0, 100.0, 200.0); + for(int z = 2; z < frame.rows-2; ++z) { + for(int i = 2; i < frame.cols-2; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pixels[4]; + pixels[0] = frame.at(z, i+1); + pixels[1] = frame.at(z+1, i); + pixels[2] = frame.at(z+1, i+1); + pixel[0] ^= (pixels[0][0]+pixels[1][0]+pixels[2][0]); + pixel[1] ^= (pixels[0][1]+pixels[1][1]+pixels[2][1]); + pixel[2] ^= (pixels[0][2]+pixels[1][2]+pixels[2][2]); + pixel[0] *= static_cast(pos); + pixel[1] *= static_cast(pos); + pixel[2] *= static_cast(pos); + // swap colors + swapColors(frame, z, i); + // if isNegative true invert pixel + if(isNegative) invert(frame, z, i); + } + } + procPos(direction, pos, pos_max); +} +// Canny takes cv::Mat reference +void ac::Canny(cv::Mat &frame) { + cv::Mat out; + static double x = 100, y = 100; + cv::Canny(frame, out, x, y); + cv::Mat converted; + cv::cvtColor(out, converted, cv::COLOR_GRAY2BGR); + frame = converted.clone(); + AddInvert(frame); +} + +// Flip takes cv::Mat reference +// flip the iamge every other frame +void ac::FlipTrip(cv::Mat &frame) { + static int _flip = 0;// index variable + cv::Mat output;// output matrix + switch(_flip){ + case 0: + cv::flip(frame, output, 1); // flip matrix + frame = output.clone();// frame equals output + _flip++;// increase index + break; + case 1: + // do nothing + _flip = 0; // index equals zero + break; + } +} + +// Loop tiled boxes +void ac::Boxes(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static int pixel_size = 8; // size of each tile + for(int z = 0; z < h; z += pixel_size) { // from top to bottom + for(int i = 0; i < w; i += pixel_size) { // from left to right + unsigned char rgb[3]; // 3 bytes + rgb[0] = rand()%255; // set to random number + rgb[1] = rand()%255; + rgb[2] = rand()%255; + for(int y = z; y < static_cast(z+pixel_size); ++y) { // tile top to bottom + for(int x = i; x < static_cast(i+pixel_size); ++x) {// tile left to right + if(x < w && y < h) { // is x,y on screen? + // reference to pixel + cv::Vec3b &pixel = frame.at(y, x); + pixel[0] += rgb[0]; // add each component + pixel[1] += rgb[1]; + pixel[2] += rgb[2]; + } + } + } + } + } + static int direction = 1; // current direction, grow versus shrink + if(direction == 1) { + ++pixel_size;// grow by 1 + // if greater than 1/6 of frame size set to zero + if(static_cast(pixel_size) > (w/6)) direction = 0; + } else if(direction == 0) {// direction equals zero shrink + --pixel_size;// shrink + if(pixel_size < 24) direction = 1; + } +} +// Loop tiled box fade +void ac::BoxesFade(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static cv::Vec3b color(rand()%255, rand()%255, rand()%255); // random color + static int sw = 0; // with component to increase + static int pixel_size = 8; // size of each tile + for(int z = 0; z < h; z += pixel_size) { // from top to bottom + ++sw;// increase + if(sw > 2) sw = 0;//greater than 2 reset + for(int i = 0; i < w; i += pixel_size) { // from left to right + for(int y = z; y < z+pixel_size; ++y) { // tile top to bottom + for(int x = i; x < i+pixel_size; ++x) {// tile left to right + if(x < w && y < h) { // is x,y on screen? + // reference to pixel + switch(sw) { + case 0: // increase B + ++color[0]; + break; + case 1:// increase G + ++color[1]; + break; + case 2:// increase R + ++color[2]; + break; + } + if(color[0] >= 254) color[0] = rand()%255; // reset if over + if(color[1] >= 254) color[1] = rand()%255; + if(color[2] >= 254) color[2] = rand()%255; + + cv::Vec3b &pixel = frame.at(y, x); + pixel[0] += color[0]; // add each component + pixel[1] += color[1]; + pixel[2] += color[2]; + } + } + } + } + } + static int direction = 1; // current direction, grow versus shrink + if(direction == 1) { + ++pixel_size;// grow by 1 + // if greater than 1/6 of frame size set to zero + if(pixel_size > (w/6)) direction = 0; + } else if(direction == 0) {// direction equals zero shrink + --pixel_size;// shrink + if(pixel_size < 24) direction = 1; + } +} + + +void ac::FlashBlack(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static cv::Vec3b black(0, 0, 0); + static bool flash = false; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + if(flash == true) + pixel = black; + + } + } + flash = !flash; +} + +void ac::SlideRGB(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static int offset_x = 0; + int color[2] = { rand()%3, rand()%3 }; + for(int z = 3; z < h-3; ++z) { + for(int i = 3; i < w-3; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + if(offset_x+i < (w-1)) { + cv::Vec3b off_pix = frame.at(z, offset_x+i); + pixel[color[0]] += static_cast(off_pix[color[0]]); + cv::Vec3b off_red = frame.at(z, (w-(offset_x+i))); + pixel[color[1]] += static_cast(off_red[color[1]]); + } + } + } + static int direction = 1; + if(direction == 1) { + ++offset_x; + if(offset_x > 5) { + direction = 0; + } + } else { + --offset_x; + if(offset_x <= 1) { + direction = 1; + } + } +} +// Blend from Side to Side +void ac::Side2Side(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static double pos = 1.0, pos_max = 3.0; + for(int z = 0; z < h; ++z) { + cv::Scalar total; + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + total[0] += (pixel[0]/2); + total[1] += (pixel[1]/2); + total[2] += (pixel[2]/2); + pixel[0] = static_cast(pixel[0] + (total[0]*pos)*0.01); + pixel[1] = static_cast(pixel[1] + (total[1]*pos)*0.01); + pixel[2] = static_cast(pixel[2] + (total[2]*pos)*0.01); + + // swap colors + swapColors(frame, z, i); + // if isNegative true invert pixel + if(isNegative) invert(frame, z, i); + } + } + static int direction = 1; + procPos(direction, pos, pos_max); +} +// Blend from Top To Bottom +void ac::Top2Bottom(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static double pos = 1.0, pos_max = 5.0; + for(int i = 0; i < w; ++i) { + cv::Scalar total; + for(int z = 0; z < h; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + total[0] += (pixel[0]/2); + total[1] += (pixel[1]/2); + total[2] += (pixel[2]/2); + pixel[0] = static_cast(pixel[0] + (total[0]*pos)*0.01); + pixel[1] = static_cast(pixel[1] + (total[1]*pos)*0.01); + pixel[2] = static_cast(pixel[2] + (total[2]*pos)*0.01); + // swap colors + swapColors(frame, z, i); + // if isNegative true invert pixel + if(isNegative) invert(frame, z, i); + } + } + static int direction = 1; + procPos(direction, pos, pos_max); +} + +void ac::StrobeRedGreenBlue(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static unsigned color = 0; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + switch(color) { + case 0: // B + pixel[1] = pixel[2] = 0; + break; + case 1:// G + pixel[0] = pixel[2] = 0; + break; + case 2:// R + pixel[0] = pixel[1] = 0; + } + // swap colors + swapColors(frame, z, i); + // if isNegative true invert pixel + if(isNegative) invert(frame, z, i); + } + } + ++color; + if(color > 2) color = 0; +} + +void ac::Blend_Angle(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static double pos = 1.0, pos_max = 5.0; + for(int z = 0; z < h; ++z) { + cv::Scalar total; + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + total[0] += pixel[0] * 0.01; + total[1] += pixel[1] * 0.01; + total[2] += pixel[2] * 0.01; + + pixel[0] = static_cast(pixel[0] + (total[0]) * (pos*0.1)); + pixel[1] = static_cast(pixel[1] + (total[1]) * (pos*0.1)); + pixel[2] = static_cast(pixel[2] + (total[2]) * (pos*0.1)); + + // swap colors + swapColors(frame, z, i); + // if isNegative true invert pixel + if(isNegative) invert(frame, z, i); + } + } + + static int direction = 1; + procPos(direction, pos,pos_max); +} + +void ac::Outward(cv::Mat &frame) { + int w = frame.cols;// frame width + int h = frame.rows;// frame height + static double start_pos = 1, pos = 1.0, pos_max = 5.0; + + static cv::Scalar offset(5, 50, 100); + + pos = start_pos; + + for(int y = h/2; y > 0; --y) { + for(int x = 0; x < w; ++x) { + cv::Vec3b &pixel = frame.at(y, x); + pixel[0] += static_cast((pos*offset[0])); + pixel[1] += static_cast((pos*offset[1])); + pixel[2] += static_cast((pos*offset[2])); + // swap colors + swapColors(frame, y, x); + // if isNegative true invert pixel + if(isNegative) invert(frame, y, x); + + } + pos += 0.005; + } + + pos = start_pos; + + for(int y = h/2+1; y < h; ++y) { + for(int x = 0; x < w; ++x) { + cv::Vec3b &pixel = frame.at(y, x); + pixel[0] += static_cast((pos*offset[0])); + pixel[1] += static_cast((pos*offset[1])); + pixel[2] += static_cast((pos*offset[2])); + // swap colors + swapColors(frame, y, x); + // if isNegative true invert pixel + if(isNegative) invert(frame, y, x); + } + pos += 0.005; + } + + offset[0] += 12; + offset[1] += 6; + offset[2] += 3; + + for(int i = 0; i < 3; ++i) if(offset[i] > 200) offset[i] = 0; + + static int direction = 1; + procPos(direction, start_pos, pos_max); +} + +void ac::OutwardSquare(cv::Mat &frame) { + int w = frame.cols;// frame width + int h = frame.rows;// frame height + int wx = w/2; + static double start_pos = 1, pos = 1.0, pos_max = 5.0; + static cv::Scalar offset(5, 50, 100); + pos = start_pos; + + for(int y = h/2; y > 0; --y) { + for(int x = 0; x < wx; ++x) { + cv::Vec3b &pixel = frame.at(y, x); + pixel[0] += static_cast((pos*offset[0])); + pixel[1] += static_cast((pos*offset[1])); + pixel[2] += static_cast((pos*offset[2])); + // swap colors + swapColors(frame, y, x); + // if isNegative true invert pixel + if(isNegative) invert(frame, y, x); + } + pos += 0.005; + } + //pos = start_pos; + for(int y = h/2; y > 0; --y) { + for(int x = w-1; x > wx-1; --x) { + cv::Vec3b &pixel = frame.at(y, x); + pixel[0] += static_cast((pos*offset[0])); + pixel[1] += static_cast((pos*offset[1])); + pixel[2] += static_cast((pos*offset[2])); + // swap colors + swapColors(frame, y, x); + // if isNegative true invert pixel + if(isNegative) invert(frame, y, x); + } + pos += 0.005; + } + + pos = start_pos; + for(int y = h/2+1; y < h; ++y) { + for(int x = 0; x < wx; ++x) { + cv::Vec3b &pixel = frame.at(y, x); + pixel[0] += static_cast((pos*offset[0])); + pixel[1] += static_cast((pos*offset[1])); + pixel[2] += static_cast((pos*offset[2])); + // swap colors + swapColors(frame, y, x); + // if isNegative true invert pixel + if(isNegative) invert(frame, y, x); + } + pos += 0.005; + } + //pos = start_pos; + for(int y = h/2+1; y < h; ++y) { + for(int x = w-1; x > wx-1; --x) { + cv::Vec3b &pixel = frame.at(y, x); + pixel[0] += static_cast((pos*offset[0])); + pixel[1] += static_cast((pos*offset[1])); + pixel[2] += static_cast((pos*offset[2])); + // swap colors + swapColors(frame, y, x); + // if isNegative true invert pixel + if(isNegative) invert(frame, y, x); + } + pos += 0.005; + } + offset[0] += 12; + offset[1] += 6; + offset[2] += 3; + for(int i = 0; i < 3; ++i) if(offset[i] > 200) offset[i] = 0; + static int direction = 1; + procPos(direction, start_pos, pos_max); +} + +void ac::ShiftPixels(cv::Mat &frame) { + static int offset = 1; + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + for(int z = 0; z < h; ++z) { + int start = 0; + for(int i = offset; i < w && start < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b &source = frame.at(z, start); + pixel[0] += source[0]; + pixel[1] += source[1]; + pixel[2] += source[2]; + ++start; + // swap colors + swapColors(frame, z, i); + // if isNegative true invert pixel + if(isNegative) invert(frame, z, i); + } + for(int i = 0; i < offset-1 && start < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b &source = frame.at(z, start); + pixel[0] += source[0]; + pixel[1] += source[1]; + pixel[2] += source[2]; + ++start; + // swap colors + swapColors(frame, z, i); + // if isNegative true invert pixel + if(isNegative) invert(frame, z, i); + } + } + static int direction = 1; + static int max_up = (w/16); + if(direction == 1) { + ++offset; + if(offset > max_up) { + direction = 0; + max_up += 4; + if(max_up > (w/4)) { + max_up = (w/16); + } + } + } else if(direction == 0) { + --offset; + if(offset < 2) direction = 1; + } +} + +void ac::ShiftPixelsDown(cv::Mat &frame) { + static int offset = 1; + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static double pos = 1.0, pos_max = 7.0; + for(int i = 0; i < w; ++i) { + int start = 0; + for(int z = offset; z < h && start < h; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b &source = frame.at(z, start); + pixel[0] += static_cast(source[0]*pos); + pixel[1] += static_cast(source[1]*pos); + pixel[2] += static_cast(source[2]*pos); + ++start; + // swap colors + swapColors(frame, z, i); + // if isNegative true invert pixel + if(isNegative) invert(frame, z, i); + } + for(int z = 0; z < offset-1 && start < h; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b &source = frame.at(z, start); + pixel[0] += static_cast(source[0]*pos); + pixel[1] += static_cast(source[1]*pos); + pixel[2] += static_cast( source[2]*pos); + ++start; + // swap colors + swapColors(frame, z, i); + // if isNegative true invert pixel + if(isNegative) invert(frame, z, i); + } + } + static int direction = 1; + static int max_up = (h/8); + if(direction == 1) { + ++offset; + if(offset > max_up) { + direction = 0; + max_up += 4; + if(max_up > (h/2)) { + max_up = (h/8); + } + } + } else if(direction == 0) { + --offset; + if(offset < 2) direction = 1; + } + static int dir = 1; + procPos(dir, pos, pos_max); + +} + +void ac::XorMultiBlend(cv::Mat &frame) { + int w = frame.cols;// frame width + int h = frame.rows;// frame height + static double pos = 1.0, pos_max = 3.0; + cv::Scalar s(pos, -pos, pos); + for(int y = h-1; y > 0; --y) { + for(int x = w-1; x > 0; --x) { + cv::Vec3b &pixel = frame.at(y, x); + pixel[0] = static_cast((pixel[0]^(int)s[0])*pos); + pixel[1] = static_cast((pixel[1]^(int)s[1])*pos); + pixel[2] = static_cast((pixel[2]^(int)s[2])*pos); + + swapColors(frame, y, x); + if(isNegative) invert(frame, y, x); + } + } + static int direction = 1; + procPos(direction, pos, pos_max, 4.0); +} + +void ac::BitwiseRotate(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static int offset = 0; + static int direction = 1; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + + if(direction == 1) { + pixel[0] = ror(pixel[0], offset); + pixel[1] = rol(pixel[1], offset); + pixel[2] = ror(pixel[2], offset); + } else { + pixel[0] = rol(pixel[0], offset); + pixel[1] = ror(pixel[1], offset); + pixel[2] = rol(pixel[2], offset); + } + + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + if(direction == 1) { + offset++; + if(offset >= 7) { + direction = 0; + } + } else { + offset--; + if(offset <= 1) { + direction = 1; + } + } +} + +void ac::BitwiseRotateDiff(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static int offset = 1; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int q = 0; q < 3; ++q) + pixel[q] += static_cast((pixel[q]-ror(pixel[q], offset))); + + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + ++offset; + if(offset > 7) offset = 1; +} + +void ac::HPPD(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static double pos = 1.0, pos_max = 4.0; + for(int z = 0; z < h; ++z) { + cv::Scalar total; + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + total[0] += pixel[0]; + total[1] += pixel[1]; + total[2] += pixel[2]; + pixel[0] = static_cast(pixel[0]-total[0]*pos); + pixel[1] = static_cast(pixel[1]-total[1]*pos); + pixel[2] = static_cast(pixel[2]-total[2]*pos); + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + + static int direction = 1; + procPos(direction, pos, pos_max); +} + +void ac::FuzzyLines(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static double pos = 1.0, pos_max = 4.0; + cv::Scalar prev_pixel; + double value[3] = { 0 }; + + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b temp = pixel; + + value[0] += temp[0]+temp[1]+temp[2]; + value[1] -= temp[0]+temp[1]+temp[2]; + value[2] += temp[0]+temp[1]+temp[2]; + pixel[0] += static_cast((value[0]*pos)*0.001); + pixel[1] += static_cast((value[1]*pos)*0.001); + pixel[2] += static_cast((value[2]*pos)*0.001); + + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + prev_pixel[0] = pixel[0]; + prev_pixel[1] = pixel[1]; + prev_pixel[2] = pixel[2]; + } + } + + static int direction = 1; + procPos(direction, pos, pos_max); +} + +void ac::GradientLines(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static int count = 0, index = 0; + + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[index] += static_cast(count); + ++count; + if(count >= 255) { + count = 0; + ++index; + if(index > 2) index = 0; + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } +} + +void ac::GradientSelf(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static double pos = 1.0, pos_max = 7.0; + static int count = 0, index = 0; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[index] = static_cast((pixel[index]*pos)+count); + ++count; + if(count >= 255) { + count = 0; + } + + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + ++index; + if(index > 2) index = 0; + } + static int direction = 1; + procPos(direction, pos, pos_max); +} + +void ac::GradientSelfVertical(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static double pos = 1.0, pos_max = 7.0; + static int count = 0, index = 0; + for(int i = 0; i < w; ++i) { + for(int z = 0; z < h; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[index] = static_cast((pixel[index]*pos)+count); + ++count; + if(count >= 255) { + count = 0; + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + ++index; + if(index > 2) index = 0; + } + static int direction = 1; + procPos(direction, pos, pos_max); +} + +void ac::GradientDown(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static double pos = 1.0, pos_max = 7.0; + static int count = 0, index = 0; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[index] = static_cast((pixel[index]*pos)+count); + ++index; + if(index > 2) index = 0; + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + ++count; + if(count >= 255) { + count = 0; + } + } + static int direction = 1; + procPos(direction, pos, pos_max); +} + +void ac::GraidentHorizontal(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static double pos = 1.0, pos_max = 7.0; + static int count = 0, index = 0; + for(int i = 0; i < w; ++i) { + for(int z = 0; z < h; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[index] = static_cast((pixel[index]*pos)+count); + ++index; + if(index > 2) index = 0; + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + ++count; + if(count >= 255) { + count = 0; + } + } + int direction = 1; + procPos(direction, pos, pos_max); +} + +void ac::GradientRGB(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static int count = 0, index = 0; + static int direction = 1; + if(direction == 1) { + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[index] = pixel[index]*count; + ++count; + if(count >= 255) { + ++index; + if(index > 2) { + index = 0; + } + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + } else { + for(int i = 0; i < w; ++i) { + for(int z = 0; z < h; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[index] = pixel[index]*count; + ++count; + if(count >= 255) { + ++index; + if(index > 2) { + index = 0; + } + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + } + if(direction == 1) direction = 0; else direction = 1; +} + + +void ac::Inter(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static int start_x = 0; + for(int z = start_x; z < h; z += 2) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[0] = pixel[1] = pixel[2] = 0; + } + } + if(start_x == 0) start_x = 1; else start_x = 0; +} + + +void ac::UpDown(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static double pos = 1.0, pos_max = 7.0; + double alpha = 1.0; + bool order = true; + + for(int i = 0; i < w; ++i) { + if(order == true) { + order = false; + for(int z = 0; z < h; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + for(int q = 0; q < 3; ++q) + pixel[q] = static_cast(alpha+(pixel[q]*pos)); + + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + alpha += 0.1; + } else { + order = true; + for(int z = h-1; z > 1; --z) { + cv::Vec3b &pixel = frame.at(z, i); + for(int q = 0; q < 3; ++q) + pixel[q] =static_cast(alpha-(pixel[q]*pos)); + + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + + alpha += 0.1; + } + + } + + static int direction = 1; + procPos(direction, pos, pos_max); +} + +void ac::LeftRight(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static double pos = 1.0, pos_max = 7.0; + double alpha = 1.0; + bool order = true; + for(int z = 0; z < h; ++z) { + if(order == true) { + order = false; + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int q = 0; q < 3; ++q) + pixel[q] = static_cast(alpha+(pixel[q]*pos)); + + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + alpha += 0.1; + } else { + order = true; + for(int i = w-1; i > 1; --i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int q = 0; q < 3; ++q) + pixel[q] = static_cast(alpha-(pixel[q]*pos)); + + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + + alpha += 0.1; + } + } + static int direction = 1; + procPos(direction, pos, pos_max); +} + +void ac::StrobeScan(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static double pos = 1.0, pos_max = 7.0; + static int color_mode = 0; + int over = rand()%255; + static int cdirection = 1; + + for(int z = 0; z < h; ++z) { + switch(color_mode) { + case 0: { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[color_mode] = static_cast(over+(pixel[color_mode]*pos)); + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + break; + case 1: { + for(int i = w-1; i > 1; --i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[color_mode] -= static_cast(over+(pixel[1]*pos)); + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + + } + } + break; + case 2: { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[color_mode] ^= static_cast(over+(pixel[color_mode]*pos)); + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + + } + } + break; + } + + if(cdirection == 1) { + ++color_mode; + if(color_mode > 2) { + cdirection = 0; + } + } else if(cdirection == 0) { + --color_mode; + if(color_mode < 0) { + cdirection = 1; + } + } + } + static int direction = 1; + procPos(direction, pos, pos_max); +} + +void ac::BlendedScanLines(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static int cnt = 0; + for(int z = 0; z < h; ++z) { + int r = rand()%255; + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[cnt] += static_cast(r); + ++r; + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + ++cnt; + if(cnt > 2) { + cnt = 0; + } + } + } +} + +void ac::GradientStripes(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static int offset = 0, count = 0; + int count_i = (rand()%0xFF)+(rand()%0xFFFFFF);//color offset + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[offset] += static_cast(count); + pixel[2-offset] -= static_cast(count_i); + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + ++count; + ++count_i; + } + ++offset; + if(offset > 2) + offset = 0; +} +// this one pixelates the image very heavily. +void ac::XorSine(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static cv::Scalar val(rand()%10, rand()%10, rand()%10); + static double pos = 1.0, pos_max = 7.0; + for(int i = 0; i < w; ++i) { + for(int z = 0; z < h; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[0] ^= static_cast(sin(pixel[0])*val[0]); + pixel[1] ^= static_cast(sin(pixel[1])*val[1]); + pixel[2] ^= static_cast(sin(pixel[2])*val[2]); + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + static int direction = 1; + for(int q = 0; q < 3; ++q) { + if(direction == 1) + val[q] += pos; + else + val[q] -= pos; + } + procPos(direction, pos, pos_max); +} + + + +void ac::Circular(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static double pos = 1.0, pos_max = 7.0; + static double deg = 0.0; + static double rad = 50; + + for(int i = 0; i < w; ++i) { + for(int z = 0; z < h; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + int X_color = int(rad * cos(deg)); + int Y_color = int(rad * sin(deg)); + pixel[0] += static_cast(pos*X_color); + pixel[1] *= static_cast(pos); + pixel[2] += static_cast(pos*Y_color); + deg += 0.1; + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + rad += 0.5; + if(rad > 100) rad = 50; + static int direction = 1; + procPos(direction, pos, pos_max); +} + + +void ac::WhitePixel(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static int pixel_count = 0; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + if(pixel_count == 4) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[0] = pixel[1] = pixel[2] = 255; + pixel_count = rand()%2; + } else ++pixel_count; + + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + pixel_count = rand()%2; + } +} + +void ac::FrameBlend(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static double pos = 1.0, pos_max = 7.0; + static cv::Mat stored_frame; + if((frame.rows != stored_frame.rows) || (frame.cols != stored_frame.cols)) { + stored_frame = frame.clone(); + } + cv::Mat start = frame.clone(); + // process frame + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b old_pixel = stored_frame.at(z, i); + pixel[0] += static_cast((old_pixel[0]^pixel[0])*pos); + pixel[1] += static_cast((old_pixel[1]&pixel[1])*pos); + pixel[2] += static_cast((old_pixel[2]|pixel[2])*pos); + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + stored_frame = start.clone(); + static int direction = 1; + procPos(direction, pos, pos_max); +} + +void ac::FrameBlendRGB(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static double pos = 1.0, pos_max = 7.0; + static cv::Mat stored_frame; + if(stored_frame.empty() || frame.size() != stored_frame.size()) { + stored_frame = frame.clone(); + } + cv::Mat start = frame.clone(); + static int swap = 0; + // process frame + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b old_pixel = stored_frame.at(z, i); + switch(swap) { + case 0: + pixel[0] += static_cast((old_pixel[0]^pixel[0])*pos); + pixel[1] += static_cast((old_pixel[1]&pixel[1])*pos); + pixel[2] += static_cast((old_pixel[2]|pixel[2])*pos); + break; + case 1: + pixel[0] += static_cast((old_pixel[0]&pixel[0])*pos); + pixel[1] += static_cast((old_pixel[1]|pixel[1])*pos); + pixel[2] += static_cast((old_pixel[2]^pixel[2])*pos); + break; + case 2: + pixel[0] += static_cast((old_pixel[0]|pixel[0])*pos); + pixel[1] += static_cast((old_pixel[1]^pixel[1])*pos); + pixel[2] += static_cast((old_pixel[2]&pixel[2])*pos); + break; + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + ++swap; + if(swap > 2) swap = 0; + stored_frame = start.clone(); + static int direction = 1; + procPos(direction, pos, pos_max); +} + +void ac::TrailsFilter(cv::Mat &frame) { + static MatrixCollection<4> collection; + collection.shiftFrames(frame); + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Scalar s; + cv::Vec3b frame_pixels[8]; + frame_pixels[0] = collection.frames[1].at(z, i); + frame_pixels[1] = collection.frames[2].at(z, i); + frame_pixels[2] = collection.frames[3].at(z, i); + pixel[0] += (frame_pixels[0][0] + frame_pixels[1][0] + frame_pixels[2][0]); + pixel[1] += (frame_pixels[0][1] + frame_pixels[1][1] + frame_pixels[2][1]); + pixel[2] += (frame_pixels[0][2] + frame_pixels[1][2] + frame_pixels[2][2]); + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } +} + +void ac::TrailsFilterIntense(cv::Mat &frame) { + static MatrixCollection<8> collection; + collection.shiftFrames(frame); + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Scalar s; + cv::Vec3b frame_pixels[8]; + frame_pixels[0] = collection.frames[0].at(z, i); + frame_pixels[1] = collection.frames[1].at(z, i); + frame_pixels[2] = collection.frames[2].at(z, i); + frame_pixels[3] = collection.frames[3].at(z, i); + frame_pixels[4] = collection.frames[4].at(z, i); + frame_pixels[5] = collection.frames[5].at(z, i); + pixel[0] += (frame_pixels[0][0] + frame_pixels[1][0] + frame_pixels[2][0] + frame_pixels[3][0] + frame_pixels[4][0] + frame_pixels[5][0]); + pixel[1] += (frame_pixels[0][1] + frame_pixels[1][1] + frame_pixels[2][1] + frame_pixels[3][1] + frame_pixels[4][1] + frame_pixels[5][1]); + pixel[2] += (frame_pixels[0][2] + frame_pixels[1][2] + frame_pixels[2][2] + frame_pixels[3][2] + frame_pixels[4][2] + frame_pixels[5][2]); + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } +} + +void ac::TrailsFilterSelfAlpha(cv::Mat &frame) { + static MatrixCollection<8> collection; + static double pos = 1.0, pos_max = 7.0; + collection.shiftFrames(frame); + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Scalar s; + cv::Vec3b frame_pixels[8]; + frame_pixels[0] = collection.frames[1].at(z, i); + frame_pixels[1] = collection.frames[2].at(z, i); + frame_pixels[2] = collection.frames[3].at(z, i); + frame_pixels[3] = collection.frames[4].at(z, i); + frame_pixels[4] = collection.frames[5].at(z, i); + frame_pixels[5] = collection.frames[6].at(z, i); + pixel[0] += static_cast((frame_pixels[0][0] + frame_pixels[1][0] + frame_pixels[2][0] + frame_pixels[3][0] + frame_pixels[4][0] + frame_pixels[5][0])*pos); + pixel[1] += static_cast((frame_pixels[0][1] + frame_pixels[1][1] + frame_pixels[2][1] + frame_pixels[3][1] + frame_pixels[4][1] + frame_pixels[5][1])*pos); + pixel[2] += static_cast((frame_pixels[0][2] + frame_pixels[1][2] + frame_pixels[2][2] + frame_pixels[3][2] + frame_pixels[4][2] + frame_pixels[5][2])*pos); + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + static int direction = 1; + procPos(direction, pos, pos_max); +} + +void ac::TrailsFilterXor(cv::Mat &frame) { + static MatrixCollection<12> collection; + static double pos = 1.0, pos_max = 7.0; + collection.shiftFrames(frame); + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Scalar s; + cv::Vec3b frame_pixels[12]; + frame_pixels[0] = collection.frames[1].at(z, i); + frame_pixels[1] = collection.frames[2].at(z, i); + frame_pixels[2] = collection.frames[3].at(z, i); + frame_pixels[3] = collection.frames[4].at(z, i); + frame_pixels[4] = collection.frames[5].at(z, i); + frame_pixels[5] = collection.frames[6].at(z, i); + pixel[0] ^= (frame_pixels[0][0] + frame_pixels[1][0] + frame_pixels[2][0] + frame_pixels[3][0] + frame_pixels[4][0] + frame_pixels[5][0]); + pixel[1] ^= (frame_pixels[0][1] + frame_pixels[1][1] + frame_pixels[2][1] + frame_pixels[3][1] + frame_pixels[4][1] + frame_pixels[5][1]); + pixel[2] ^= (frame_pixels[0][2] + frame_pixels[1][2] + frame_pixels[2][2] + frame_pixels[3][2] + frame_pixels[4][2] + frame_pixels[5][2]); + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + static int direction = 1; + procPos(direction, pos, pos_max); +} + +void ac::ColorTrails(cv::Mat &frame) { + static MatrixCollection<8> collection; + collection.shiftFrames(frame); + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Scalar s; + cv::Vec3b frame_pixels[8]; + frame_pixels[0] = collection.frames[1].at(z, i); + frame_pixels[1] = collection.frames[2].at(z, i); + frame_pixels[2] = collection.frames[3].at(z, i); + frame_pixels[3] = collection.frames[4].at(z, i); + frame_pixels[4] = collection.frames[5].at(z, i); + frame_pixels[5] = collection.frames[6].at(z, i); + for(int q = 0; q < 6; ++q) { + if(frame_pixels[q][0] > pixel[0]) frame_pixels[q][0] = 0; + if(frame_pixels[q][1] < pixel[1]) frame_pixels[q][1] = 0; + if(frame_pixels[q][2] > pixel[2]) frame_pixels[q][2] = 0; + } + pixel[0] = (frame_pixels[0][0] + frame_pixels[1][0] + frame_pixels[2][0] + frame_pixels[3][0] + frame_pixels[4][0] + frame_pixels[5][0]); + pixel[1] = (frame_pixels[0][1] + frame_pixels[1][1] + frame_pixels[2][1] + frame_pixels[3][1] + frame_pixels[4][1] + frame_pixels[5][1]); + pixel[2] = (frame_pixels[0][2] + frame_pixels[1][2] + frame_pixels[2][2] + frame_pixels[3][2] + frame_pixels[4][2] + frame_pixels[5][2]); + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } +} + +void ac::MoveRed(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + static double pos = 1.0, pos_max = 7.0; + static int movement = 0; + cv::Mat frame_copy = frame.clone(); + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + if(i+movement < (w-1)) { + cv::Vec3b add = frame_copy.at(z, (i+movement)); + pixel[2] += static_cast((add[2]*pos)); + } else if((i-movement) > 1) { + cv::Vec3b add = frame_copy.at(z, (i-movement)); + pixel[2] += static_cast((add[2]*pos)); + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + ++movement; + if(movement > (w-1)) movement = 0; + static int direction = 1; + procPos(direction, pos, pos_max); +} + +void ac::MoveRGB(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + static double pos = 1.0, pos_max = 7.0; + static int rgb = 0; + static int movement = 0; + cv::Mat frame_copy = frame.clone(); + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + if(i+movement < (w-1)) { + cv::Vec3b add = frame_copy.at(z, (i+movement)); + pixel[rgb] += static_cast((add[rgb]*pos)); + } else if((i-movement) > 1) { + cv::Vec3b add = frame_copy.at(z, (i-movement)); + pixel[rgb] += static_cast((add[rgb]*pos)); + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + ++rgb; + if(rgb > 2) rgb = 0; + ++movement; + if(movement > (w-1)) movement = 0; + static int direction = 1; + procPos(direction, pos, pos_max); +} + +void ac::MoveRedGreenBlue(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + static double pos = 1.0, pos_max = 7.0; // position in transition, maximum value + static int movement[4] = {0, w, 0}; // movement variable array + static int stored_w = w; // stored_w in case the frame size changes + if(stored_w != w) { + movement[1] = w-1; // set movement[1] to width + stored_w = w; // stored_w set to new width + } + cv::Mat frame_copy = frame.clone(); // make a copy of the frame + for(int z = 0; z < h; ++z) { // loop from top to bottom + for(int i = 0; i < w; ++i) { // loop from left to right + cv::Vec3b &pixel = frame.at(z, i); // reference to current pixel + for(int q = 0; q <= 2; ++q) { // loop from 0 to 2 + int pos_x = i+movement[q];// pixel position + int pos_y = i-movement[q];// pixel position + if(pos_x < (w-1) && pos_x > 0) { // if within the screen + cv::Vec3b add = frame_copy.at(z, pos_x); // grab pixel + pixel[q] += static_cast((add[q]*pos)); // add to current index multiplied by position + } else if(pos_y > 0 && pos_y < (w-1)) {// if pos y within the screen + cv::Vec3b add = frame_copy.at(z, pos_y); // grab pixel + pixel[q] += static_cast((add[q]*pos));// add to current index multiplied by position + } + } + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + } + movement[0] += 4; // movement position increase by 4 + if(movement[0] > (w-1)) movement[0] = 0; + movement[1] -= 4;// movement position decrease by 4 + if(movement[1] < 1) movement[1] = w-1; // set to width -1 + movement[2] += 8;// movement position increase by 8 + if(movement[2] > (w-1)) movement[2] = 0;// if greater than widthset to zero + static int direction = 1;// direction of transition animation + procPos(direction, pos, pos_max);// proc the position by increasing/decreasing +} + +void ac::BlurSim(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + static double pos = 1.0, pos_max = 7.0; + + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b pixels[2][2]; + cv::Vec3b &pixel = frame.at(z, i); + bool grabbed = true; + for(int a = 0; a < 2; a++) { + for(int b = 0; b < 2; b++) { + if((a+i) < (w-1) && (b+z) < (h-1)) { + pixels[a][b] = frame.at(z+b, i+a); + } else { + grabbed = false; + break; + } + } + } + if(grabbed == false) continue; + unsigned char rgb[3] = {0}; + for(int q = 0; q < 3; ++q) + for(int a = 0; a < 2; ++a) { + for(int b = 0; b < 2; ++b) { + rgb[q] += pixels[a][b][q]; + } + } + pixel[0] ^= static_cast((rgb[0]/4)*pos); + pixel[1] ^= static_cast((rgb[1]/4)*pos); + pixel[2] ^= static_cast((rgb[2]/4)*pos); + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + } + static int direction = 1; + procPos(direction, pos, pos_max); +} + +void ac::Block(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + static int square = 2; + for(int z = 0; z < h; z += square) { + for(int i = 0; i < w; i += square) { + cv::Vec3b &pixel = frame.at(z, i); + for(int x = 0; x < square; ++x) { + for(int y = 0; y < square; ++y) { + if(y+z < h && i+x < w) { + cv::Vec3b &pix = frame.at(y+z, i+x); + pix = pixel; + } + } + } + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + } + static int direction = 1; + if(direction == 1) { + square += 2; + if(square >= 32) direction = 0; + } else { + square -= 2; + if(square <= 2) direction = 1; + } +} + +void ac::BlockXor(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + static double pos = 1.0, pos_max = 3.0; + static int square = 2; + for(int z = 0; z < h; z += square) { + for(int i = 0; i < w; i += square) { + cv::Vec3b &pixel = frame.at(z, i); + for(int x = 0; x < square; ++x) { + for(int y = 0; y < square; ++y) { + if(y+z < h && i+x < w) { + cv::Vec3b &pix = frame.at(y+z, i+x); + pix[0] ^= static_cast(pixel[0]*pos); + pix[1] ^= static_cast(pixel[1]*pos); + pix[2] ^= static_cast(pixel[2]*pos); + + } + } + } + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + + } + } + static int direction = 1; + if(direction == 1) { + square += 2; + if(square >= 8) direction = 0; + } else { + square -= 2; + if(square <= 2) direction = 1; + } + static int posDirection = 1; + procPos(posDirection, pos, pos_max); +} +// BlockScale +void ac::BlockScale(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + static double pos = 1.0, pos_max = 3.0; + static int square = 2; + for(int z = 0; z < h; z += square) { // loop from top to bottom + for(int i = 0; i < w; i += square) { // loop from left to right + cv::Vec3b &pixel = frame.at(z, i);// grab pixel value + for(int x = 0; x < square; ++x) {// draw square from left to right + for(int y = 0; y < square; ++y) {// draw square form top to bottom + if(y+z < h && i+x < w) {// within bounds? + cv::Vec3b &pix = frame.at(y+z, i+x); // grab pixel + pix[0] = static_cast(pixel[0]*pos); // calculate values + pix[1] = static_cast(pixel[1]*pos); + pix[2] = static_cast(pixel[2]*pos); + } + } + } + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + } + // move in/out direction + static int direction = 1; + if(direction == 1) { + square += 2; + if(square >= 8) direction = 0; + } else { + square -= 2; + if(square <= 2) direction = 1; + } + static int posDirection = 1; + procPos(posDirection, pos, pos_max); +} + +void ac::BlockStrobe(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + static int square = 2; + for(int z = 0; z < h; z += square) { + for(int i = 0; i < w; i += square) { + cv::Vec3b &pixel = frame.at(z, i); + for(int x = 0; x < square; ++x) { + for(int y = 0; y < square; ++y) { + if(y+z < h && i+x < w) { + cv::Vec3b &pix = frame.at(y+z, i+x); + pix[0] += static_cast(pixel[0]*(x*y)); + pix[1] += static_cast(pixel[1]*(x*y)); + pix[2] += static_cast(pixel[2]*(x*y)); + } + } + } + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + } + static int direction = 1; + if(direction == 1) { + square += 2; + if(square >= 8) direction = 0; + } else { + square -= 2; + if(square <= 2) direction = 1; + } +} + +// Prev Frame Blend +// store previous frame and manipulate with current frame +void ac::PrevFrameBlend(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + double pos = 1.0; + static int old_w = w; + static cv::Mat stored = frame.clone(), temp; + temp = frame.clone(); + if(old_w != w) { + stored = frame.clone(); + old_w = w; + } + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b old_pixel = stored.at(z, i); + pixel[0] = static_cast((pixel[0])+(1-old_pixel[0])*pos); + pixel[1] = static_cast((pixel[1])+(1-old_pixel[1])*pos); + pixel[2] = static_cast((pixel[2])+(1-old_pixel[2])*pos); + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + } + stored = temp; + static int direction = 1; + if(direction == 1) { + pos += 0.1; + if(pos > 7.0) direction = 0; + } else { + pos -= 0.1; + if(pos <= 1.0) direction = 1; + } + resetAlpha(direction, pos); + +} + +class WavePoints { +public: + WavePoints() : x1(0), x2(0), x1_dir(0), x2_dir(0),c_dir(0),color(0) {} + int x1,x2; + int x1_dir, x2_dir, c_dir; + double color; +}; + + +void ac::Wave(cv::Mat &frame) { + static int width = 0, height = 0; + // uses lazy allocation when frame is resized pointer is reallocated. + // last deallocation is done when program exits so no need to manually release + static std::unique_ptr points; + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + const int slice = (h/16); + + if(width != w || height != h) { + points.reset(new WavePoints[w]); + width = w; + height = h; + + for(int i = 0; i < w; ++i) { + points[i].x1 = rand()%slice; + points[i].x2 = h-rand()%slice; + points[i].color = rand()%13; + points[i].x1_dir = 0; + points[i].x2_dir = 0; + points[i].c_dir = 0; + } + } + for(int z = 0; z (z, i); + if(z >= points[i].x1 && z <= points[i].x2) { + pixel[0] += static_cast(pixel[0]*points[i].color); + pixel[1] += static_cast(pixel[1]*points[i].color); + pixel[2] += static_cast(pixel[2]*points[i].color); + } + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + } + for(int i = 0; i < w; ++i) { + // color direction + if(points[i].c_dir == 0) { + points[i].color += 0.1; + if(points[i].color >= 10) { + points[i].c_dir = 1; + } + } else if(points[i].c_dir == 1) { + points[i].color -= 0.1; + if(points[i].color <= 1) { + points[i].c_dir = 0; + } + } + + // x1 point direction/move down and up + if(points[i].x1_dir == 0) { + points[i].x1 ++; + if(points[i].x1 > slice) { + points[i].x1_dir = 1; + } + } else if(points[i].x1_dir == 1) { + points[i].x1--; + if(points[i].x1 < 1) { + points[i].x1_dir = 0; + } + } + + // x2 point up/down + if(points[i].x2_dir == 0) { + points[i].x2--; + if(points[i].x2 < (h-slice)) { + points[i].x2_dir = 1; + } + } else if(points[i].x2_dir == 1) { + points[i].x2++; + if(points[i].x2 > (h-4)) { + points[i].x2_dir = 0; + } + } + } +} + +void ac::HighWave(cv::Mat &frame) { + static int width = 0, height = 0; + static std::unique_ptr points; + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + const int slice = (h/8); + + if(width != w || height != h) { + points.reset(new WavePoints[w]); + width = w; + height = h; + + for(int i = 0; i < w; ++i) { + points[i].x1 = rand()%slice; + points[i].x2 = h-rand()%slice; + points[i].color = rand()%13; + points[i].x1_dir = 0; + points[i].x2_dir = 0; + points[i].c_dir = 0; + } + } + for(int z = 0; z (z, i); + pixel[0] -= static_cast(pixel[0]*points[i].color); + pixel[1] += static_cast(pixel[1]*points[i].color); + pixel[2] -= static_cast(pixel[2]*points[i].color); + swapColors(frame, z, i);// swap colors for rgb slides + if(isNegative) invert(frame, z, i); // if is negative + } + } + for(int i = 0; i < w; ++i) { + // color direction + if(points[i].c_dir == 0) { + points[i].color += 0.25; + if(points[i].color >= 10) { + points[i].c_dir = 1; + } + } else if(points[i].c_dir == 1) { + points[i].color -= 0.25; + if(points[i].color <= 1) { + points[i].c_dir = 0; + } + } + } +} + +void ac::VerticalSort(cv::Mat &frame) { + int w = frame.cols;// frame width + int h = frame.rows;// frame height + static std::vector v;// static vector of int + v.reserve(w);// reserve w bytes + for(int i = 0; i < w; ++i) { // top to bottom + for(int z = 0; z < h; ++z) { // left to right + //int value = frame.at(z, i); + // grab pixel reference + + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + + cv::Vec3b &value = frame.at(z, i); + unsigned int vv = 0; + // unsigned char * of vv + unsigned char *cv = (unsigned char*)&vv; + // set RGB values + cv[0] = value[0]; + cv[1] = value[1]; + cv[2] = value[2]; + cv[3] = 0; + // push back into vector v + v.push_back(vv); + } + // sort vector v + std::sort(v.begin(), v.end()); + for(int q = 0; q < h; ++q) {// left to right + // unsigned char pointer of vector v at index i + unsigned char *value = (unsigned char*)&v[q]; + // get pixel reference + cv::Vec3b &pixel = frame.at(q, i); + // add to pixel without scaling + pixel[0] = value[0]; + pixel[1] = value[1]; + pixel[2] = value[2]; + + } + v.erase(v.begin(), v.end()); + } +} + +void ac::VerticalChannelSort(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + std::vector pixels[3]; + for(int i = 0; i < w; ++i) { + for(int z = 0; z < h; ++z) { + + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixels[j].push_back(pixel[j]); + } + + for(int j = 0; j < 3; ++j) + std::sort(pixels[j].begin(), pixels[j].end()); + + for(int z = 0; z < h; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[0] = pixels[0][z]; + pixel[1] = pixels[1][z]; + pixel[2] = pixels[2][z]; + } + for(int j = 0; j < 3; ++j) + if(!pixels[j].empty()) + pixels[j].erase(pixels[j].begin(), pixels[j].end()); + } + +} + +void ac::HorizontalBlend(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static double alpha[3] = {1,8,16}; + for(int i = 0; i < w; ++i) { + for(int z = 0; z < h; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[0] = static_cast(pixel[0] * alpha[0]); + pixel[1] = static_cast(pixel[1] * alpha[1]); + pixel[2] = static_cast(pixel[2] * alpha[2]); + + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + if((rand()%4)==0) { + for(int i = 0; i < 3; ++i) { + alpha[i] += 0.1; + if(alpha[i] > 25) alpha[i] = 1; + } + } + } +} + +void ac::VerticalBlend(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static double alpha[3] = {1,8,16}; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[0] = static_cast(pixel[0] * alpha[0]); + pixel[1] = static_cast(pixel[1] * alpha[1]); + pixel[2] = static_cast(pixel[2] * alpha[2]); + + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + if((rand()%4)==0) { + for(int i = 0; i < 3; ++i) { + alpha[i] += 0.1; + if(alpha[i] > 25) alpha[i] = 1; + } + } + } +} + diff --git a/windows/Acid.Cam.Qt.Windows.Project/ac-filter4.cpp b/windows/Acid.Cam.Qt.Windows.Project/ac-filter4.cpp new file mode 100755 index 0000000..7fe631d --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/ac-filter4.cpp @@ -0,0 +1,1241 @@ +/* + * Software written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + +#include "ac.h" +#include "fractal.h" + + +void ac::OppositeBlend(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + cv::Mat temp = frame.clone(); + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w-1; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b temp_pixel = temp.at(z, w-i-1); + pixel[0] = static_cast((pixel[0]+temp_pixel[0])); + pixel[1] = static_cast((pixel[1]+temp_pixel[1])); + pixel[2] = static_cast((pixel[2]+temp_pixel[2])); + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + } +} + +void ac::DiagonalLines(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + cv::Mat temp = frame.clone(); + static double pos = 1.0; + + for(int i = 0; i < w-1; ++i) { + for(int z = 0; z < h-1; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b temp_pixel = temp.at(h-z-1, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast((pixel[j]+temp_pixel[j])+pos); + ++pos; + if(pos > 100) pos = 0; + } + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + } +} + +void ac::HorizontalLines(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static double pos[3] = {1.0, 16.0, 32.0}; + + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast(pixel[j] + pos[j]); + pos[j] += 0.1; + if(pos[j] > 100) + pos[j] = 0; + + } + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + } +} + +void ac::InvertedScanlines(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + + static int index = 0; + static double alpha = 1.0; + static double pos_max = 14.0; + + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + switch(index) { + case 0: { + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast((~pixel[j])*alpha); + index++; + } + case 1: { + cv::Vec3b temp = pixel; + pixel[0] = static_cast(temp[2]*alpha); + pixel[1] = static_cast(temp[1]*alpha); + pixel[2] = static_cast(temp[0]*alpha); + index++; + } + break; + case 2: + index = 0; + break; + } + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + } + + static int direction = 1; + procPos(direction, alpha, pos_max); +} + +void ac::Soft_Mirror(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static int index = 0; + cv::Mat temp = frame.clone(); + for(int z = 1; z < h-1; ++z) { + for(int i = 1; i < w-1; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + switch(index) { + case 0: + index++; + break; + case 1: { + cv::Vec3b pix = frame.at(h-z-1, w-i-1); + pixel[0] = pix[0]; + pixel[1] = pix[1]; + pixel[2] = pix[2]; + index = 0; + } + break; + } + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + } +} + +void ac::KanapaTrip(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static int start_index = 0; + int index = start_index; + cv::Mat temp = frame.clone(); + for(int z = 1; z < h-1; ++z) { + for(int i = 1; i < w-1; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + switch(index) { + case 0: + index++; + break; + case 1: { + cv::Vec3b pix = frame.at(h-z-1, w-i-1); + pixel[0] = pix[0]; + pixel[1] = pix[1]; + pixel[2] = pix[2]; + index = 0; + } + break; + } + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + } + if(start_index == 0) + start_index = 1; + else + start_index = 0; +} + +void ac::ColorMorphing(cv::Mat &frame) { + KanapaTrip(frame); + SidewaysMirror(frame); +} + + +void ac::ScanSwitch(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static int start_index = 0; + int index = start_index; + for(int z = 3; z < h-3; ++z) { + for(int i = 3; i < w-3; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + switch(index) { + case 0: + index++; + break; + case 1: { + pixel[0] = ~pixel[0]; + pixel[1] = ~pixel[1]; + pixel[2] = ~pixel[2]; + index = 0; + } + break; + } + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + } + if(start_index == 0) + start_index = 1; + else + start_index = 0; +} + + +void ac::ScanAlphaSwitch(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static int start_index = 0; + static double alpha = 1.0, alpha_max = 10.0; + int index = start_index; + for(int z = 3; z < h-3; ++z) { + for(int i = 3; i < w-3; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + switch(index) { + case 0: + index++; + pixel[0] = ~pixel[0]; + pixel[1] = ~pixel[1]; + pixel[2] = ~pixel[2]; + break; + case 1: { + pixel[0] += static_cast(pixel[0]*alpha); + pixel[1] += static_cast(pixel[1]*alpha); + pixel[2] += static_cast(pixel[2]*alpha); + index = 0; + } + break; + } + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + } + if(start_index == 0) + start_index = 1; + else + start_index = 0; + + static int direction = 1; + procPos(direction, alpha, alpha_max); +} + +void ac::NegativeStrobe(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + static int flash = 1; + if(flash == 1) { + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[0] = ~pixel[0]; + pixel[1] = ~pixel[1]; + pixel[2] = ~pixel[2]; + } + } + } + if(flash == 1) { + flash = 0; + } else { + flash = 1; + } +} + +void ac::XorAddMul(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + static double blend = 1.0, blend_max = 13.0; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + int b = static_cast(blend); + pixel[0] += static_cast(pixel[0]^b); + pixel[1] += static_cast(pixel[1]+b); + pixel[2] += static_cast(pixel[2]*b); + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + } + static int direction = 1; + procPos(direction, blend, blend_max); + //if(blend > 255) blend = 1.0; +} + + +void ac::BlendSwitch(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + static int pos = 0; + static unsigned char blend_pixel = 0; + for(int i = 0; i < w; ++i) { + for(int z = 0; z < h; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[pos] *= blend_pixel++; + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + pos++; + if(pos > 2) pos = 0; + } +} + +// set all color components other than red to zero +void ac::AllRed(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[0] = pixel[1] = 0; + } + } +} +// set all color components other than green to zero +void ac::AllGreen(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[0] = pixel[2] = 0; + } + } +} +// set all color components other than blue to zero +void ac::AllBlue(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[2] = pixel[1] = 0; + } + } +} +// set colors to zero based on counter +// increment counter after each nested loop +void ac::LineRGB(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + static int counter = 0; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + switch(counter) { + case 0: + pixel[0] = pixel[1] = 0; + break; + case 1: + pixel[0] = pixel[2] = 0; + break; + case 2: + pixel[2] = pixel[1] = 0; + break; + } + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + ++counter; + if(counter > 2) counter = 0; + } +} +// set colors to zero based on counter +// increment counter each iteration of nested loop +void ac::PixelRGB(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + static int counter = 0; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + switch(counter) { + case 0: + pixel[0] = pixel[1] = 0; + break; + case 1: + pixel[0] = pixel[2] = 0; + break; + case 2: + pixel[2] = pixel[1] = 0; + break; + } + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + ++counter; + if(counter > 2) counter = 0; + } + } +} + +// Boxed RGB +void ac::BoxedRGB(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + static int row_counter = 0; // row counter + + for(int z = 0; z < h; ++z) { // from top to bottom + for(int i = 0; i < w; ++i) { // from left to right + cv::Vec3b &pixel = frame.at(z, i); // pixel + switch(row_counter) {// row counter iterate between red,green,and blue + case 0: + pixel[0] = pixel[1] = 0; // red + break; + case 1: + pixel[0] = pixel[2] = 0; // green + break; + case 2: + pixel[2] = pixel[1] = 0; // blue + break; + } + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + // if z is evenly divideable by 32 + if((z%32) == 0) { + ++row_counter;// increment row counter + if(row_counter > 3) row_counter = 0; + } + } +} + +// joke filter +// color the image with red/green bars switching color each frame +void ac::KruegerSweater(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + static int row_counter = 0;// row counter + static int rg = 0;// row counter start variable + row_counter = rg; // set row counter to start + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + // set the colors other than red or green to zero based on row counter + switch(row_counter) { + case 0: + pixel[0] = pixel[1] = 0; // red + break; + case 1: + pixel[0] = pixel[2] = 0; // green + break; + } + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + if((z%32) == 0) { + ++row_counter; // increment row counter + if(row_counter >= 2) { // if greater than or equal 2 + row_counter = 0; // set to row_counter to zero + } + } + } + rg = (rg == 0) ? 1 : 0; // swap back and forth rg between zero and one. +} + +void ac::RGBFlash(cv::Mat &frame) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + static int counter = 0; // counter for setting the pixel + static int start = 0; // start position + for(int z = start; z < h; z += 2) { // top to bottom, skipping 1 each time + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + // set pixel a certain color based on the counter + switch(counter) { + case 0: + pixel[2] = 255;// set red + break; + case 1: + pixel[1] = 255; // set green + break; + case 2: + pixel[0] = 255;// set blue + break; + } + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + } + ++counter;// increment counter + if(counter > 2) counter = 0; // if greater than 2 reset to zero + start = (start == 0) ? 1 : 0; // swap start back and forth between 0 and 1 +} + +void ac::IncreaseBlendHorizontal(cv::Mat &frame) { + ac::orig_frame = frame.clone(); + const int w = frame.cols; + const int h = frame.rows; + for(int i = 0; i < w; ++i) { + cv::Vec3b pix; + for(int z = 0; z < h; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + pix[0] += pixel[0]/2; + pix[1] += pixel[1]/4; + pix[2] += pixel[2]/6; + pixel[0] += pixel[0] * (pix[0]/32); + pixel[1] += pixel[1] * (pix[1]/32); + pixel[2] += pixel[2] * (pix[2]/32); + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + } + ac::pass2_alpha = 0.75; + Pass2Blend(frame); +} +// blend increase +void ac::BlendIncrease(cv::Mat &frame) { + static int blend_r = rand()%255, blend_g = rand()%255, blend_b = rand()%255; + static bool cblend_r = true, cblend_g = true, cblend_b = true; + static int increase_value_r = 2, increase_value_g = 2, increase_value_b = 2; + const int w = frame.cols; + const int h = frame.rows; + if(blend_r > 255) { + blend_r = rand()%255; + if(cblend_r == true) { + blend_r = -blend_r; + cblend_r = false; + } else { + cblend_r = true; + } + } + if(blend_g > 255) { + blend_g = rand()%255; + if(cblend_g == true) { + blend_g = -blend_g; + cblend_g = false; + } else { + cblend_g = true; + } + } + if(blend_b > 255) { + blend_b = rand()%255; + if(cblend_b == true) { + blend_b = -blend_b; + cblend_b = false; + } else { + cblend_b = true; + } + } + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[2] += static_cast(blend_r); + pixel[1] += static_cast(blend_g); + pixel[0] += static_cast(blend_b); + swapColors(frame, z, i);// swap colors for rgb sliders + if(isNegative) invert(frame, z, i); // if is negative + } + } + blend_r += increase_value_r; + blend_g += increase_value_g; + blend_b += increase_value_b; + increase_value_r += rand()%5; + increase_value_g += rand()%5; + increase_value_b += rand()%5; + if(increase_value_r > 20) { + increase_value_r = 2; + } + if(increase_value_g > 20) { + increase_value_g = 2; + } + if(increase_value_b > 20) { + increase_value_b = 2; + } +} + +void ac::GradientReverse(cv::Mat &frame) { + const int w = frame.cols; + const int h = frame.rows; + static bool direction = true; + static double alpha = 1.0, alpha_max = 8; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + if(direction == true) + pixel[j] += static_cast(i*alpha); + else + pixel[j] -= static_cast(i*alpha); + } + ac::swapColors(frame, z, i); + if(isNegative) ac::invert(frame, z, i); + } + direction = (direction == true) ? false : true; + } + static int direction_ = 1; + procPos(direction_, alpha, alpha_max); +} + +void ac::GradientReverseBox(cv::Mat &frame) { + const int w = frame.cols; + const int h = frame.rows; + static bool direction = true; + static double alpha = 1.0, alpha_max = 8; + for(int i = 0; i < w; ++i) { + for(int z = 0; z < h; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + if(direction == true) + pixel[j] += static_cast((i*alpha)); + else + pixel[j] -= static_cast((z*alpha)); + } + ac::swapColors(frame, z, i); + if(isNegative) ac::invert(frame, z, i); + } + direction = (direction == true) ? false : true; + } + static int direction_ = 1; + procPos(direction_, alpha, alpha_max); +} + +void ac::GradientReverseVertical(cv::Mat &frame) { + const int w = frame.cols; + const int h = frame.rows; + static bool direction = true; + static double alpha = 1.0, alpha_max = 8; + for(int i = 0; i < w; ++i) { + for(int z = 0; z < h; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + if(direction == true) + pixel[j] += static_cast((z*alpha)); + else + pixel[j] -= static_cast((z*alpha)); + } + ac::swapColors(frame, z, i); + if(isNegative) ac::invert(frame, z, i); + } + direction = (direction == true) ? false : true; + } + static int direction_ = 1; + procPos(direction_, alpha, alpha_max); +} + +void ac::GradientNewFilter(cv::Mat &frame) { + const int w = frame.cols; + const int h = frame.rows; + static int index = 0; + static double alpha = 1.0, alpha_max = 9; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + switch(index) { + case 0: + pixel[j] = static_cast((pixel[j] ^ (int)(alpha*z))); + break; + case 1: + pixel[j] = static_cast((pixel[j] & (int)(alpha*i))); + break; + case 2: + pixel[j] = static_cast((pixel[j] ^ (int)alpha)); + break; + } + } + ac::swapColors(frame, z, i); + if(isNegative) ac::invert(frame, z, i); + ++index; + if(index > 2) index = 0; + } + } + static int direction_ = 1; + procPos(direction_, alpha, alpha_max); +} + +void ac::ReinterpretDouble(cv::Mat &frame) { + const int w = frame.cols; + const int h = frame.rows; + static double alpha = 1.0, alpha_max = 8; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + unsigned char *value = reinterpret_cast(&alpha); + for(int j = 0; j < 3; ++j) + pixel[j] = cv::saturate_cast(pixel[j] ^ value[j]); + + ac::swapColors(frame, z, i); + if(isNegative) ac::invert(frame, z, i); + } + } + static int direction_ = 1; + procPos(direction_, alpha, alpha_max); +} + + +void ac::ReinterpSelfScale(cv::Mat &frame) { + const int w = frame.cols; + const int h = frame.rows; + static int index = 0; + static double alpha = 1.0, alpha_max = 8; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + unsigned char *value = reinterpret_cast(&alpha); + switch(index) { + case 0: { + pixel[0] = static_cast(pixel[0]*alpha)^value[0]; + pixel[1] = static_cast(pixel[1]*alpha); + pixel[2] = static_cast(pixel[2]*alpha); + } + break; + case 1: { + pixel[0] = static_cast(pixel[0]*alpha); + pixel[1] = static_cast(pixel[0]*alpha)^value[1]; + pixel[2] = static_cast(pixel[2]*alpha); + } + break; + case 2: { + pixel[0] = static_cast(pixel[0]*alpha); + pixel[1] = static_cast(pixel[1]*alpha); + pixel[2] = static_cast(pixel[2]*alpha)^value[2]; + } + break; + } + ac::swapColors(frame, z, i); + if(isNegative) ac::invert(frame, z, i); + } + ++index; + if(index > 2) index = 0; + } + static int direction_ = 1; + procPos(direction_, alpha, alpha_max); +} + +void ac::AverageLines(cv::Mat &frame) { + const int w = frame.cols; + const int h = frame.rows; + unsigned char average[3]; + static double alpha = 1.0, alpha_max = 11; + for(int z = 0; z < h; ++z) { + cv::Scalar s(1,1,1); + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + s[0] += pixel[0]; + s[1] += pixel[1]; + s[2] += pixel[2]; + pixel[0] = static_cast((pixel[0]^average[0])*alpha); + pixel[1] = static_cast((pixel[1]^average[1])*alpha); + pixel[2] = static_cast((pixel[2]^average[2])*alpha); + ac::swapColors(frame, z, i); + if(isNegative) ac::invert(frame, z, i); + } + average[0] = cv::saturate_cast((s[0]/w)); + average[1] = cv::saturate_cast((s[1]/w)); + average[2] = cv::saturate_cast((s[2]/w)); + } + int direction = 1; + procPos(direction, alpha, alpha_max); +} + + + +void ac::ColorRange(cv::Mat &frame) { + const int w = frame.cols; + const int h = frame.rows; + static double alpha = 1.0, alpha_max = 6; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast((pixel[j]+colors[j])*alpha); + } + } + static int direction[3] = {1, 0, 1}; + for(int j = 0; j < 3; ++j) { + if(direction[j] == 1) { + colors[j] ++; + if(colors[j] >= 255) { + direction[j] = 0; + colors[j] = 255; + } + } else if(direction[j] == 0) { + colors[j] --; + if(colors[j] <= 0) { + direction[j] = 1; + colors[j] = 0; + } + } + } + + static int _direction = 1; + procPos(_direction, alpha, alpha_max); +} + + +void ac::TrailsInter(cv::Mat &frame) { + static MatrixCollection<8> collection; + collection.shiftFrames(frame); + static int counter = 0; + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel = collection.frames[counter+1].at(z, i); + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + ++counter; + if(counter > 5) counter = 0; + } +} + +void ac::TrailsBlend(cv::Mat &frame) { + static MatrixCollection<8> collection; + cv::Mat new_frame = frame.clone(); + ac::SelfAlphaBlend(new_frame); + collection.shiftFrames(new_frame); + static int counter = 0; + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel = collection.frames[counter].at(z, i); + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + ++counter; + if(counter >= 5) counter = 0; + } +} + +void ac::TrailsNegate(cv::Mat &frame) { + static MatrixCollection<8> collection; + static int index = 0; + cv::Mat new_frame = frame.clone(); + if(index == 0) { + ac::Negate(new_frame); + index = 1; + } else { + index = 0; + } + collection.shiftFrames(new_frame); + static int counter = 0; + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + for(int z = 0; z < h-1; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel = collection.frames[counter].at(z, i); + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + ++counter; + if(counter >= 5) counter = 0; + } +} + +void ac::InterReverse(cv::Mat &frame) { + const int w = frame.cols; + const int h = frame.rows; + bool get_value = true; + static bool value_start = true; + get_value = value_start; + cv::Mat frame_copy = frame.clone(); + for(int z = 2; z < h-2; ++z) { + for(int i = 2; i < w-2; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + if(get_value == true) { + cv::Vec3b value; + value = frame_copy.at(h-z-1, i); + pixel = value; + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + get_value = (get_value == true) ? false : true; + } + value_start = (value_start == true) ? false : true; +} + +void ac::InterMirror(cv::Mat &frame) { + const int w = frame.cols; + const int h = frame.rows; + bool get_value = true; + static bool value_start = true; + get_value = value_start; + cv::Mat frame_copy = frame.clone(); + for(int z = 2; z < h-2; ++z) { + for(int i = 2; i < w-2; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + if(get_value == true) { + cv::Vec3b value; + value = frame_copy.at(h-z-1, i); + cv::Vec3b value2; + value2 = frame_copy.at(z, w-i-1); + cv::Vec3b value3; + value3 = frame_copy.at(h-z-1, w-i-1); + pixel[0] = static_cast(value[0]+value2[0]+value3[0]); + pixel[1] = static_cast(value[1]+value2[1]+value3[1]); + pixel[2] = static_cast(value[2]+value2[2]+value3[2]); + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + get_value = (get_value == true) ? false : true; + } + value_start = (value_start == true) ? false : true; +} + +void ac::InterFullMirror(cv::Mat &frame) { + const int w = frame.cols; + const int h = frame.rows; + int index = 0; + cv::Mat frame_copy = frame.clone(); + for(int z = 2; z < h-2; ++z) { + for(int i = 2; i < w-2; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + switch(index) { + case 0: + continue; + case 1: + pixel = frame_copy.at(h-z-1, i); + break; + case 2: + pixel = frame_copy.at(z, w-i-1); + break; + case 3: + pixel = frame_copy.at(h-z-1, w-i-1); + break; + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + ++index; + if(index > 3) index = 0; + } +} + +void ac::MirrorRGB(cv::Mat &frame) { + const int w = frame.cols; + const int h = frame.rows; + cv::Mat frame_copy = frame.clone(); + for(int z = 2; z < h-2; ++z) { + for(int i = 2; i < w-2; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b frame_pixels[4] = {frame_copy.at(h-z-1, i), frame_copy.at(z, w-i-1), frame_copy.at(h-z-1, w-i-1)}; + for(int j = 0; j < 3; ++j) { + pixel[j] += static_cast(frame_pixels[j][j]); + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } +} + +void ac::RGBStatic1(cv::Mat &frame) { + const int w = frame.cols; + const int h = frame.rows; + static double pos = 0.25; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b add(rand()%255, rand()%255, rand()%255); + for(int j = 0; j < 3; ++j) + pixel[j] += static_cast(add[j] * pos); + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + static int direction = 1; + static double direction_max = 0.4; + if(direction == 1) { + pos += 0.005; + if(pos > direction_max) { + direction = 0; + direction_max += 0.05; + if(direction_max >= 0.8) { + direction_max = 0.5; + } + } + } else if(direction == 0) { + pos -= 0.005; + if(pos <= 0.25) + direction = 1; + } +} + +void ac::RGBStatic2(cv::Mat &frame) { + const int w = frame.cols; + const int h = frame.rows; + static double pos = 0.05; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b add(rand()%255, rand()%255, rand()%255); + for(int j = 0; j < 3; ++j) + pixel[j] += static_cast(add[j] * pos); + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + static int direction = 1; + static double direction_max = 0.4; + if(direction == 1) { + pos += 0.005; + if(pos > direction_max) { + direction = 0; + direction_max += 0.05; + if(direction_max >= 0.9) { + direction_max = 0.4; + } + } + } else if(direction == 0) { + pos -= 0.05; + if(pos <= 0.05) + direction = 1; + } + +} + +void ac::VectorIncrease(cv::Mat &frame) { + const int w = frame.cols; + const int h = frame.rows; + static double pos = 0.25; + static cv::Vec3b value(rand()%255, rand()%255, rand()%255); + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast((pixel[j]*value[j]) * pos); + + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + for(int j = 0; j < 3; ++j) + value[j] += rand()%8; +} + +void ac::LineByLineReverse(cv::Mat &frame) { + const int w = frame.cols; + const int h = frame.rows; + bool rev = false; + cv::Mat frame_copy = frame.clone(); + for(int z = 0; z < h; ++z) { + for(int i = 2; i < w-2; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + if(rev == true) + break; + else + pixel = frame_copy.at(z, (w-i-1)); + + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + rev = (rev == true) ? false : true; + } +} + +void ac::RandomIntertwine(cv::Mat &frame) { + cv::Mat frame1 = frame.clone(), frame2 = frame.clone(); + randomFilter(frame1); + randomFilter(frame2); + const int w = frame.cols; + const int h = frame.rows; + bool rev = false; + for(int z = 0; z < h; ++z) { + for(int i = 2; i < w-2; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + if(rev == true) + pixel = frame1.at(z, i); + else + pixel = frame2.at(z, (w-i-1)); + + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + rev = (rev == true) ? false : true; + } +} + +void ac::RandomFour(cv::Mat &frame) { + cv::Mat frames[4]; + frames[0] = frame; + for(int j = 1; j < 4; ++j) { + frames[j] = frame.clone(); + randomFilter(frames[j]); + } + const int w = frame.cols, h = frame.rows; + static int row = 0; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + if(row == 0) break; + else { + pixel = frames[row].at(z, i); + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + ++row; + if(row > 3) row = 0; + } +} + +void ac::BlendThree(cv::Mat &frame) { + static double pos = 1.0, pos_max = 8.0; + cv::Mat frames[3]; + frames[0] = frame; + for(int j = 1; j < 3; ++j) { + frames[j] = frame.clone(); + randomFilter(frames[j]); + } + const int w = frame.cols, h = frame.rows; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b values[4]; + for(int j = 0; j < 3; ++j) + values[j] = frames[j].at(z, i); + + pixel[0] = values[0][0] + values[1][0] + values[2][0]; + pixel[1] = values[0][1] + values[1][1] + values[2][1]; + pixel[2] = values[0][2] + values[1][2] + values[2][2]; + + for(int j = 0; j < 3; ++j) { + pixel[j] /= 3; + pixel[j] *= static_cast(pos); + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + + static int direction = 1; + procPos(direction, pos, pos_max); +} + +void ac::AcidTrails(cv::Mat &frame) { + const int w = frame.cols, h = frame.rows; + cv::Mat frame_copies[3]; + + for(int j = 0; j < 3; ++j) + frame_copies[j] = frame.clone(); + + ac::SelfScale(frame_copies[0]); + ac::TrailsInter(frame_copies[0]); + ac::Type(frame_copies[1]); + ac::Outward(frame_copies[2]); + + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b copy1 = frame_copies[0].at(z, i); + cv::Vec3b copy2 = frame_copies[1].at(z, i); + cv::Vec3b copy3 = frame_copies[2].at(z, i); + cv::Vec3b value; + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast(((copy1[j] ^ copy2[j]) + copy3[j])); + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } +} + +void ac::RandomTwo(cv::Mat &frame) { + cv::Mat frames[2]; + frames[0] = frame.clone(); + frames[1] = frame.clone(); + randomFilter(frames[0]); + randomFilter(frames[1]); + static int index = 0; + int w = frame.cols, h = frame.rows; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel = frames[index].at(z, i); + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + ++index; + if(index > 1) index = 0; + } +} + +void ac::HorizontalTrailsInter(cv::Mat &frame) { + static MatrixCollection<8> collection; + collection.shiftFrames(frame); + static int counter = 0; + const int w = frame.cols;// frame width + const int h = frame.rows;// frame heigh + for(int i = 0; i < w; ++i) { + for(int z = 0; z < h; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + pixel = collection.frames[counter].at(z, i); + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + ++counter; + if(counter >= 3) counter = 0; + } +} + +void ac::Trails(cv::Mat &frame) { + TrailsInter(frame); + HorizontalTrailsInter(frame); +} + +void ac::BlendTrails(cv::Mat &frame) { + Negate(frame); + rainbowBlend(frame); + Trails(frame); +} + diff --git a/windows/Acid.Cam.Qt.Windows.Project/ac-filter5.cpp b/windows/Acid.Cam.Qt.Windows.Project/ac-filter5.cpp new file mode 100755 index 0000000..0f4cfa9 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/ac-filter5.cpp @@ -0,0 +1,1280 @@ +/* + * Software written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + + +#include"ac.h" + +void ac::RandomFilteredSquare(cv::Mat &frame) { + static std::unique_ptr boxes; + int num_boxes = static_cast(frame.cols/0.5); + if(boxes == 0 || (frame.cols != Box::frame_width)) { + boxes.reset(new Box[num_boxes]); + Box::frame_width = frame.cols; + Box::frame_height = frame.rows; + for(int i = 0; i < num_boxes; ++i) + boxes.get()[i].initBox(frame.cols, frame.rows); + } + + for(int i = 0; i < num_boxes; ++i) { + boxes.get()[i].sizeBox(); + boxes.get()[i].drawBox(frame); + } +} + +void ac::RandomQuads(cv::Mat &frame) { + static MatrixCollection<8> collection; + collection.shiftFrames(frame); + for(int j = 0; j < 4; ++j) { + int frame_index = 0; + do { + frame_index = rand()%28; + } while(frame_index == 13 || frame_index == 14); + ac::draw_func[frame_index](collection.frames[j]); + } + cv::Size quarter(frame.cols/2, frame.rows/2); + ac::copyMat(collection.frames[0],0, 0, frame, ac::Rect(0, 0, quarter)); + ac::copyMat(collection.frames[1],frame.cols/2, 0, frame, ac::Rect(frame.cols/2,0, quarter)); + ac::copyMat(collection.frames[2],frame.cols/2, frame.rows/2, frame, ac::Rect(frame.cols/2, frame.rows/2, quarter)); + ac::copyMat(collection.frames[3],0, frame.rows/2, frame, ac::Rect(0,frame.rows/2, quarter)); +} + +void ac::QuadCosSinMultiply(cv::Mat &frame) { + cv::Mat frame_copy = frame.clone(); + cv::Size quarter(frame.cols/2, frame.rows/2); + DrawFunction procFunc = ac::draw_func[15]; + procFunc(frame_copy); + procFunc(frame_copy); + ac::copyMat(frame_copy,0, 0, frame, ac::Rect(0, 0, quarter)); + procFunc(frame_copy); + ac::copyMat(frame_copy,frame.cols/2, 0, frame, ac::Rect(frame.cols/2,0, quarter)); + procFunc(frame_copy); + ac::copyMat(frame_copy,frame.cols/2, frame.rows/2, frame, ac::Rect(frame.cols/2, frame.rows/2, quarter)); + procFunc(frame_copy); + ac::copyMat(frame_copy,0, frame.rows/2, frame, ac::Rect(0,frame.rows/2, quarter)); +} + +void ac::QuadRandomFilter(cv::Mat &frame) { + + if(testSize(frame) == false) + return; + + cv::Mat frame_copy = frame.clone(); + cv::Size quarter(frame.cols/2, frame.rows/2); + int base_index = 0, index = 0; + DrawFunction baseFilter = getRandomFilter(base_index); + baseFilter(frame_copy); + DrawFunction procFunc = getRandomFilter(index); + procFunc(frame_copy); + ac::copyMat(frame_copy,0, 0, frame, ac::Rect(0, 0, quarter)); + procFunc(frame_copy); + ac::copyMat(frame_copy,frame.cols/2, 0, frame, ac::Rect(frame.cols/2,0, quarter)); + procFunc(frame_copy); + ac::copyMat(frame_copy,frame.cols/2, frame.rows/2, frame, ac::Rect(frame.cols/2, frame.rows/2, quarter)); + procFunc(frame_copy); + ac::copyMat(frame_copy,0, frame.rows/2, frame,ac::Rect(0,frame.rows/2, quarter)); +} + +void ac::RollRandom(cv::Mat &frame) { + + if(testSize(frame) == false) + return; + + SquareVertical_Roll(frame); + int index = 0; + DrawFunction rand_func = getRandomFilter(index); + rand_func(frame); +} + +void ac::AverageRandom(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 8.0; + cv::Mat frame_copy = frame.clone(), frame_copy2 = frame.clone(); + int index = 0; + DrawFunction func = getRandomFilter(index); + func(frame_copy); + func(frame_copy2); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix1 = frame_copy.at(z, i); + cv::Vec3b pix2 = frame_copy2.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast(pixel[j] + pix1[j] + pix2[j]); + pixel[j] /= static_cast(1.5); + pixel[j] = static_cast(pixel[j] * alpha); + } + } + } + static int direction = 1; + procPos(direction, alpha, alpha_max); +} + +void ac::HorizontalStripes(cv::Mat &frame) { + + if(frame.empty() || frame.rows < 25 || frame.cols < 25) + return; + + static cv::Scalar value(1.0, 1.0, 1.0); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + double rval = rand()%10; + double val = rval * 0.001; + value[j] += val; + if(value[j] > 255) value[j] = 0; + pixel[j] = pixel[j] ^ static_cast(value[j]); + } + } + } + MedianBlur(frame); + Bitwise_XOR(frame); +} + +void ac::DiamondStrobe(cv::Mat &frame) { + static double pos = 1.0;// set pos to 1.0 + int w = frame.cols;// frame width + int h = frame.rows;// frame height + static int index1 = 0, index2 = 2; + + ++index1; + if(index1 > 2) index1 = 0; + ++index2; + if(index2 > 2) index2 = 0; + + for(int z = 0; z < h; ++z) {// from top to bottom + for(int i = 0; i < w; ++i) {// from left to right + cv::Vec3b &buffer = frame.at(z, i);// get current pixel + // calculate the colors of the gradient diamonds + if((i%2) == 0) {// if i % 2 equals 0 + if((z%2) == 0) {// if z % 2 equals 0 + // set pixel component values + buffer[index1] = static_cast(1-pos*buffer[0]); + buffer[index2] = static_cast((i+z)*pos); + } else { + // set pixel coomponent values + buffer[index1] = static_cast(pos*buffer[0]-z); + buffer[index2] = static_cast((i-z)*pos); + } + } else { + if((z%2) == 0) {// if z % 2 equals 0 + // set pixel component values + buffer[index1] = static_cast(pos*buffer[0]-i); + buffer[index2] = static_cast((i-z)*pos); + } else { + // set pixel component values + buffer[index1] = static_cast(pos*buffer[0]-z); + buffer[index2] = static_cast((i+z)*pos); + } + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel + } + } + // static direction starts off with 1 + static double pos_max = 7.0f;// pos maximum + static int direction = 1; + procPos(direction, pos, pos_max); +} + +void ac::SmoothTrails(cv::Mat &frame) { + static MatrixCollection<8> collection; + Smooth(frame, &collection); +} + + +void ac::Dual_SelfAlphaRainbow(cv::Mat &frame) { + static double alpha1 = 2.0, alpha2 = 10.0, pos_max = 10.0; + static bool switch_on = true; + rainbowBlend(frame); + for(int z = 0; z < frame.rows-1; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + if(switch_on == true) { + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast(pixel[j]*alpha1); + } else { + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast(pixel[j]*alpha2); + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel + } + switch_on = !switch_on; + } + static int direction[2] = { 1, 0 }; + procPos(direction[0], alpha1, pos_max); + procPos(direction[1], alpha2, pos_max); +} + +void ac::Dual_SelfAlphaBlur(cv::Mat &frame) { + Dual_SelfAlphaRainbow(frame); + MedianBlur(frame); + MedianBlur(frame); + Bitwise_XOR(frame); +} + +void ac::SurroundPixelXor(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 4.0; + for(int z = 0; z < frame.rows-3; ++z) { + for(int i = 0; i < frame.cols-3; ++i) { + cv::Vec3b pix[3]; + cv::Vec3b &pixel = frame.at(z, i); + pix[0] = frame.at(z+1, i); + pix[1] = frame.at(z, i+1); + pix[2] = frame.at(z+1, i+1); + cv::Scalar value; + value[0] = pix[0][0]+pix[1][0]+pix[2][0]; + value[1] = pix[0][1]+pix[1][1]+pix[2][1]; + value[3] = pix[0][2]+pix[1][2]+pix[2][2]; + for(int j = 0; j < 3; ++j) { + int val = static_cast(value[j]); + pixel[j] = static_cast((val^pixel[j])*alpha); + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel + } + } + static int direction = 1; + procPos(direction, alpha, alpha_max); +} + +void ac::Darken(cv::Mat &frame) { + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[0] /= 6; + pixel[1] /= 6; + pixel[2] /= 6; + } + } +} + +void ac::WeakBlend(cv::Mat &frame) { + static int index = 0; + static cv::Scalar value((rand()%5)+1,(rand()%5)+1,(rand()%5)+1); + for(int i = 0; i < frame.cols; ++i) { + for(int z = 0; z < frame.rows; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + int val = static_cast(pixel[j]+(pixel[j]*value[index])); + val /= 2; + pixel[j] = static_cast(val); + } + index ++; + if(index > 2) + index = 0; + + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel + } + } + for(int j = 0; j < 3; ++j) { + value[j] += 1+((rand()%5) * 0.5); + if(value[j] > 10) { + value[j] = rand()%10; + } + } +} + +void ac::AverageVertical(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 8.0; + std::unique_ptr values(new cv::Scalar[frame.rows]); + for(int i = 0; i < frame.cols; ++i) { + for(int z = 0; z < frame.rows; ++z) { + cv::Vec3b pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + values.get()[z][j] += pixel[j]; + } + } + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Scalar val = values.get()[z]; + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + val[j] /= frame.rows; + pixel[j] += static_cast(val[j]*alpha); + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel + } + } + static int direction = 1; + procPos(direction, alpha, alpha_max); +} + + +void ac::RandomCollectionAverage(cv::Mat &frame) { + + if(testSize(frame) == false) + return; + + static MatrixCollection<8> collection; + int index = 0; + DrawFunction randF = getRandomFilter(index); + randF(frame); + Smooth(frame, &collection); +} + +void ac::RandomCollectionAverageMax(cv::Mat &frame) { + + if(testSize(frame) == false) + return; + + static MatrixCollection<16> collection; + int index = 0; + DrawFunction randF = getRandomFilter(index); + randF(frame); + Smooth(frame, &collection); +} + +void ac::SmoothTrailsSelfAlphaBlend(cv::Mat &frame) { + static MatrixCollection<8> collection; + MedianBlur(frame); + SelfAlphaBlend(frame); + Smooth(frame, &collection); +} + +void ac::SmoothTrailsRainbowBlend(cv::Mat &frame) { + static MatrixCollection<8> collection; + MedianBlur(frame); + rainbowBlend(frame); + Smooth(frame, &collection); +} + +void ac::MedianBlend(cv::Mat &frame) { + static MatrixCollection<8> collection; + int r = 3+rand()%7; + for(int i = 0; i < r; ++i) + MedianBlur(frame); + + collection.shiftFrames(frame); + static double alpha = 1.0, alpha_max = 3.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Scalar value; + for(int j = 0; j < collection.size(); ++j) { + cv::Vec3b pixel = collection.frames[j].at(z, i); + for(int q = 0; q < 3; ++q) { + value[q] += pixel[q]; + } + } + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + int val = 1+static_cast(value[j]); + pixel[j] = static_cast(pixel[j] ^ val); + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int direction = 1; + procPos(direction, alpha, alpha_max); +} + + + + +void ac::RandomAlphaBlend(cv::Mat &frame) { + static MatrixCollection<8> collection; + double alpha = 1.0, alpha_max = 6.0; + int index = 0; + + if(testSize(frame) == false) + return; + + DrawFunction randFunc = getRandomFilter(index); + cv::Mat temp = frame.clone(), rand_frame = frame.clone(); + randFunc(rand_frame); + collection.shiftFrames(rand_frame); + AlphaBlend(temp,rand_frame, frame, alpha); + Smooth(frame, &collection); + static int direction = 1; + procPos(direction, alpha, alpha_max); +} + +void ac::RandomTwoFilterAlphaBlend(cv::Mat &frame) { + /* + static double alpha = 1.0, alpha_max = 5.0; + static MatrixCollection<8> collection; + cv::Mat one, two, output; + one = frame.clone(); + two = frame.clone(); + int index = 0; + DrawFunction randFunc1 = getRandomFilter(index); + DrawFunction randFunc2 = getRandomFilter(index); + randFunc1(one); + randFunc2(two); + AlphaBlend(one, two, output, alpha); + collection.shiftFrames(output); + Smooth(frame, &collection); + static int direction = 1; + procPos(direction, alpha, alpha_max); + */ +} + +void ac::PixelatedSquare(cv::Mat &frame) { + static MatrixCollection<8> collection; + static double alpha = 1.0, alpha_max = 3.0; + cv::Mat filter_1 = frame.clone(); + cv::Mat frame_copy; + SurroundPixelXor(filter_1); + GridFilter16x(filter_1); + + AlphaBlend(filter_1,frame,frame_copy,alpha); + collection.shiftFrames(frame_copy); + Smooth(frame, &collection); + static int direction = 1; + procPos(direction, alpha, alpha_max); +} + +void ac::AlphaBlendPosition(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 4.0; + int pos_x = 0; + for(int z = 0; z < frame.rows; ++z) { + cv::Vec3b pix = frame.at(z, pos_x); + ++pos_x; + if(pos_x > frame.cols-1) pos_x = 0; + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast((pixel[j]*alpha)+(pix[j]*alpha)); + + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel + } + } + static int direction = 1; + procPos(direction, alpha, alpha_max); +} + +void ac::BlendRowAlpha(cv::Mat &frame) { + static int row = 0; + static double alpha = 1.0, alpha_max = 4.0; + for(int i = 0; i < frame.cols; ++i) { + row++; + if(row > frame.cols) row = 0; + for(int z = 0; z < frame.rows; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast((pixel[j] ^ row)*alpha); + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel + } + } + static int direction = 1; + procPos(direction, alpha, alpha_max); +} + +void ac::BlendRow(cv::Mat &frame) { + static int row = 0; + for(int i = 0; i < frame.cols; ++i) { + row++; + if(row > frame.cols) row = 0; + for(int z = 0; z < frame.rows; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast(pixel[j] ^ row); + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel + } + } +} + +void ac::BlendRowByVar(cv::Mat &frame) { + static int row = 0; + for(int i = 0; i < frame.cols; ++i) { + row++; + if(row > frame.cols) row = 0; + for(int z = 0; z < frame.rows; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast((pixel[j]+(z-i)) ^ row); + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel + } + } +} + +void ac::BlendRowByDirection(cv::Mat &frame) { + static int row = 0; + static int direction = 1; + for(int i = 0; i < frame.cols; ++i) { + if(direction == 1) { + ++row; + if(row > frame.cols) + direction = 0; + } else if(direction == 0) { + --row; + if(row <= 0) { + direction = 1; + } + } + for(int z = 0; z < frame.rows; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + if(direction == 1) + pixel[j] = static_cast((pixel[j]+i+z) & row); + else if(direction == 0) + pixel[j] = static_cast((pixel[j]^row)); + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } +} + +void ac::BlendAlphaXor(cv::Mat &frame) { + static int r = 3; + static int direction = 1; + static double alpha = 1.0, alpha_max = 10.0; + for(int i = 0; i < frame.cols; ++i) { + for(int z = 0; z < frame.rows; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + unsigned char val = static_cast(r*alpha); + pixel[j] += cv::saturate_cast(pixel[j]^val); + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + if(direction == 1) { + ++r; + if(r >= 255) + direction = 0; + } else if(direction == 0) { + --r; + if(r <= 3) + direction = 1; + } + static int dir = 1; + procPos(dir, alpha, alpha_max); +} + +void ac::SelfXorScale(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 8.0; + static int value = 1; + for(int i = 0; i < frame.cols; ++i) { + for(int z = 0; z < frame.rows; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast((pixel[j]^value)*alpha); + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int direction = 1; + if(direction == 1) { + ++value; + if(value > 254) + direction = 0; + } else if(direction == 0) { + --value; + if(value <= 1) + direction = 1; + } + static int dir = 1; + procPos(dir, alpha, alpha_max); +} + +void ac::BitwiseXorScale(cv::Mat &frame) { + static cv::Mat frame1 = frame.clone(); + cv::Mat temp = frame.clone(); + + if(frame1.size()!=frame.size()) + frame1 = temp.clone(); + + static double alpha = 1.0, alpha_max = 2.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame1.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] += static_cast((pixel[j]^pix[j])*alpha); + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + frame1 = temp; + static int direction = 1; + procPos(direction, alpha, alpha_max); +} + +void ac::XorTrails(cv::Mat &frame) { + static MatrixCollection<8> collection; + collection.shiftFrames(frame); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b value; + for(int j = 0; j < collection.size(); ++j) { + cv::Vec3b frame_val = collection.frames[j].at(z, i); + for(int q = 0; q < 3; ++q) { + value[q] ^= frame_val[q]; + } + } + for(int j = 0; j < 3; ++j) + pixel[j] = pixel[j]^value[j]; + + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } +} + +void ac::RainbowTrails(cv::Mat &frame) { + static MatrixCollection<8> collection; + collection.shiftFrames(frame); + for(int i = 0; i < frame.cols; ++i) { + for(int z = 0; z < frame.rows; ++z) { + cv::Vec3b value; + cv::Vec3b &pixel = frame.at(z, i);; + for(int j = 1; j < collection.size(); ++j) { + cv::Vec3b frame_val = collection.frames[j].at(z, i); + for(int q = 0; q < 3; ++q) { + value[q] += frame_val[q]; + } + } + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j]^value[j]; + } + } + } +} +void ac::NegativeTrails(cv::Mat &frame) { + static MatrixCollection<8> collection; + static double alpha = 1.0, alpha_max = 8.0; + collection.shiftFrames(frame); + for(int i = 0; i < frame.cols; ++i) { + for(int z = 0; z < frame.rows; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b value; + for(int j = 0; j < collection.size(); ++j) { + cv::Vec3b frame_val = collection.frames[j].at(z, i); + for(int q = 0; q < 3; ++q) { + pixel[q] ^= pixel[q]+frame_val[q]; + } + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); +} + +void ac::IntenseTrails(cv::Mat &frame) { + static MatrixCollection<8> collection; + collection.shiftFrames(frame); + static double alpha = 1.0, alpha_max = 8.0; + for(int i = 0; i < frame.cols; ++i) { + for(int z = 0; z < frame.rows; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b value = pixel; + for(int j = 0; j < collection.size(); ++j) { + cv::Vec3b frame_val = collection.frames[j].at(z, i); + for(int q =0; q < 3; ++q) { + value[q] += static_cast(frame_val[q]*alpha); + + } + } + for(int j = 0; j < 3; ++j) + pixel[j] ^= value[j]; + + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); +} + +void ac::SelfAlphaRGB(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 3.0; + static int index = 0; + for(int i = 0; i < frame.cols-2; ++i) { + for(int z = 0; z < frame.rows-2; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix[4]; + pix[0] = frame.at(z+1, i+1); + pix[1] = frame.at(z+1, i); + pix[2] = frame.at(z, i+1); + pix[3] = pixel; + switch(index) { + case 0: + pixel[0] = static_cast(pix[0][0]*alpha); + pixel[1] = static_cast((pix[0][1]+pix[1][1])*alpha); + pixel[2] = static_cast((pix[0][2]+pix[1][2]+pix[2][2])*alpha); + break; + case 1: + pixel[2] = static_cast(pix[0][0]*alpha); + pixel[1] = static_cast((pix[0][1]+pix[1][1])*alpha); + pixel[0] = static_cast((pix[0][2]+pix[1][2]+pix[2][2])*alpha); + break; + case 2: + pixel[1] = static_cast(pix[0][0]*alpha); + pixel[0] = static_cast((pix[0][1]+pix[1][1])*alpha); + pixel[2] = static_cast((pix[0][2]+pix[1][2]+pix[2][2])*alpha); + break; + case 3: + pixel[0] = pixel[0]^static_cast(pix[0][0]*alpha); + pixel[1] = pixel[1]^static_cast((pix[0][1]+pix[1][1])*alpha); + pixel[2] = pixel[2]^static_cast((pix[0][2]+pix[1][2]+pix[2][2])*alpha); + break; + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); + + ++index; + if(index > 3) index = 0; +} + + +void ac::BitwiseXorStrobe(cv::Mat &frame) { + static int index = 0; + static double alpha1 = 1.0, alpha2 = 10.0, alpha3 = 5.0,alpha_max = 3.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + switch(index) { + case 0: + pixel[0] += cv::saturate_cast(pixel[0] * alpha1); + pixel[1] += cv::saturate_cast(pixel[1] * alpha2); + pixel[2] += cv::saturate_cast(pixel[2] * alpha3); + break; + case 1: + pixel[2] += cv::saturate_cast(pixel[0] * alpha1); + pixel[0] += cv::saturate_cast(pixel[1] * alpha2); + pixel[1] += cv::saturate_cast(pixel[2] * alpha3); + break; + case 2: + pixel[1] += cv::saturate_cast(pixel[0] * alpha1); + pixel[2] += cv::saturate_cast(pixel[1] * alpha2); + pixel[0] += cv::saturate_cast(pixel[2] * alpha3); + break; + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int dir1 = 1, dir2 = 0, dir3 = 1; + procPos(dir1, alpha1, alpha_max); + procPos(dir2, alpha2, alpha_max); + procPos(dir3, alpha3, alpha_max); + + ++index; + if(index > 2) index = 0; + Bitwise_XOR(frame); +} + + +void ac::AlphaBlendRandom(cv::Mat &frame) { + + if(testSize(frame) == false) + return; + + static double val = 0.30; + static int val_dir = 1; + int index = 0; + DrawFunction func[2]; + func[0] = getRandomFilter(index); + func[1] = getRandomFilter(index); + cv::Mat copy[4]; + copy[0] = frame.clone(); + copy[1] = frame.clone(); + copy[2] = frame.clone(); + func[0](copy[0]); + func[1](copy[1]); + AlphaBlend(copy[0], copy[1], copy[3], 0.5); + AlphaBlend(copy[2], copy[3], frame, val); + if(val_dir == 1) { + val += 0.05; + if(val >= 1.0) + val_dir = 0; + } else { + val -= 0.05; + if(val <= 0.30) + val_dir = 1; + } +} + +void ac::ChannelSortAlphaBlend(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 3.0; + static int index = 0; + std::vector v; // to hold the Matrix for split + cv::split(frame, v);// split the channels into seperate matrices + cv::Mat channels[3]; // output channels + cv::Mat output; // for merge + cv::sort(v[0], channels[0],cv::SORT_ASCENDING); // sort each matrix + cv::sort(v[1], channels[1],cv::SORT_ASCENDING); + cv::sort(v[2], channels[2],cv::SORT_ASCENDING); + cv::sort(v[index], channels[index], cv::SORT_DESCENDING); + cv::merge(channels, 3, output); + ++index; + if(index > 2) index = 0; + cv::Mat copy = frame.clone(); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pixadd = output.at(z, i); + for(int j = 0; j < 3; ++j) { + //pixel += pixadd; + pixel[j] = static_cast((pixel[j] * alpha) + (pixadd[j] * alpha)); + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 10, 0.01); +} + +void ac::XorChannelSort(cv::Mat &frame) { + std::vector v; // to hold the Matrix for split + cv::split(frame, v);// split the channels into seperate matrices + cv::Mat channels[3]; // output channels + cv::Mat output; // for merge + cv::sort(v[0], channels[0],(((rand()%2) == 0) ? cv::SORT_ASCENDING : cv::SORT_DESCENDING)); // sort each matrix + cv::sort(v[1], channels[1],(((rand()%2) == 0) ? cv::SORT_ASCENDING : cv::SORT_DESCENDING)); // sort each matrix + cv::sort(v[2], channels[2],(((rand()%2) == 0) ? cv::SORT_ASCENDING : cv::SORT_DESCENDING)); // sort each matrix + cv::merge(channels, 3, output); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b sorted = output.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = pixel[j] ^ sorted[j]; + + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } +} + +void ac::GradientColors(cv::Mat &frame) { + static int index = 0; + static unsigned char val = 0; + int inc = (frame.rows/255)+1; + for(int i = 0; i < frame.cols; ++i) { + val = 1; + for(int z = 0; z < frame.rows; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[index] = val; + if((z%inc) == 0) + ++val; + + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + ++index; + if(index > 2) + index = 0; +} + +void ac::GradientColorsVertical(cv::Mat &frame) { + static int index = 0; + static unsigned char val = 0; + int inc = (frame.cols/255)+1; + for(int z = 0; z < frame.rows; ++z) { + val = 1; + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[index] = val; + + if((i%inc) == 0) + ++val; + + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + ++index; + if(index > 2) + index = 0; +} + +void ac::Bitwise_XOR_Average(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 8.0; + for(int z = 0; z < frame.rows; ++z) { + cv::Scalar sval; + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + sval[j] += pixel[j]; + } + } + + for(int j = 0; j < 3; ++j) + sval[j] /= frame.cols; + + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast((pixel[j] * alpha) + (static_cast(sval[j])*alpha)); + + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 0.01); + Bitwise_XOR(frame); +} + +void ac::NotEqual(cv::Mat &frame) { + + static MatrixCollection<2> collection; + collection.shiftFrames(frame); + static double alpha = 1.0, alpha_max = 3.0; + + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + bool same_value = true; + cv::Vec3b value; + for(int j = 0; j < collection.size(); ++j) { + value = collection.frames[j].at(z, i); + if(value != pixel) { + same_value = false; + break; + } + } + if(same_value == false) { + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast((pixel[j] * alpha) + (value[j] * alpha)); + } + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 0.10); +} + +void ac::GradientXorSelfScale(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 3.0; + for(int z = 0; z < frame.rows-1; ++z) { + for(int i = 0; i < frame.cols-1; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame.at(z+1, i+1); + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast((pixel[j] * alpha)) ^ pix[j]; + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 10, 0.03); +} + +void ac::SmoothSourcePixel(cv::Mat &frame) { + static MatrixCollection<8> collection; + static double alpha = 1.0, alpha_max = 3.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + int total = pixel[0]+pixel[1]+pixel[2]/3; + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast(((pixel[j] ^ total) * static_cast(alpha))); + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 15, 0.1); + collection.shiftFrames(frame); + Smooth(frame, &collection); +} + +void ac::StrobeBlend(cv::Mat &frame) { + int value1 = ((frame.cols/2)/255)+1; + int num = 1, num2 = 1; + static double alpha = 1.0, alpha_max = 8.0; + static int index1 = 0, index2 = 2; + static int frame_num = 0; + + ++frame_num; + if(frame_num > 1) frame_num = 0; + + for(int z = 0; z < frame.rows; ++z) { + num = 1; + num2 = 1; + for(int i = 0; i < frame.cols/2; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + if((i%value1)==0) + num++; + if(frame_num == 0) { + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j] ^ static_cast(num); + } + } else { + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j] ^ static_cast(num/(alpha+1)); + } + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + //pixel[index1]= 255; + } + for(int i = frame.cols/2; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + if((i%value1)==0) + num2++; + if(frame_num == 0) { + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j] ^ static_cast(num2); + } + } else { + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j] ^ static_cast(num2/(alpha+1)); + } + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + //pixel[index2] = 0; + } + } + if(++index1 > 2) index1 = 0; + if(--index2 < 0) index2 = 2; + static int dir = 1; + procPos(dir, alpha, alpha_max, 15, 0.03); +} + +void ac::FrameBars(cv::Mat &frame) { + int diff_i = (frame.cols/255)+1; + int diff_z = (frame.rows/255)+1; + unsigned char val[2] = {0,0}; + static double alpha = 1.0, alpha_max = 8.0; + static MatrixCollection<4> collection; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] += static_cast(val[0]*alpha) + static_cast(val[1]*alpha); + + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + + if((i%diff_i) == 0) { + val[0]++; + } + } + if((z%diff_z) == 0) { + val[1]++; + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); + collection.shiftFrames(frame); + Smooth(frame, &collection); +} + +void ac::Sort_Vertical_Horizontal(cv::Mat &frame) { + cv::Mat value = frame.clone(); + VerticalChannelSort(value); + ChannelSort(value); + Add(frame, value, false); + +} + +void ac::Sort_Vertical_Horizontal_Bitwise_XOR(cv::Mat &frame) { + cv::Mat value = frame.clone(); + VerticalChannelSort(value); + ChannelSort(value); + static bool sub = false; + if(sub == false) + Add(frame, value, false); + else + Sub(frame, value, false); + sub = (sub == true) ? false : true; + Bitwise_XOR(frame); +} + + +void ac::Scalar_Average_Multiply(cv::Mat &frame) { + cv::Mat copy = frame.clone(); + VerticalChannelSort(frame); + cv::Scalar average; + ScalarAverage(frame, average); + Transform(copy, frame, [&](cv::Vec3b &pixel, int , int ) { + for(int j = 0; j < 3; ++j) { + pixel[j] *= static_cast(average[j]); + } + }); + cv::Mat out = frame.clone(); + AlphaBlend(out, copy, frame, 0.5); +} + +void ac::Scalar_Average(cv::Mat &frame) { + cv::Mat copy = frame.clone(); + cv::Scalar value; + ScalarAverage(frame, value); + Transform(copy, frame,[&](cv::Vec3b &pixel, int , int ) { + for(int j = 0; j < 3; ++j) + pixel[j] *= static_cast(value[j]); + }); + cv::Mat out = frame.clone(); + AlphaBlend(copy, out, frame, 0.5); +} + +void ac::Total_Average(cv::Mat &frame) { + cv::Mat frames[3]; + static double alpha = 1.0, alpha_max = 8.0; + frames[0] = frame.clone(); + frames[1] = frame.clone(); + frames[2] = frame.clone(); + + SelfScale(frames[0]); + rainbowBlend(frames[1]); + SelfAlphaRGB(frames[2]); + + unsigned long total[3]; + + for(int j = 0; j < 3; ++j) + TotalAverageOffset(frames[j], total[j]); + + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] += static_cast((alpha*total[j])); + + swapColors(frame, z, i); + // if isNegative true invert pixel + if(isNegative) invert(frame, z, i); + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); + +} + +void ac::FlashWhite(cv::Mat &frame) { + static cv::Vec3b white(255,255,255); + static bool state = false; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + if(state) + frame.at(z, i) = white; + } + } + state = (state == true) ? false : true; +} + +void ac::FlashBlackAndWhite(cv::Mat &frame) { + static int index = 0; + static cv::Vec3b white(255,255,255), black(0,0,0); + if(index != 1 && index != 3) { + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + switch(index) { + case 0: + frame.at(z, i) = white; + break; + case 2: + frame.at(z, i) = black; + } + } + } + } + ++index; + if(index > 3) index = 0; +} + +void ac::GaussianBlend(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 3.0; + static MatrixCollection<8> collection; + unsigned int r = rand()%10; + for(unsigned int q = 0; q < r; ++q) + GaussianBlur(frame); + + collection.shiftFrames(frame); + int value[3] = { rand()%255, rand()%255, rand()%255 }; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast((pixel[j] ^ value[j]) * alpha); + + swapColors(frame, z, i); + // if isNegative true invert pixel + if(isNegative) invert(frame, z, i); + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 15, 0.1); + collection.shiftFrames(frame); + Smooth(frame, &collection); + +} + +void ac::RandomXor(cv::Mat &frame) { + int r_color[3] = { rand()%255, rand()%255, rand()%255 }; + static double alpha = 1.0, alpha_max = 3.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast((pixel[j] ^ r_color[j]) * alpha); + + swapColors(frame, z, i); + // if isNegative true invert pixel + if(isNegative) invert(frame, z, i); + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); + +} + diff --git a/windows/Acid.Cam.Qt.Windows.Project/ac-filter6.cpp b/windows/Acid.Cam.Qt.Windows.Project/ac-filter6.cpp new file mode 100755 index 0000000..1ee43f9 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/ac-filter6.cpp @@ -0,0 +1,1287 @@ +/* + * Software written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + + +#include"ac.h" + +double blend_percentage = 0.5; + +void ac::RandomXorFlash(cv::Mat &frame) { + static int index = 0; + int col_p[3] = { rand()%255, rand()%255, rand()%255 }; + int col_x[3] = { rand()%255, rand()%255, rand()%255 }; + static double alpha = 1.0, alpha_max = 3.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + switch(index) { + case 0: + pixel[j] = static_cast(pixel[j] ^ ((col_p[j] ^ col_x[j]) * static_cast(alpha))); + break; + case 1: + pixel[j] = static_cast(pixel[j] ^ col_p[j]); + break; + case 2: + pixel[j] = static_cast(pixel[j] ^ (col_p[j]+col_x[j])); + break; + } + } + swapColors(frame, z, i); + // if isNegative true invert pixel + if(isNegative) invert(frame, z, i); + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); + + ++index; + if(index > 2) index = 0; +} + +void ac::RandomAmountMedianBlur(cv::Mat &frame) { + int random = rand()%10; + for(int j = 0; j < random; ++j) + MedianBlur(frame); +} + +void ac::SoftXor(cv::Mat &frame) { + static MatrixCollection<4> collection; + RandomAmountMedianBlur(frame); + collection.shiftFrames(frame); + double alpha = 1.0, alpha_max = 3.0; + + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Scalar s; + for(int q = 0; q < collection.size(); ++q) { + cv::Vec3b val = collection.frames[q].at(z, i); + unsigned char v[3] = { static_cast(s[0]), static_cast(s[1]), static_cast(s[2])}; + s[0] = (v[0] + val[0]) ^ static_cast(s[0]); + s[1] = (v[1] + val[1]) ^ static_cast(s[1]); + s[2] = (v[2] + val[2]) ^ static_cast(s[2]); + } + + s[0] /= (collection.size()); + s[1] /= (collection.size()); + s[2] /= (collection.size()); + + for(int j = 0; j < 3; ++j) { + unsigned char v = static_cast(s[j]); + pixel[j] = static_cast((pixel[j] ^ v) * static_cast(alpha)); + } + + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + + static int dir = 1; + procPos(dir, alpha, alpha_max, 8.0, 0.1); + +} + +void ac::SelfXorBlend(cv::Mat &frame) { + static unsigned char index[3] = {static_cast(rand()%255), static_cast(rand()%255), static_cast(rand()%255)}; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j] ^ index[j]; + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + for(int j = 0; j < 3; ++j) + ++index[j]; +} + +void ac::SelfXorDoubleFlash(cv::Mat &frame) { + static double alpha = 1.0; + int r[3] = {rand()%255,rand()%255,rand()%255}; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = pixel[j] ^ (static_cast(alpha)+r[j]); + + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int dir = 1; + if(dir == 1) { + alpha += alpha_increase; + if(alpha > 255) + dir = 0; + } else { + alpha -= alpha_increase; + if(alpha <= 0) + dir = 1; + } +} + +void ac::SelfOrDoubleFlash(cv::Mat &frame) { + static double alpha = 1.0; + int r[3] = {rand()%255,rand()%255,rand()%255}; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = pixel[j] | (static_cast(alpha) ^ r[j]); + + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int dir = 1; + if(dir == 1) { + alpha += alpha_increase; + if(alpha > 255) + dir = 0; + } else { + alpha -= alpha_increase; + if(alpha <= 0) + dir = 1; + } +} + +void ac::BlendRowCurvedSqrt(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 3.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + double amount = sqrt(i*z); + pixel[j] = static_cast((pixel[j]^static_cast(amount))*alpha); + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); +} + +void ac::CycleShiftRGB(cv::Mat &frame) { + static int offset[3] = {0, ((frame.cols/2)/2), (frame.cols/2)}; + if(reset_filter == true) { + offset[0] = 0; + offset[1] = ((frame.cols/2)/2); + offset[2] = (frame.cols/2); + reset_filter = false; + } + cv::Mat frame_copy = frame.clone(); + for(int z = 0; z < frame.rows; ++z) { + for(int j = 0; j < 3; ++j) { + for(int i = 0; i < offset[j]; ++i) { + if(i >= 0 && i < frame.cols) { + if(offset[j]-i-1 >= 0 && offset[j]-i-1 < frame.cols) { + cv::Vec3b &pixel = frame.at(z, offset[j]-i-1); + cv::Vec3b pix_copy = frame_copy.at(z, i); + pixel[j] = pix_copy[j]; + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + } + int index = 0; + for(int i = offset[j]; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix_copy = frame_copy.at(z, index); + pixel[j] = pix_copy[j]; + ++index; + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + + } + } + for(int j = 0; j < 3; ++j) { + ++offset[j] += 50; + if(offset[j] > frame.cols) + offset[j] = 0; + } +} + +void ac::CycleShiftRandomRGB(cv::Mat &frame) { + static int offset[3] = {0, ((frame.cols/2)/2), (frame.cols/2)}; + static bool lazy = false; + if(reset_filter == true || lazy == false) { + switch(rand()%2) { + case 0: + offset[0] = 0; + offset[1] = ((frame.cols/2)/2); + offset[2] = (frame.cols/2); + break; + case 1: + offset[2] = 0; + offset[0] = ((frame.cols/2)/2); + offset[1] = (frame.cols/2); + break; + default: + offset[1] = 0; + offset[2] = ((frame.cols/2)/2); + offset[0] = (frame.cols/2); + break; + } + lazy = true; + reset_filter = false; + } + cv::Mat frame_copy = frame.clone(); + for(int z = 0; z < frame.rows; ++z) { + for(int j = 0; j < 3; ++j) { + for(int i = 0; i < offset[j]; ++i) { + if(i >= 0 && i < frame.cols) { + if(offset[j]-i-1 >= 0 && offset[j]-i-1 < frame.cols) { + cv::Vec3b &pixel = frame.at(z, offset[j]-i-1); + cv::Vec3b pix_copy = frame_copy.at(z, i); + pixel[j] = pix_copy[j]; + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + int index = 0; + for(int i = offset[j]; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix_copy = frame_copy.at(z, index); + pixel[j] = pix_copy[j]; + ++index; + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + } + for(int j = 0; j < 3; ++j) { + ++offset[j] += 50; + if(offset[j] > frame.cols) + offset[j] = 0; + } +} + +void ac::CycleShiftRandomRGB_XorBlend(cv::Mat &frame) { + static int offset[3] = {0, ((frame.cols/2)/2), (frame.cols/2)}; + static bool lazy = false; + if(reset_filter == true || lazy == false) { + switch(rand()%2) { + case 0: + offset[0] = 0; + offset[1] = ((frame.cols/2)/2); + offset[2] = (frame.cols/2); + break; + case 1: + offset[2] = 0; + offset[0] = ((frame.cols/2)/2); + offset[1] = (frame.cols/2); + break; + default: + offset[1] = 0; + offset[2] = ((frame.cols/2)/2); + offset[0] = (frame.cols/2); + break; + } + lazy = true; + reset_filter = false; + } + cv::Mat frame_copy = frame.clone(); + for(int z = 0; z < frame.rows; ++z) { + for(int j = 0; j < 3; ++j) { + for(int i = 0; i < offset[j]; ++i) { + if(i >= 0 && i < frame.cols) { + if(offset[j]-i-1 >= 0 && offset[j]-i-1 < frame.cols) { + cv::Vec3b &pixel = frame.at(z, offset[j]-i-1); + cv::Vec3b pix_copy = frame_copy.at(z, i); + pixel[j] ^= pix_copy[j]; + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + } + int index = 0; + for(int i = offset[j]; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix_copy = frame_copy.at(z, index); + pixel[j] ^= pix_copy[j]; + ++index; + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + } + for(int j = 0; j < 3; ++j) { + ++offset[j] += 50; + if(offset[j] > frame.cols) + offset[j] = 0; + } +} + +void ac::CycleShiftRandomAlphaBlend(cv::Mat &frame) { + static double alpha[3] = {1.0,4.0,2.5}, alpha_max = 3.0; + static int offset[3] = {0, ((frame.cols/2)/2), (frame.cols/2)}; + static bool lazy = false; + if(reset_filter == true || lazy == false) { + switch(rand()%2) { + case 0: + offset[0] = 0; + offset[1] = ((frame.cols/2)/2); + offset[2] = (frame.cols/2); + break; + case 1: + offset[2] = 0; + offset[0] = ((frame.cols/2)/2); + offset[1] = (frame.cols/2); + break; + default: + offset[1] = 0; + offset[2] = ((frame.cols/2)/2); + offset[0] = (frame.cols/2); + break; + } + lazy = true; + reset_filter = false; + alpha[0] = 1.0; + alpha[1] = 4.0; + alpha[2] = 2.5; + } + cv::Mat frame_copy = frame.clone(); + for(int z = 0; z < frame.rows; ++z) { + for(int j = 0; j < 3; ++j) { + for(int i = 0; i < offset[j]; ++i) { + if(i >= 0 && i < frame.cols) { + if(offset[j]-i-1 >= 0 && offset[j]-i-1 < frame.cols) { + cv::Vec3b &pixel = frame.at(z, offset[j]-i-1); + cv::Vec3b pix_copy = frame_copy.at(z, i); + pixel[j] = static_cast((pixel[j] * alpha[j]) + (pix_copy[j] * alpha[j])); + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + } + int index = 0; + for(int i = offset[j]; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix_copy = frame_copy.at(z, index); + pixel[j] = static_cast((pixel[j] * alpha[j]) + (pix_copy[j] * alpha[j])); + ++index; + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + } + + static int dir[3] = {1,0,1}; + for(int j = 0; j < 3; ++j) { + ++offset[j] += 50; + if(offset[j] > frame.cols) + offset[j] = 0; + + procPos(dir[j], alpha[j], alpha_max, 6, 0.03); + } +} + +void ac::VerticalColorBars(cv::Mat &frame) { + static double alpha[3] = { 1.0, 3.0, 7.0}, alpha_max = 3.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast(pixel[j]^(i)*static_cast(alpha[j])); + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int dir[3] = { 1,1,0 }; + for(int j = 0; j < 3; ++j) + procPos(dir[j], alpha[j], alpha_max,10.0, 0.3); +} + +void ac::GradientLeftRight(cv::Mat &frame) { + static double inc[3] = {1, 25, 50}, alpha_max = 3.0; + for(int z = 0; z < frame.rows; ++z) { + double amt[3] = {5, 16, 30}; + for(int i = 0; i < frame.cols/2; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] += static_cast(amt[j]); + amt[j] += inc[j]; + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + for(int i = frame.cols/2; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] -= static_cast(amt[j]); //static_cast(amt); + amt[j] -= inc[j]; + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int dir[3] = {1, 1, 1}; + for(int j = 0; j < 3; ++j) { + procPos(dir[j], inc[j], alpha_max, 10, 0.1); + } +} + +void ac::GraidentUpDown(cv::Mat &frame) { + static double inc[3] = {1, 25, 50}, alpha_max = 3.0; + for(int i = 0; i < frame.cols; ++i) { + double amt[3] = {5, 16, 30}; + for(int z = 0; z < frame.rows/2; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] += static_cast(amt[j]); + amt[j] += inc[j]; + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + for(int z = frame.rows/2; z < frame.rows; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] -= static_cast(amt[j]); + amt[j] -= inc[j]; + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int dir[3] = {1, 1, 1}; + for(int j = 0; j < 3; ++j) { + procPos(dir[j], inc[j], alpha_max, 10, 0.1); + } +} + +void ac::GradientLeftRightInOut(cv::Mat &frame) { + static double inc[3] = {1, 25, 50}, alpha_max = 3.0; + static int dir[3] = {1, 0, 1}; + for(int z = 0; z < frame.rows; ++z) { + double amt[3] = {5, 16, 30}; + for(int i = 0; i < frame.cols/2; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + if(dir[j] == 0) { + pixel[j] += static_cast(amt[j]); + amt[j] += inc[j]; + } else { + pixel[j] -= static_cast(amt[j]); + amt[j] -= inc[j]; + } + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + for(int i = frame.cols/2; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + if(dir[j] == 1) { + pixel[j] += static_cast(amt[j]); + amt[j] += inc[j]; + } else { + pixel[j] -= static_cast(amt[j]); + amt[j] -= inc[j]; + } + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + for(int j = 0; j < 3; ++j) { + procPos(dir[j], inc[j], alpha_max, 10, 0.1); + } +} + +void ac::GradientUpDownInOut(cv::Mat &frame) { + static double inc[3] = {1, 25, 50}, alpha_max = 3.0; + static int dir[3] = {1, 0, 1}; + for(int i = 0; i < frame.cols; ++i) { + double amt[3] = {5, 16, 30}; + for(int z = 0; z < frame.rows/2; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + if(dir[j] == 0) { + pixel[j] += static_cast(amt[j]); + amt[j] += inc[j]; + } else { + pixel[j] -= static_cast(amt[j]); + amt[j] -= inc[j]; + } + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + for(int z = frame.rows/2; z < frame.rows; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + if(dir[j] == 1) { + pixel[j] += static_cast(amt[j]); + amt[j] += inc[j]; + } else { + pixel[j] -= static_cast(amt[j]); + amt[j] -= inc[j]; + } + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + for(int j = 0; j < 3; ++j) { + procPos(dir[j], inc[j], alpha_max, 10, 0.1); + } +} + +void ac::Lines(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 3.0; + for(int z = 0; z < frame.rows; ++z) { + int r_start = (rand()%(frame.cols/2)); + int r_stop = (frame.cols/2)+(rand()%(frame.cols/2)); + int r_height = 1+rand()%3; + bool sw = true; + for(int q = z; q < frame.rows && q < z+r_height; ++q) { + for(int i = r_start; i < frame.cols && i < r_stop; ++i) { + if(q >= 0 && q < frame.rows && i >= 0 && i < frame.cols) { + cv::Vec3b &pixel = frame.at(q, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = (sw == true) ? 255 : 0; + } + swapColors(frame, q, i);// swap colors + if(isNegative) invert(frame, q, i);// if isNegative invert pixel */ + } + } + sw = (sw == true) ? false : true; + } + z += r_height-1; + } + static int dir = 1; + procPos(dir, alpha, alpha_max); +} + +void ac::ColorLines(cv::Mat &frame) { + int diff = (frame.cols/255); + static double alpha = 1.0, alpha_max = 2.0; + for(int z = 0; z < frame.rows; ++z) { + int total[3] = {rand()%16, rand()%32, rand()%64}; + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = (pixel[j]^total[j])*alpha; + if((i%(diff+1))==0) { + ++total[j]; + } + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 8.0, 0.01); +} + +void ac::WhiteLines(cv::Mat &frame) { + for(int z = 0; z < frame.rows; z += rand()%20) { + int num = rand()%25, skip = rand()%10; + int count = 0, skip_count = 0; + for(int i = 0; i < frame.cols; ++i) { + if(count < num) { + if(z >= 0 && z < frame.rows && i >= 0 && i < frame.cols) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[0] = pixel[1] = pixel[2] = 255; + } + ++count; + } else { + if(skip_count >= skip) { + skip_count = 0; + count = 0; + num = rand()%25; + skip = rand()%10; + } else { + ++skip_count; + } + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } +} + +void ac::ThickWhiteLines(cv::Mat &frame) { + for(int j = 0; j < 5; ++j) { + int start_y = 0; + if(j > 0) start_y = rand()%frame.rows; + for(int z = start_y; z < frame.rows; z += rand()%30) { + int num = rand()%50, skip = rand()%25; + int count = 0, skip_count = 0; + for(int i = 0; i < frame.cols; ++i) { + if(count < num) { + if(i >= 0 && i < frame.cols && z >= 0 && z < frame.rows) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[0] = pixel[1] = pixel[2] = 255; + } + ++count; + } else { + if(skip_count >= skip) { + skip_count = 0; + count = 0; + num = rand()%50; + skip = rand()%20; + } else { + ++skip_count; + } + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + } +} + +void ac::UseLineObject(cv::Mat &frame) { + static HLine obj_lines; + if(obj_lines.empty()) { + obj_lines.createLines(100, frame.cols, frame.rows); + } + obj_lines.drawLines(frame); +} + +void ac::TanAlphaGrid(cv::Mat &frame) { + static double alpha[3] = {1.0, 32.0, 64.0}, alpha_max = 7.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[0] = static_cast((tan(i)*alpha[0])+pixel[0]); + pixel[1] = static_cast((tan(z)*alpha[1])+pixel[1]); + pixel[2] = static_cast((tan(z-i)*alpha[2])+pixel[2]); + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int dir[3] = {1,1,1}; + for(int j = 0; j < 3; ++j) + procPos(dir[j], alpha[j], alpha_max); +} + +void ac::MedianBlendAnimation(cv::Mat &frame) { + static MatrixCollection<8> collection; + + int r = 3+rand()%7; + for(int i = 0; i < r; ++i) + MedianBlur(frame); + + collection.shiftFrames(frame); + static double alpha = 1.0, alpha_max = 3.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Scalar value; + for(int j = 0; j < collection.size(); ++j) { + cv::Vec3b pixel = collection.frames[j].at(z, i); + for(int q = 0; q < 3; ++q) { + value[q] += pixel[q]; + } + } + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + int val = 1+static_cast(value[j]); + pixel[j] = static_cast(static_cast(pixel[j]*alpha) ^ static_cast(val * alpha)); + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int direction = 1; + procPos(direction, alpha, alpha_max, 10, 0.08); +} + +void ac::FibFlash(cv::Mat &frame) { + static int values[13] = {1,2,3,5,8,13,21,34,55,89,144,233}; + static int index = 0; + static double alpha = 1.0, alpha_max = 3.0; + + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + int value = values[index]; + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j] ^ (static_cast(alpha)*value); + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int idir = 1; + if(idir == 1) { + ++index; + if(index > 12) idir = 0; + } else { + --index; + if(index <= 1) idir = 1; + } + static int dir = 1; + procPos(dir, alpha, alpha_max); +} + +void ac::ScaleFlash(cv::Mat &frame) { + static double pos = 1.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast(pixel[j]*pos); + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int idir = 1; + if(idir == 1) { + pos += 0.5; + + if(pos > 12) + idir = 0; + } else if(idir == 0) { + pos -= 0.5; + if(pos <= 1) + idir = 1; + } +} + +void ac::LeftLines(cv::Mat &frame) { + static std::unique_ptr line_width; + static int width = 0; + if(!line_width || frame.rows != width) { + line_width.reset(new unsigned int[frame.rows+1]); + width = frame.rows; + for(int i = 0; i < width; ++i) { + line_width[i] = rand()%50; + } + } + static double alpha = 1.0, alpha_max = 3.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < line_width[z]; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] ^= static_cast(pixel[j]*alpha); + + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + line_width[z] += 50; + if(line_width[z] > frame.cols) + line_width[z] = 1; + } + int direction = 1; + procPos(direction, alpha, alpha_max, 4.0, 0.05); +} + +void ac::Curtain(cv::Mat &frame) { + static int start = 0; + static int direction = 1; + static double alpha = 1.0, alpha_max = 7.0; + for(int z = 0; z < frame.rows; ++z) { + if(direction == 1) { + for(int i = 0; i < start; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] ^= static_cast(pixel[j]*alpha); + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + + } else { + + for(int i = frame.cols-1; i > start; --i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] ^= static_cast(pixel[j]*alpha); + + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + } + if(direction == 1) { + start += 40; + if(start > frame.cols-1) { + direction = 0; + } + } else { + start -= 40; + if(start <= 1) { + direction = 1; + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); +} + +void ac::RandomCurtain(cv::Mat &frame) { + + if(testSize(frame) == false) + return; + + static int start = 0; + static int direction = 1; + static double alpha = 1.0, alpha_max = 7.0; + int i = 0; + static DrawFunction rf = getRandomFilter(i); + cv::Mat frame_copy = frame.clone(); + rf(frame_copy); + + + for(int z = 0; z < frame.rows; ++z) { + if(direction == 1) { + for(int i = 0; i < start; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b copy_pix = frame_copy.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] ^= static_cast(copy_pix[j]+pixel[j]); + } + } + } else { + + for(int i = frame.cols-1; i > start; --i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b copy_pix = frame_copy.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] ^= static_cast(copy_pix[j]+pixel[j]); + } + } + } + if(direction == 1) { + start += 40; + if(start > frame.cols-1) { + direction = 0; + int i = 0; + rf = getRandomFilter(i); + } + } else { + start -= 40; + if(start <= 1) { + direction = 1; + int i = 0; + rf = getRandomFilter(i); + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); + AddInvert(frame); +} + +void ac::CurtainVertical(cv::Mat &frame) { + static int start = 0; + static int direction = 1; + static double alpha = 1.0, alpha_max = 7.0; + for(int z = 0; z < frame.cols; ++z) { + if(direction == 1) { + for(int i = 0; i < start; ++i) { + cv::Vec3b &pixel = frame.at(i, z); + for(int j = 0; j < 3; ++j) { + pixel[j] ^= static_cast(pixel[j]*alpha); + } + } + } else { + + for(int i = frame.rows-1; i > start; --i) { + cv::Vec3b &pixel = frame.at(i, z); + for(int j = 0; j < 3; ++j) + pixel[j] ^= static_cast(pixel[j]*alpha); + } + } + } + if(direction == 1) { + start += 50; + if(start > frame.rows-1) { + direction = 0; + } + } else { + start -= 50; + if(start <= 1) { + direction = 1; + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); + AddInvert(frame); +} + +void ac::RandomCurtainVertical(cv::Mat &frame) { + + if(frame.rows < 320 || frame.cols < 240) + return; + + static int start = 0; + static int direction = 1; + static double alpha = 1.0, alpha_max = 7.0; + int i = 0; + static DrawFunction rf = getRandomFilter(i); + cv::Mat frame_copy = frame.clone(); + rf(frame_copy); + + for(int z = 0; z < frame.cols; ++z) { + if(direction == 1) { + for(int i = 0; i < start; ++i) { + cv::Vec3b &pixel = frame.at(i, z); + cv::Vec3b copy_pix = frame_copy.at(i, z); + for(int j = 0; j < 3; ++j) { + pixel[j] ^= static_cast(copy_pix[j]+pixel[j]); + } + } + } else { + for(int i = frame.rows-1; i > start; --i) { + cv::Vec3b &pixel = frame.at(i, z); + cv::Vec3b copy_pix = frame_copy.at(i, z); + for(int j = 0; j < 3; ++j) + pixel[j] ^= static_cast(copy_pix[j]+pixel[j]); + + } + } + } + if(direction == 1) { + start += 50; + if(start > frame.rows-1) { + direction = 0; + rf = getRandomFilter(i); + } + } else { + start -= 50; + if(start <= 1) { + direction = 1; + rf = getRandomFilter(i); + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); + AddInvert(frame); +} + +void ac::inOrderBySecond(cv::Mat &frame) { + static int index = 0; + if(index < ac::draw_max-8) { + static int frame_count = 0; + if(index >= 0 && index < ac::draw_max-8 && ac::draw_strings[index] != "inOrderBySecond" && ac::draw_strings[index] != "inOrder" && ac::draw_strings[index] != "inOrderAlpha" && ac::draw_strings[index] != "inOrderAlphaXor") ac::draw_func[index](frame); + ++frame_count; + if(frame_count >= ac::fps) { + frame_count = 0; + ++index; + if(index >= ac::draw_max-10) { + index = 0; + } + } + } else index = 0; + AddInvert(frame); +} + +void ac::inOrder(cv::Mat &frame) { + static int index = 0; + if(index < ac::draw_max-8) { + if(index >= 0 && index < ac::draw_max-8 && ac::draw_strings[index] != "inOrderBySecond" && ac::draw_strings[index] != "inOrder" && ac::draw_strings[index] != "inOrderAlpha" && ac::draw_strings[index] != "inOrderAlphaXor") ac::draw_func[index](frame); + ++index; + } else index = 0; + + AddInvert(frame); +} + +void ac::DarkenFilter(cv::Mat &frame) { + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = pixel[j] / 2; + } + } +} + +void ac::RandomFilterBySecond(cv::Mat &frame) { + if(testSize(frame) == false) + return; + + static int frame_count = 0; + static int f = 0; + static DrawFunction func = getRandomFilter(f); + if(ac::draw_strings[f] == "RandomFilterBySecond") { + func = getRandomFilter(f); + return; + } + func(frame); + if(++frame_count >= ac::fps) { + frame_count = 0; + func = getRandomFilter(f); + } + AddInvert(frame); +} + +void ac::ThreeRandom(cv::Mat &frame) { + + if(testSize(frame) == false) + return; + + for(int j = 0; j < 3; ++j) { + int f = 0; + ac::DrawFunction func = getRandomFilter(f); + if(ac::draw_strings[f] != "ThreeRandom") + func(frame); + } + AddInvert(frame); +} + +void ac::inOrderAlpha(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 7.0; + cv::Mat copy[2]; + copy[0] = frame.clone(); + copy[1] = frame.clone(); + inOrder(copy[0]); + inOrder(copy[1]); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b colors[3]; + cv::Vec3b &pixel = frame.at(z, i); + colors[0] = copy[0].at(z, i); + colors[1] = copy[1].at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] ^= (colors[0][j] * static_cast(alpha)) + (colors[1][j] * static_cast(alpha)); + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); + AddInvert(frame); +} + +void ac::inOrderAlphaXor(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 4.0; + cv::Mat copy[2]; + copy[0] = frame.clone(); + copy[1] = frame.clone(); + inOrder(copy[0]); + AlphaXorBlend(copy[0], copy[1], frame, alpha); + static int dir = 1; + procPos(dir, alpha, alpha_max, 10, 0.01); + AddInvert(frame); +} + +void ac::SlideFilter(cv::Mat &frame) { + static const int speed = 40; + static int start_1 = 0, start_2 = frame.cols-1; + static int direction_1 = 1, direction_2 = 0; + static double alpha = 1.0, alpha_max = 3.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < start_1; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j]*(1+static_cast(alpha)); + } + } + for(int i =(frame.cols-1); i > start_2; --i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = pixel[j]*(1+static_cast(alpha)); + + } + } + if(direction_1 == 1) { + start_1 += speed; + if(start_1 > (frame.cols-1)) { + direction_1 = 0; + start_1 = (frame.cols-1); + } + } else { + start_1 -= speed; + if(start_1 <= 0) { + direction_1 = 1; + start_1 = 0; + } + } + if(direction_2 == 1) { + start_2 += speed; + if(start_2 >= (frame.cols-1)) { + direction_2 = 0; + start_2 = (frame.cols-1); + } + } else { + start_2 -= speed; + if(start_2 <= 0) { + direction_2 = 1; + start_2 = 0; + } + } + + static int dir = 1; + procPos(dir, alpha, alpha_max, 9.0, 0.005); + AddInvert(frame); +} + +void ac::SlideFilterXor(cv::Mat &frame) { + static const int speed = 40; + static int start_1 = 0, start_2 = frame.cols-1; + static int direction_1 = 1, direction_2 = 0; + static double alpha = 1.0, alpha_max = 3.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < start_1; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] ^= pixel[j]*static_cast(1+alpha); + } + } + for(int i =(frame.cols-1); i > start_2; --i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] ^= pixel[j]*static_cast(1+alpha); + + } + } + if(direction_1 == 1) { + start_1 += speed; + if(start_1 > (frame.cols-1)) { + direction_1 = 0; + start_1 = (frame.cols-1); + } + } else { + start_1 -= speed; + if(start_1 <= 0) { + direction_1 = 1; + start_1 = 0; + } + } + if(direction_2 == 1) { + start_2 += speed; + if(start_2 >= (frame.cols-1)) { + direction_2 = 0; + start_2 = (frame.cols-1); + } + } else { + start_2 -= speed; + if(start_2 <= 0) { + direction_2 = 1; + start_2 = 0; + } + } + + static int dir = 1; + procPos(dir, alpha, alpha_max, 9.0, 0.005); + AddInvert(frame); +} + +void ac::RandomSlideFilter(cv::Mat &frame) { + + if(testSize(frame) == false) + return; + + static const int speed = 40; + static int start_1 = 0, start_2 = frame.cols-1; + static int direction_1 = 1, direction_2 = 0; + static double alpha = 1.0, alpha_max = 7.0; + static int index[2]; + DrawFunction f1, f2; + f1 = getRandomFilter(index[0]); + f2 = getRandomFilter(index[1]); + if(ac::draw_strings[index[0]] == "RandomSlideFilter") return; + if(ac::draw_strings[index[1]] == "RandomSlideFilter") return; + cv::Mat frames[2]; + frames[0] = frame.clone(); + frames[1] = frame.clone(); + f1(frames[0]); + f2(frames[1]); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < start_1; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frames[0].at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] ^= static_cast(pix[j]*alpha); + } + } + for(int i =(frame.cols-1); i > start_2; --i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frames[1].at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] ^= static_cast(pix[j]*alpha); + } + } + if(direction_1 == 1) { + start_1 += speed; + if(start_1 > (frame.cols-1)) { + direction_1 = 0; + start_1 = (frame.cols-1); + } + } else { + start_1 -= speed; + if(start_1 <= 0) { + direction_1 = 1; + start_1 = 0; + } + } + if(direction_2 == 1) { + start_2 += speed; + if(start_2 >= (frame.cols-1)) { + direction_2 = 0; + start_2 = (frame.cols-1); + } + } else { + start_2 -= speed; + if(start_2 <= 0) { + direction_2 = 1; + start_2 = 0; + } + } + + static int dir = 1; + procPos(dir, alpha, alpha_max); + AddInvert(frame); +} + +// No Filter +void ac::NoFilter(cv::Mat &) {} +// Alpha Blend with Original Frame +void ac::BlendWithSource(cv::Mat &frame) { + cv::Mat copyf = frame.clone(); + ac::pass2_alpha = blend_percentage; // set to 50% + Pass2Blend(copyf);// call Pass2 function + frame = copyf.clone(); +} + +void ac::setBlendPercentage(const double &value) { + blend_percentage = value; +} + diff --git a/windows/Acid.Cam.Qt.Windows.Project/ac-filter7.cpp b/windows/Acid.Cam.Qt.Windows.Project/ac-filter7.cpp new file mode 100755 index 0000000..0927ea1 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/ac-filter7.cpp @@ -0,0 +1,1047 @@ +/* + * Software written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + + +#include "ac.h" + + +void ac::SlideUpDown(cv::Mat &frame) { + static const int speed = 40; + static int start_1 = 0, start_2 = frame.rows-1; + static int direction_1 = 1, direction_2 = 0; + static double alpha = 1.0, alpha_max = 3.0; + for(int i = 0; i < frame.cols; ++i) { + for(int z = 0; z < start_1; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast(pixel[j]*alpha); + } + } + for(int z =(frame.rows-1); z > start_2; --z) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast(pixel[j]*alpha); + + } + } + if(direction_1 == 1) { + start_1 += speed; + if(start_1 > (frame.rows-1)) { + direction_1 = 0; + start_1 = (frame.rows-1); + } + } else { + start_1 -= speed; + if(start_1 <= 0) { + direction_1 = 1; + start_1 = 0; + } + } + if(direction_2 == 1) { + start_2 += speed; + if(start_2 >= (frame.rows-1)) { + direction_2 = 0; + start_2 = (frame.rows-1); + } + } else { + start_2 -= speed; + if(start_2 <= 0) { + direction_2 = 1; + start_2 = 0; + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 9.0, 0.005); + AddInvert(frame); +} + +void ac::SlideUpDownXor(cv::Mat &frame) { + static const int speed = 40; + static int start_1 = 0, start_2 = frame.rows-1; + static int direction_1 = 1, direction_2 = 0; + static double alpha = 1.0, alpha_max = 3.0; + for(int i = 0; i < frame.cols; ++i) { + for(int z = 0; z < start_1; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] ^= static_cast(pixel[j]*alpha); + } + } + for(int z =(frame.rows-1); z > start_2; --z) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] ^= static_cast(pixel[j]*alpha); + + } + } + if(direction_1 == 1) { + start_1 += speed; + if(start_1 > (frame.rows-1)) { + direction_1 = 0; + start_1 = (frame.rows-1); + } + } else { + start_1 -= speed; + if(start_1 <= 0) { + direction_1 = 1; + start_1 = 0; + } + } + if(direction_2 == 1) { + start_2 += speed; + if(start_2 >= (frame.rows-1)) { + direction_2 = 0; + start_2 = (frame.rows-1); + } + } else { + start_2 -= speed; + if(start_2 <= 0) { + direction_2 = 1; + start_2 = 0; + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 9.0, 0.005); + AddInvert(frame); +} + +void ac::SlideUpDownRandom(cv::Mat &frame) { + + if(testSize(frame) == false) + return; + + DrawFunction f1, f2; + static int index[2]; + f1 = getRandomFilter(index[0]); + f2 = getRandomFilter(index[1]); + if(ac::draw_strings[index[0]] == "SlideUpDownRandom") return; + if(ac::draw_strings[index[1]] == "SlideUpDownRandom") return; + cv::Mat frames[2]; + frames[0] = frame.clone(); + frames[1] = frame.clone(); + f1(frames[0]); + f2(frames[1]); + static const int speed = 40; + static int start_1 = 0, start_2 = frame.rows-1; + static int direction_1 = 1, direction_2 = 0; + static double alpha = 1.0, alpha_max = 3.0; + for(int i = 0; i < frame.cols; ++i) { + for(int z = 0; z < start_1; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frames[0].at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] ^= static_cast(pix[j]*alpha); + } + } + for(int z =(frame.rows-1); z > start_2; --z) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frames[1].at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] ^= static_cast(pix[j]*alpha); + + } + } + if(direction_1 == 1) { + start_1 += speed; + if(start_1 > (frame.rows-1)) { + direction_1 = 0; + start_1 = (frame.rows-1); + } + } else { + start_1 -= speed; + if(start_1 <= 0) { + direction_1 = 1; + start_1 = 0; + } + } + if(direction_2 == 1) { + start_2 += speed; + if(start_2 >= (frame.rows-1)) { + direction_2 = 0; + start_2 = (frame.rows-1); + } + } else { + start_2 -= speed; + if(start_2 <= 0) { + direction_2 = 1; + start_2 = 0; + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 9.0, 0.005); + AddInvert(frame); +} + +void ac::SlideSubFilter(cv::Mat &frame) { + static const int speed = 40; + static int start_1 = 0, start_2 = frame.cols-1; + static int direction_1 = 1, direction_2 = 0; + static double alpha = 1.0, alpha_max = 7.0; + if(subfilter == -1 || ac::draw_strings[subfilter] == "SlideSubFilter") return; + cv::Mat frame_x; + frame_x = frame.clone(); + if(ac::subfilter != -1) { + ac::draw_func[ac::subfilter](frame_x); + } else return; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < start_1; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_x.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] ^= static_cast(pix[j]*alpha); + } + } + for(int i =(frame.cols-1); i > start_2; --i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_x.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] ^= static_cast(pix[j]*alpha); + } + } + if(direction_1 == 1) { + start_1 += speed; + if(start_1 > (frame.cols-1)) { + direction_1 = 0; + start_1 = (frame.cols-1); + } + } else { + start_1 -= speed; + if(start_1 <= 0) { + direction_1 = 1; + start_1 = 0; + } + } + if(direction_2 == 1) { + start_2 += speed; + if(start_2 >= (frame.cols-1)) { + direction_2 = 0; + start_2 = (frame.cols-1); + } + } else { + start_2 -= speed; + if(start_2 <= 0) { + direction_2 = 1; + start_2 = 0; + } + } + + static int dir = 1; + procPos(dir, alpha, alpha_max); + AddInvert(frame); +} + +void ac::SlideSubUpDownFilter(cv::Mat &frame) { + static const int speed = 40; + static int start_1 = 0, start_2 = frame.rows-1; + static int direction_1 = 1, direction_2 = 0; + static double alpha = 1.0, alpha_max = 3.0; + if(subfilter == -1 || ac::draw_strings[subfilter] == "SlideSubUpDownFilter") return; + cv::Mat frame_x; + frame_x = frame.clone(); + if(ac::subfilter != -1) { + ac::draw_func[ac::subfilter](frame_x); + } else return; + + for(int i = 0; i < frame.cols; ++i) { + for(int z = 0; z < start_1; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_x.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] ^= static_cast(pix[j]*alpha); + } + } + for(int z =(frame.rows-1); z > start_2; --z) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_x.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] ^= static_cast(pix[j]*alpha); + + } + } + if(direction_1 == 1) { + start_1 += speed; + if(start_1 > (frame.rows-1)) { + direction_1 = 0; + start_1 = (frame.rows-1); + } + } else { + start_1 -= speed; + if(start_1 <= 0) { + direction_1 = 1; + start_1 = 0; + } + } + if(direction_2 == 1) { + start_2 += speed; + if(start_2 >= (frame.rows-1)) { + direction_2 = 0; + start_2 = (frame.rows-1); + } + } else { + start_2 -= speed; + if(start_2 <= 0) { + direction_2 = 1; + start_2 = 0; + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 9.0, 0.005); + AddInvert(frame); +} + +void ac::BlendInAndOut(cv::Mat &frame) { + static cv::Scalar color(rand()%255, rand()%255, rand()%255); + static int step[3] = {1,1,1}; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] ^= static_cast(color[j]); + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + static int dir[3] = {1,1,1}; + for(int j = 0; j < 3; ++j) { + if(dir[j] == 1) { + color[j] += step[j]; + if(color[j] >= 255) { + dir[j] = 0; + } + + } else if(dir[j] == 0) { + color[j] -= step[j]; + if(color[j] <= 0) { + step[j] = 1+(rand()%10); + dir[j] = 1; + color[j] = rand()%255; + } + } + } +} + +void ac::BlendScaleInAndOut(cv::Mat &frame) { + static cv::Scalar color(rand()%255, rand()%255, rand()%255); + static double alpha = 1.0, alpha_max = 6.0; + static int step[3] = {1,1,1}; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] ^= static_cast(color[j]*alpha); + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + static int dir[3] = {1,1,1}; + for(int j = 0; j < 3; ++j) { + if(dir[j] == 1) { + color[j] += step[j]; + if(color[j] >= 255) { + dir[j] = 0; + } + } else if(dir[j] == 0) { + color[j] -= step[j]; + if(color[j] <= 0) { + step[j] = 1+(rand()%10); + dir[j] = 1; + color[j] = rand()%255; + } + } + } + static int alpha_direction = 1; + procPos(alpha_direction, alpha, alpha_max, 10, 0.09); +} +void ac::AcidGlitch(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 6.0; + static int step[3] = {1,1,1}; + static cv::Scalar color(rand()%255, rand()%255, rand()%255); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix_copy = pixel; + for(int j = 0; j < 3; ++j) { + pixel[j] += (((pix_copy[3-j-1] ^ static_cast(color[j]))) * alpha); + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + static int dir[3] = {1,1,1}; + for(int j = 0; j < 3; ++j) { + if(dir[j] == 1) { + color[j] += step[j]; + if(color[j] >= 255) { + dir[j] = 0; + } + } else if(dir[j] == 0) { + color[j] -= step[j]; + if(color[j] <= 0) { + step[j] = 1+(rand()%10); + dir[j] = 1; + color[j] = rand()%255; + } + } + } + static int alpha_direction = 1; + procPos(alpha_direction, alpha, alpha_max, 10, 0.09); +} + +void ac::XorBackwards(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 6.0; + static cv::Mat frame_copy = frame.clone(); + cv::Mat orig = frame.clone(); + if(frame_copy.size()!=frame.size()) { + frame_copy = frame.clone(); + } + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + for(int j = 0; j < 3; ++j) { + double val = 0; + val = (pixel[j]^pix[3-j-1])*alpha; + pixel[j] += static_cast(val); + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); + frame_copy = orig; +} + +void ac::LiquidFilter(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 7.0; + static MatrixCollection<3> collection; + collection.shiftFrames(frame); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b frame_pix[3]; + for(int j = 0; j < 3; ++j) { + frame_pix[j] = collection.frames[j].at(z, i); + } + for(int j = 0; j < 3; ++j) { + double value = 0; + for(int q = 0; q < 3; ++q) { + value += frame_pix[j][q] * alpha; + } + pixel[j] = pixel[j]^static_cast(value); + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); +} + +void ac::MatrixXorAnd(cv::Mat &frame) { + static MatrixCollection<3> collection; + static double alpha = 1.0, alpha_max = 7.0; + collection.shiftFrames(frame); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b frame_pix[3]; + for(int j = 0; j < 3; ++j) + frame_pix[j] = collection.frames[j].at(z, i); + + for(int j = 0; j < 3; ++j) { + static bool dir = true; + double value = 0; + for(int q = 0; q < 3; ++q) { + if(dir == true) + value += frame_pix[j][q] * alpha; + else + value += frame_pix[3-j-1][q] * alpha; + dir = (dir == true) ? false : true; + } + pixel[j] = (cv::saturate_cast(pixel[j]&(static_cast(value))))^static_cast(alpha); + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 8.0, 0.1); +} + + +void ac::XorAlpha(cv::Mat &frame) { + static cv::Scalar color_value(rand()%255, rand()%255, rand()%255); + static int index = 0; + static double alpha = 1.0, alpha_max = 7.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] ^= static_cast(color_value[j]*alpha); + + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + if(color_value[index] >= 255) { + color_value[index] = rand()%255; + ++index; + if(index > 2) + index = 0; + } else { + color_value[index] += 5; + } + static int dir = 1; + procPos(dir, alpha, alpha_max); +} + +void ac::AlphaAcidTrails(cv::Mat &frame) { + XorAlpha(frame); + MedianBlend(frame); +} + +void ac::SelfXorAverage(cv::Mat &frame) { + static MatrixCollection<4> collection; + collection.shiftFrames(frame); + static double alpha = 1.0, alpha_max = 7.0; + + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix[3]; + for(int j = 0; j < 3; ++j) { + pix[j] = collection.frames[j].at(z, i); + } + for(int j = 0; j < 3; ++j) { + double value = ((pix[0][j] ^ pix[1][j] ^ pix[2][j])/3) * alpha; + pixel[j] ^= static_cast(value) ^ static_cast(alpha); + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); +} + +void ac::RandomXorBlend(cv::Mat &frame) { + cv::Vec3b pix(rand()%255, rand()%255, rand()%255); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = cv::saturate_cast(pixel[j]^pix[j]); + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } +} + +void ac::RGBVerticalXor(cv::Mat &frame) { + static int pos[3] = {0, 0, 0}; + static cv::Size old_size; + if(frame.size() != old_size) { + pos[0] = pos[1] = pos[2] = 0; + old_size = frame.size(); + } + static int index = 0; + static double alpha = 1.0, alpha_max = 6.0; + for(int i = 0; i < frame.cols; ++i) { + for(int z = 0; z < pos[index]; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[3-index-1] ^= static_cast(pixel[index]*alpha); + + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + for(int z = pos[index]; z < frame.rows; ++z) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[index] ^= static_cast(pixel[index]*alpha); + + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + + pos[index] += 100; + + if(pos[index] > frame.rows) { + pos[index] = 0; + ++index; + if(index > 2) + index = 0; + } + + static int dir = 1; + procPos(dir, alpha, alpha_max); +} + +void ac::RGBVerticalXorScale(cv::Mat &frame) { + RGBVerticalXor(frame); + BlendScaleInAndOut(frame); +} + +void ac::RGBHorizontalXor(cv::Mat &frame) { + static int pos[3] = {0, 0, 0}; + static cv::Size old_size; + if(frame.size() != old_size) { + pos[0] = pos[1] = pos[2] = 0; + old_size = frame.size(); + } + static int index = 0; + static double alpha = 1.0, alpha_max = 6.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < pos[index]; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[3-index-1] ^= static_cast(pixel[index]*alpha); + + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + for(int i = pos[index]; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[index] ^= static_cast(pixel[index]*alpha); + + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + pos[index] += 100; + if(pos[index] > frame.cols) { + pos[index] = 0; + ++index; + if(index > 2) + index = 0; + } + + static int dir = 1; + procPos(dir, alpha, alpha_max); +} + +void ac::RGBHorizontalXorScale(cv::Mat &frame) { + RGBHorizontalXor(frame); + BlendScaleInAndOut(frame); +} + +void ac::FadeStrobe(cv::Mat &frame) { + static cv::Scalar colorval(rand()%255, rand()%255, rand()%255); + if(frames_released == true || reset_alpha == true) { + colorval = cv::Scalar(rand()%255, rand()%255, rand()%255); + } + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = (pixel[j]^static_cast(1+colorval[j])); + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + for(int j = 0; j < 3; ++j) { + colorval[j] += 20; + if(colorval[j] >= 255) { + colorval[j] = 0; + } + } +} + +void ac::RGBMirror(cv::Mat &frame) { + cv::Mat f_copy = frame.clone(); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b f_pixel[4]; + f_pixel[0] = f_copy.at(frame.rows-z-1, frame.cols-i-1); + f_pixel[1] = f_copy.at(frame.rows-z-1, i); + f_pixel[2] = f_copy.at(z, frame.cols-i-1); + for(int j = 0; j < 3; ++j) { + pixel[j] = (pixel[j]^f_pixel[j][j]); + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } +} + +void ac::MirrorStrobe(cv::Mat &frame) { + cv::Mat copy_f = frame.clone(); + static cv::Scalar value(rand()%255, rand()%255, rand()%255); + static int index = 0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = copy_f.at(copy_f.rows-z-1, copy_f.cols-i-1); + pixel[index] = cv::saturate_cast((pixel[index]^pix[index])+value[index]); + + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + + value[index] += 50; + if(value[index] > 255) + value[index] = 0; + + ++index; + if(index > 2) + index = 0; +} + +void ac::AndStrobe(cv::Mat &frame) { + cv::Vec3b colorval(rand()%255, rand()%255, rand()%255); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j]&colorval[j]; + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } +} + +void ac::AndStrobeScale(cv::Mat &frame) { + static double alpha = 1.0, pos_max = 7.0; + cv::Vec3b colorval(rand()%255, rand()%255, rand()%255); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast((pixel[j]&colorval[j])*alpha); + } + } + } + static int dir = 1; + procPos(dir, alpha, pos_max); +} + +void ac::AndPixelStrobe(cv::Mat &frame) { + static cv::Scalar colorval(rand()%255, rand()%255, rand()%255); + static int index = 0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j] & static_cast(colorval[j]); + pixel[j] = pixel[j] ^ static_cast(colorval[j]); + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + colorval[index] += 50; + if(colorval[index] > 255) { + colorval[index] = rand()%255; + ++index; + if(index > 2) + index = 0; + } +} + +void ac::AndOrXorStrobe(cv::Mat &frame) { + static int index = 0; + cv::Scalar colorval(rand()%255, rand()%255, rand()%255); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + switch(index) { + case 0: + pixel[j] = pixel[j] & static_cast(colorval[j]); + break; + case 1: + pixel[j] = pixel[j] | static_cast(colorval[j]); + break; + case 2: + pixel[j] = pixel[j] ^ static_cast(colorval[j]); + break; + } + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + ++index; + if(index > 2) + index = 0; + +} + +void ac::AndOrXorStrobeScale(cv::Mat &frame) { + static int index = 0; + static double alpha = 1.0, alpha_max = 7.0; + cv::Scalar colorval(rand()%255, rand()%255, rand()%255); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + switch(index) { + case 0: + pixel[j] = (pixel[j] & static_cast(colorval[j]))*static_cast(1+alpha); + break; + case 1: + pixel[j] = (pixel[j] | static_cast(colorval[j]))*static_cast(1+alpha); + break; + case 2: + pixel[j] = (pixel[j] ^ static_cast(colorval[j]))*static_cast(1+alpha); + break; + } + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + ++index; + if(index > 2) + index = 0; + + static int dir = 1; + procPos(dir, alpha, alpha_max); +} + +void ac::FadeInAndOut(cv::Mat &frame) { + static int speed[3] = {5+rand()%10, 5+rand()%10, 5+rand()%10}; + static cv::Scalar colorval(rand()%255, rand()%255, rand()%255); + static int dir[3] = {rand()%2, rand()%2, rand()%2}; + if(frames_released == true || reset_alpha == true) { + colorval = cv::Scalar(rand()%255, rand()%255, rand()%255); + for(int j = 0; j < 3; ++j) { + dir[j] = rand()%2; + speed[j] = 5+rand()%10; + } + } + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] ^= cv::saturate_cast(colorval[j]); + + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + for(int j = 0; j < 3; ++j) { + if(dir[j] == 1) { + colorval[j] += speed[j]; + if(colorval[j] > 255) { + colorval[j] = 255; + dir[j] = 0; + speed[j] = 5+rand()%10; + } + } else if(dir[j] == 0) { + colorval[j] -= speed[j]; + if(colorval[j] <= 0) { + colorval[j] = 0; + dir[j] = 1; + speed[j] = 5+rand()%10; + } + } + } +} + +void ac::BrightStrobe(cv::Mat &frame) { + static int speed[3] = {1,6,13}; + static int dir[3] = {1,1,1}; + cv::Scalar colorval(rand()%255, rand()%255, rand()%255); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] ^= static_cast((colorval[j]*speed[j])); + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + for(int j = 0; j < 3; ++j) { + if(dir[j] == 1) { + colorval[j] += speed[j]; + if(colorval[j] > 255) { + dir[j] = 0; + } + ++speed[j]; + if(speed[j] > 25) { + speed[j] = 25; + } + } else { + colorval[j] -= speed[j]; + if(colorval[j] <= 0) { + colorval[j] = speed[j]--; + dir[j] = 1; + } + --speed[j]; + if(speed[j] <= 0) { + speed[j] = 1; + } + } + } + +} + +void ac::DarkStrobe(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 7.0; + cv::Scalar colorval(rand()%255, rand()%255, rand()%255); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i ){ + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] &= static_cast((pixel[j]%(1+static_cast(colorval[j])))*alpha); + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); +} + +void ac::RandomXorOpposite(cv::Mat &frame) { + cv::Vec3b colorval(rand()%255, rand()%255, rand()%255); + cv::Vec3b colorval2(rand()%255, rand()%255, rand()%255); + for(int z = 0; z < frame.rows; ++z){ + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = ~pixel[j] ^ colorval[j] ^ ~colorval2[j]; + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } +} + +void ac::StrobeTransform(cv::Mat &frame) { + cv::Vec3b colorval(rand()%255, rand()%255, rand()%255); + static double value = 25.0, alpha = 1.0, alpha_max = 7.0; + static int dir = 1, speed_dir = 1; + static int speed = 2, speed_increase = 5; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] += ((pixel[j] + (static_cast(value))) ^ static_cast(alpha)) ^ colorval[j]; + } + } + } + if(dir == 1) + value += speed; + else + value -= speed; + + if(dir == 1) { + if(value > (255)) { + dir = 0; + if(speed_dir == 1) { + speed += speed_increase; + if(speed > 25) + speed_dir = 0; + } else if(speed_dir == 0) { + speed -= speed_increase; + if(speed <= 1) + speed_dir = 1; + } + } + } else if(dir == 0) { + if(value <= 25) { + dir = 1; + } + } + static int cdir = 1; + procPos(cdir, alpha, alpha_max); +} + +void ac::InitBlend(cv::Mat &frame) { + static cv::Vec3b colorval(rand()%255, rand()%255, rand()%255); + static double value = 25.0, alpha = 1.0, alpha_max = 7.0; + static int dir = 1, speed_dir = 1; + static int speed = 2, speed_increase = 5; + if(reset_alpha == true || frames_released == true) { + colorval = cv::Vec3b(rand()%255, rand()%255, rand()%255); + value = 25.0; + alpha = 1.0; + alpha_max = 7.0; + dir = 1; + speed_dir = 1; + speed = 2; + speed_increase = 5; + } + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] += ((pixel[j] + (static_cast(value))) ^ static_cast(alpha)) ^ colorval[j]; + } + } + } + if(dir == 1) + value += speed; + else + value -= speed; + if(dir == 1) { + if(value > (255)) { + dir = 0; + if(speed_dir == 1) { + speed += speed_increase; + if(speed > 25) + speed_dir = 0; + } else if(speed_dir == 0) { + speed -= speed_increase; + if(speed <= 1) + speed_dir = 1; + } + } + } else if(dir == 0) { + if(value <= 25) { + dir = 1; + } + } + static int cdir = 1; + procPos(cdir, alpha, alpha_max); +} + diff --git a/windows/Acid.Cam.Qt.Windows.Project/ac-filter8.cpp b/windows/Acid.Cam.Qt.Windows.Project/ac-filter8.cpp new file mode 100755 index 0000000..502b93c --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/ac-filter8.cpp @@ -0,0 +1,1226 @@ +/* + * Software written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + + +#include "ac.h" + +void ac::MoveUpLeft(cv::Mat &frame) { + + static double alpha = 1.0, alpha_max = 7.0; + + static cv::Mat old_frame = frame.clone(); + static cv::Size old_size = old_frame.size(); + + if(reset_alpha == true || frames_released == true || old_size != frame.size()) { + old_frame = frame.clone(); + old_size = old_frame.size(); + } + for(int z = 0; z < old_frame.rows-1; ++z) { + for(int i = 0; i < old_frame.cols-1; ++i) { + cv::Vec3b &pixel = old_frame.at(z, i); + cv::Vec3b pix = old_frame.at(z+1, i+1); + pixel = pix; + } + } + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = old_frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast((pixel[j]^pix[j])*alpha); + } + } + + static int dir = 1; + procPos(dir, alpha, alpha_max); + AddInvert(frame); +} + +void ac::RandomStrobe(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 7.0; + static std::vector svStrobe{ "StrobeEffect", "Blank", "Type","Random Flash","Strobe Red Then Green Then Blue","Flash Black","FlashWhite","StrobeScan", "RGBFlash", "ReinterpretDouble", "DiamondStrobe", "BitwiseXorStrobe","FlashBlackAndWhite", "StrobeBlend", "FibFlash", "ScaleFlash", "FadeStrobe", "AndStrobe", "AndStrobeScale", "AndPixelStrobe", "AndOrXorStrobe", "AndOrXorStrobeScale", "BrightStrobe", "DarkStrobe", "RandomXorOpposite", "StrobeTransform"}; + + cv::Mat old_frame = frame.clone(); + DrawFilter(svStrobe[rand()%svStrobe.size()], old_frame); + cv::Mat copy = frame.clone(); + AlphaBlend(old_frame, copy, frame, alpha); + static int dir = 1; + procPos(dir, alpha, alpha_max, 15, 0.1); + AddInvert(frame); +} + +void ac::RandomBlur(cv::Mat &frame) { + std::vector svBlur { "GaussianBlur", "Median Blur", "Blur Distortion", "ColorTrails","TrailsFilter", "TrailsFilterIntense", "TrailsFilterSelfAlpha", "TrailsFilterXor","BlurSim", "TrailsInter", "TrailsBlend", "TrailsNegate", "AcidTrails", "HorizontalTrailsInter" ,"Trails", "BlendTrails", "SmoothTrails", "SmoothTrailsSelfAlphaBlend", "SmoothTrailsRainbowBlend", "MedianBlend", "XorTrails", "RainbowTrails", "NegativeTrails", "IntenseTrails", "GaussianBlend", "RandomAmountMedianBlur", "MedianBlendAnimation", "AlphaAcidTrails"}; + static double alpha = 1.0, alpha_max = 7.0; + cv::Mat old_frame = frame.clone(); + DrawFilter(svBlur[rand()%svBlur.size()], old_frame); + cv::Mat copy = frame.clone(); + AlphaBlend(old_frame, copy, frame, alpha); + static int dir = 1; + procPos(dir, alpha, alpha_max, 15, 0.1); + AddInvert(frame); +} + + +void ac::StuckStrobe(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 7.0; + static cv::Mat old_frame = frame.clone(); + if(reset_alpha == true || frames_released == true || old_frame.size() != frame.size()) { + old_frame = frame.clone(); + } + cv::Mat copy = frame.clone(); + AlphaBlend(old_frame, copy, frame, alpha); + static int dir = 1; + procPos(dir, alpha, alpha_max, 15, 0.1); + AddInvert(frame); +} + +void ac::Stuck(cv::Mat &frame) { + static cv::Mat old_frame = frame.clone(); + if(reset_alpha == true || frames_released == true || old_frame.size() != frame.size()) { + old_frame = frame.clone(); + } + Add(frame, old_frame); + AddInvert(frame); +} + +void ac::OrStrobe(cv::Mat &frame) { + cv::Mat copy = frame.clone(); + static cv::Mat prev_frame = frame.clone(); + if(prev_frame.size() != frame.size()) { + prev_frame = frame.clone(); + } + cv::Vec3b randval(rand()%255, rand()%255, rand()%255); + static double alpha = 1.0, alpha_max = 7.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = prev_frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast((pixel[j]|randval[j]|pix[j])*alpha); + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); + prev_frame = copy.clone(); + AddInvert(frame); +} + +void ac::LagBlend(cv::Mat &frame) { + static MatrixCollection<8> collection; + static cv::Size c_size = frame.size(); + // lazy init + static bool init = false; + if(c_size != frame.size() || init == false) { + collection.shiftFrames(frame); + init = true; + c_size = frame.size(); + } + static int frame_count = 0; + ++frame_count; + if(frame_count > (ac::fps/8)) { + collection.shiftFrames(frame); + frame_count = 0; + } + for(int i = 0; i < collection.size(); ++i) { + DarkenFilter(frame); + Add(frame, collection.frames[i]); + } + AddInvert(frame); +} + +void ac::SubFilter(cv::Mat &frame) { + static MatrixCollection<8> collection; + collection.shiftFrames(frame); + for(int j = 0; j < collection.size(); ++j) { + Sub(frame, collection.frames[j]); + } + AddInvert(frame); +} + +void ac::AddFilter(cv::Mat &frame) { + static MatrixCollection<12> collection; + collection.shiftFrames(frame); + for(int j = 0; j < collection.size(); ++j) { + Add(frame, collection.frames[j]); + } + AddInvert(frame); +} + +// Use in a custom with Darken Filter twice +void ac::RGBTrails(cv::Mat &frame) { + static MatrixCollection<8> collection; + collection.shiftFrames(frame); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + int offset = 0; + for(int j = 0; j < collection.size(); ++j) { + cv::Vec3b pix = collection.frames[j].at(z, i); + pixel[offset] = static_cast(pixel[offset]+(pix[offset])); + + ++offset; + if(offset > 2) + offset = 0; + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } +} + +void ac::RGBTrailsDark(cv::Mat &frame) { + DarkenFilter(frame); + DarkenFilter(frame); + RGBTrails(frame); +} + +void ac::RGBTrailsAlpha(cv::Mat &frame) { + static MatrixCollection<8> collection; + DarkenFilter(frame); + DarkenFilter(frame); + collection.shiftFrames(frame); + static double alpha = 1.0, alpha_max = 4.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + int offset = 0; + for(int j = 0; j < collection.size(); ++j) { + cv::Vec3b pix = collection.frames[j].at(z, i); + pixel[offset] = static_cast((pixel[offset]+pix[offset])*alpha); + + ++offset; + if(offset > 2) + offset = 0; + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 4.5, 0.01); +} + +void ac::RGBTrailsNegativeAlpha(cv::Mat &frame) { + static MatrixCollection<8> collection; + DarkenFilter(frame); + DarkenFilter(frame); + collection.shiftFrames(frame); + static double alpha = 1.0, alpha_max = 8.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + int offset = 0; + for(int j = 0; j < collection.size(); ++j) { + cv::Vec3b pix = collection.frames[j].at(z, i); + pixel[offset] = static_cast((pixel[offset]+~pix[offset])*alpha); + + ++offset; + if(offset > 2) + offset = 0; + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 9.0, 0.005); +} + +void ac::MovementRGBTrails(cv::Mat &frame) { + static MatrixCollection<16> collection; + SmoothRGB(frame, &collection); +} + +void ac::RGBTrailsXor(cv::Mat &frame) { + RGBTrails(frame); + RandomXorOpposite(frame); +} + +void ac::DifferenceStrobe(cv::Mat &frame) { + static cv::Mat frame_copy = frame.clone(); + cv::Mat orig_frame = frame.clone(); + if(frame_copy.size() != frame.size()) { + frame_copy = frame.clone(); + } + static int offset = 0; + static double alpha = 1.0, alpha_max = 7.0; + int rand_value = rand()%255; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + if(pixel[offset]+5 >= pix[offset] && pixel[offset]-5 <= pix[offset]) { + for(int j = 0; j < 3; ++j) { + pixel[j] ^= static_cast(pixel[j]*alpha)+static_cast(pix[j]*alpha); + } + } else { + pixel[offset] = rand_value; + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + + ++offset; + if(offset > 2) + offset = 0; + + static int dir = 1; + procPos(dir, alpha, alpha_max); + frame_copy = orig_frame.clone(); +} + +void ac::BlackAndWhiteDifferenceStrobe(cv::Mat &frame) { + static cv::Mat frame_copy = frame.clone(); + cv::Mat orig_frame = frame.clone(); + if(frame_copy.size() != frame.size()) { + frame_copy = frame.clone(); + } + static int offset = 0; + static double alpha = 1.0, alpha_max = 7.0; + static int counter = 0; + static cv::Vec3b white(255, 255, 255), black(0, 0, 0); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + if(pixel[offset]+5 >= pix[offset] && pixel[offset]-5 <= pix[offset]) { + for(int j = 0; j < 3; ++j) { + pixel[j] ^= static_cast(pixel[j]*alpha)+static_cast(pix[j]*alpha); + } + } else { + if(counter == 0) + pixel = black; + else + pixel = white; + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + counter = (counter == 0) ? 1 : 0; + ++offset; + if(offset > 2) + offset = 0; + static int dir = 1; + procPos(dir, alpha, alpha_max); + frame_copy = orig_frame.clone(); +} + +void ac::DifferenceXor(cv::Mat &frame) { + static cv::Mat frame_copy = frame.clone(); + cv::Mat orig_frame = frame.clone(); + if(frame_copy.size() != frame.size()) { + frame_copy = frame.clone(); + } + static int offset = 0; + static double alpha = 1.0, alpha_max = 7.0; + cv::Vec3b pix_color(rand()%255, rand()%255, rand()%255); + static cv::Vec3b white(255, 255, 255), black(0, 0, 0); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + if(pixel[offset]+5 >= pix[offset] && pixel[offset]-5 <= pix[offset]) { + for(int j = 0; j < 3; ++j) { + pixel[j] ^= static_cast(pixel[j]*alpha)+static_cast(pix[j]*alpha); + } + } else { + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j]^pix_color[j]; + } + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + ++offset; + if(offset > 2) + offset = 0; + static int dir = 1; + procPos(dir, alpha, alpha_max); + frame_copy = orig_frame.clone(); +} + +void ac::DifferenceRand(cv::Mat &frame) { + static cv::Mat frame_copy = frame.clone(); + cv::Mat orig_frame = frame.clone(); + if(frame_copy.size() != frame.size()) { + frame_copy = frame.clone(); + } + static int offset = 0; + static double alpha = 1.0, alpha_max = 7.0; + cv::Vec3b pix_color(rand()%255, rand()%255, rand()%255); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + if(pixel[offset]+5 >= pix[offset] && pixel[offset]-5 <= pix[offset]) { + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j]^pix_color[j]; + } + } else { + for(int j = 0; j < 3; ++j) { + pixel[j] ^= static_cast(pixel[j]*alpha)+static_cast(pix[j]*alpha); + } + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + ++offset; + if(offset > 2) + offset = 0; + static int dir = 1; + procPos(dir, alpha, alpha_max); + frame_copy = orig_frame.clone(); +} + +void ac::DifferenceBrightStrobe(cv::Mat &frame) { + static cv::Mat frame_copy = frame.clone(); + cv::Mat orig_frame = frame.clone(); + if(frame_copy.size() != frame.size()) { + frame_copy = frame.clone(); + } + static int offset = 0; + static double alpha = 1.0, alpha_max = 7.0; + static int sw = 0; + cv::Vec3b rand_pix(rand()%255, rand()%255, rand()%255); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + if(pixel[offset]+5 >= pix[offset] && pixel[offset]-5 <= pix[offset]) { + for(int j = 0; j < 3; ++j) { + if(sw == 0) + pixel[j] = ~pixel[j]; + else + pixel[j] ^= static_cast((pixel[j]^rand_pix[j])*alpha); + } + } else { + for(int j = 0; j < 3; ++j) { + if(sw == 1) + pixel[j] = ~pixel[j]; + else + pixel[j] ^= static_cast((pixel[j]^rand_pix[j])*alpha); + } + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + ++offset; + if(offset > 2) + offset = 0; + static int dir = 1; + + ++sw; + if(sw > 1) + sw = 0; + + procPos(dir, alpha, alpha_max); + frame_copy = orig_frame.clone(); +} + +void ac::PsycheTrails(cv::Mat &frame) { + static MatrixCollection<16> collection; + DarkenImage(frame, 8); + collection.shiftFrames(frame); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + int offset = 0; + for(int j = 0; j < collection.size(); ++j) { + cv::Vec3b pix = collection.frames[j].at(z, i); + pixel[offset] = static_cast(pixel[offset]+(pix[offset])); + ++offset; + if(offset > 2) + offset = 0; + } + swapColors(frame, z, i); + if(isNegative) invert(frame, z, i); + } + } + DifferenceXor(frame); +} + +void ac::FourSquare(cv::Mat &frame) { + static MatrixCollection<4> collection; + collection.shiftFrames(frame); + int pos_x = 0; + int pos_y = 0; + for(int i = 0; i < collection.size(); ++i) { + cv::Mat out_frame; + if(frame.cols/2 > 0 && frame.rows/2 > 0) { + cv::resize(collection.frames[i], out_frame, cv::Size(frame.cols/2,frame.rows/2)); + copyMat(out_frame, 0,0, frame, pos_x, pos_y, frame.cols/2, frame.rows/2); + } + pos_x += frame.cols/2; + if(pos_x > frame.cols-(frame.cols/2)) { + pos_x = 0; + pos_y += frame.rows/2; + } + } + AddInvert(frame); +} + +void ac::EightSquare(cv::Mat &frame) { + static MatrixCollection<8> collection; + collection.shiftFrames(frame); + int pos_x = 0; + int pos_y = 0; + for(int i = 0; i < collection.size(); ++i) { + cv::Mat out_frame; + if(frame.cols/4 > 0 && frame.rows/2 > 0) { + cv::resize(collection.frames[i], out_frame, cv::Size(frame.cols/4,frame.rows/2)); + copyMat(out_frame, 0,0, frame, pos_x, pos_y, frame.cols/4, frame.rows/2); + } + pos_x += frame.cols/4; + if(pos_x > frame.cols-(frame.cols/4)) { + pos_x = 0; + pos_y += frame.rows/2; + } + } + AddInvert(frame); +} + +void ac::DiagonalSquare(cv::Mat &frame) { + int pos_x = 0, pos_y = 0; + int col_w = (frame.cols/4)-1; + int col_h = (frame.rows/4)-1; + cv::Mat copy_frame = frame.clone(); + for(int i = 0; i < 3; ++i) { + cv::Mat out_frame; + if(col_w > 0 && col_h > 0) { + cv::resize(copy_frame, out_frame, cv::Size(col_w,col_h)); + if(pos_x >= 0 && pos_x <= frame.cols-col_w && pos_y >= 0 && pos_y <= frame.rows-col_h) + copyMat(out_frame, 0, 0, frame, pos_x, pos_y, col_w, col_h); + } + pos_x += col_w; + pos_y += col_h; + } + AddInvert(frame); +} + +void ac::DiagonalSquareRandom(cv::Mat &frame) { + + if(testSize(frame) == false) + return; + + static MatrixCollection<4> collection; + collection.shiftFrames(frame); + int pos_x = 0, pos_y = 0; + int col_w = (frame.cols/4)-1; + int col_h = (frame.rows/4)-1; + + if(col_w < 25 || col_h < 25) + return; + + Negate(frame); + for(int i = 0; i < 4; ++i) { + cv::Mat ©_frame = collection.frames[i]; + cv::Mat out_frame; + if(col_w > 0 && col_h > 0) { + cv::resize(copy_frame, out_frame, cv::Size(col_w,col_h)); + int index = 0; + DrawFunction func = getRandomFilter(index); + func(out_frame); + copyMat(out_frame, 0, 0, frame, pos_x, pos_y, col_w, col_h); + } + pos_x += col_w; + pos_y += col_h; + } + AddInvert(frame); +} + +void ac::SquareStretchDown(cv::Mat &frame) { + cv::Mat copy_frame = frame.clone(); + static int z = 10; + if(z > frame.rows-1) { + z = 10; + } + cv::Mat out_frame; + if(frame.cols > 0 && z > 0) { + cv::resize(copy_frame, out_frame, cv::Size(frame.cols,z)); + if(subfilter != -1 && ac::draw_strings[subfilter] != "SquareStretchDown") { + ac::draw_func[ac::subfilter](out_frame); + } + copyMat(out_frame, 0, 0, frame, 0, 0, frame.cols, z); + } + z += 50; + AddInvert(frame); +} + +void ac::SquareStretchRight(cv::Mat &frame) { + cv::Mat copy_frame = frame.clone(); + static int z = 10; + if(z > frame.cols-1) { + z = 10; + } + cv::Mat out_frame; + if(z > 0 && frame.rows > 0) { + cv::resize(copy_frame, out_frame, cv::Size(z,frame.rows)); + if(subfilter != -1 && ac::draw_strings[subfilter] != "SquarehStretcRight") { + ac::draw_func[ac::subfilter](out_frame); + } + copyMat(out_frame, 0, 0, frame, 0, 0, z,frame.rows); + } + z += 50; + AddInvert(frame); +} + +void ac::SquareStretchUp(cv::Mat &frame) { + cv::Mat copy_frame = frame.clone(); + cv::Mat out_frame; + static int size = 1; + static int y = frame.rows-10; + if(y < 1) { + y = frame.rows-10; + size = 1; + } + if(frame.cols > 0 && size > 0) { + cv::resize(copy_frame, out_frame, cv::Size(frame.cols, size)); + if(subfilter != -1 && ac::draw_strings[subfilter] != "SquareStretchUp") { + ac::draw_func[ac::subfilter](out_frame); + } + copyMat(out_frame, 0, 0, frame, 0, y, frame.cols, size); + } + y -= 50; + size += 50; + AddInvert(frame); +} + +void ac::SquareStretchLeft(cv::Mat &frame) { + cv::Mat copy_frame = frame.clone(); + cv::Mat out_frame; + static int size = 1; + static int y = frame.cols-10; + if(y < 1) { + y = frame.cols-10; + size = 1; + } + if(size > 0 && frame.rows > 0) { + cv::resize(copy_frame, out_frame, cv::Size(size, frame.rows)); + if(subfilter != -1 && ac::draw_strings[subfilter] != "SquareStretchLeft") { + ac::draw_func[ac::subfilter](out_frame); + } + copyMat(out_frame, 0, 0, frame, y, 0, size, frame.rows); + } + y -= 50; + size += 50; + AddInvert(frame); +} + +void ac::DarkTrails(cv::Mat &frame) { + RGBTrailsDark(frame); + Bitwise_XOR(frame); +} + +void ac::SoftFeedback(cv::Mat &frame) { + Rect source(0, 0, frame.cols-1, frame.rows-1); + cv::Mat frame_copy = frame.clone(); + + int add_w = source.w/16; + int add_h = source.h/16; + + while(source.x < frame.cols-1 && source.w > add_w) { + if(source.w > 100 && source.w > add_w && source.h > add_h) { + cv::Mat out_frame; + cv::resize(frame_copy, out_frame, cv::Size(source.w, source.h)); + copyMat(out_frame, 0, 0, frame, source.x, source.y, source.w, source.h); + } + source.x += add_w; + source.y += add_h; + source.w -= add_w*2; + source.h -= add_h*2; + } + AddInvert(frame); +} + +void ac::SoftFeedbackFrames(cv::Mat &frame) { + static MatrixCollection<16> collection; + collection.shiftFrames(frame); + Rect source(0, 0, frame.cols-1, frame.rows-1); + cv::Mat frame_copy = frame.clone(); + int add_w = source.w/16; + int add_h = source.h/16; + int offset = 0; + while(source.x < frame.cols-1 && source.w > add_w) { + if(offset < collection.size() && source.w > add_w && source.h > add_h) { + cv::Mat out_frame; + cv::resize(collection.frames[offset], out_frame, cv::Size(source.w, source.h)); + copyMat(out_frame, 0, 0, frame, source.x, source.y, source.w, source.h); + } + source.x += add_w; + source.y += add_h; + source.w -= add_w*2; + source.h -= add_h*2; + offset++; + } + AddInvert(frame); +} + +void ac::ResizeSoftFeedback(cv::Mat &frame) { + static MatrixCollection<16> collection; + collection.shiftFrames(frame); + Rect source(0, 0, frame.cols-1, frame.rows-1); + cv::Mat frame_copy = frame.clone(); + static int num_squares = 2; + int add_w = source.w/num_squares; + int add_h = source.h/num_squares; + int offset = 0; + while(source.x < frame.cols-1 && source.w > add_w) { + if(offset < collection.size() && source.w > add_w && source.h > add_h) { + cv::Mat out_frame; + cv::resize(collection.frames[offset], out_frame, cv::Size(source.w, source.h)); + copyMat(out_frame, 0, 0, frame, source.x, source.y, source.w, source.h); + } + source.x += add_w; + source.y += add_h; + source.w -= add_w*2; + source.h -= add_h*2; + offset++; + } + static int dir = 1; + if(dir == 1) { + num_squares += 2; + if(num_squares >= 16) + dir = 0; + } else if(dir == 0) { + num_squares -= 2; + if(num_squares <= 2) + dir = 1; + } + AddInvert(frame); +} + + +void ac::SoftFeedback8(cv::Mat &frame) { + Rect source(0, 0, frame.cols-1, frame.rows-1); + cv::Mat frame_copy = frame.clone(); + + int add_w = source.w/8; + int add_h = source.h/8; + + while(source.x < frame.cols-1 && source.w > add_w) { + if(source.w > add_w && source.h > add_h) { + cv::Mat out_frame; + cv::resize(frame_copy, out_frame, cv::Size(source.w, source.h)); + copyMat(out_frame, 0, 0, frame, source.x, source.y, source.w, source.h); + } + source.x += add_w; + source.y += add_h; + source.w -= add_w*2; + source.h -= add_h*2; + } + AddInvert(frame); +} +void ac::SoftFeedbackFrames8(cv::Mat &frame) { + static MatrixCollection<8> collection; + collection.shiftFrames(frame); + Rect source(0, 0, frame.cols-1, frame.rows-1); + cv::Mat frame_copy = frame.clone(); + int add_w = source.w/8; + int add_h = source.h/8; + int offset = 0; + while(source.x < frame.cols-1 && source.w > add_w) { + if(offset < collection.size() && source.w > add_w && source.h > add_h) { + cv::Mat out_frame; + cv::resize(collection.frames[offset], out_frame, cv::Size(source.w, source.h)); + copyMat(out_frame, 0, 0, frame, source.x, source.y, source.w, source.h); + } + source.x += add_w; + source.y += add_h; + source.w -= add_w*2; + source.h -= add_h*2; + offset++; + } + AddInvert(frame); +} +void ac::ResizeSoftFeedback8(cv::Mat &frame) { + static MatrixCollection<8> collection; + collection.shiftFrames(frame); + Rect source(0, 0, frame.cols-1, frame.rows-1); + cv::Mat frame_copy = frame.clone(); + static int num_squares = 2; + int add_w = source.w/num_squares; + int add_h = source.h/num_squares; + int offset = 0; + while(source.x < frame.cols-1 && source.w > add_w) { + if(offset < collection.size() && source.w > add_w && source.h > add_h) { + cv::Mat out_frame; + cv::resize(collection.frames[offset], out_frame, cv::Size(source.w, source.h)); + copyMat(out_frame, 0, 0, frame, source.x, source.y, source.w, source.h); + } + source.x += add_w; + source.y += add_h; + source.w -= add_w*2; + source.h -= add_h*2; + offset++; + } + static int dir = 1; + if(dir == 1) { + num_squares += 2; + if(num_squares >= 8) + dir = 0; + } else if(dir == 0) { + num_squares -= 2; + if(num_squares <= 2) + dir = 1; + } + AddInvert(frame); +} + +void ac::ResizeSoftFeedbackSubFilter(cv::Mat &frame) { + if(subfilter != -1 && ac::draw_strings[subfilter] != "ResizeSoftFeedbackSubFilter") { + static MatrixCollection<16> collection; + collection.shiftFrames(frame); + Rect source(0, 0, frame.cols-1, frame.rows-1); + cv::Mat frame_copy = frame.clone(); + static int num_squares = 2; + int add_w = source.w/num_squares; + int add_h = source.h/num_squares; + int offset = 0; + while(source.x < frame.cols-1 && source.w > add_w) { + if(offset < collection.size() && source.w > add_w && source.h > add_h) { + cv::Mat out_frame; + cv::resize(collection.frames[offset], out_frame, cv::Size(source.w, source.h)); + ac::draw_func[ac::subfilter](out_frame); + copyMat(out_frame, 0, 0, frame, source.x, source.y, source.w, source.h); + } + source.x += add_w; + source.y += add_h; + source.w -= add_w*2; + source.h -= add_h*2; + offset++; + } + static int dir = 1; + if(dir == 1) { + num_squares += 2; + if(num_squares >= 16) + dir = 0; + } else if(dir == 0) { + num_squares -= 2; + if(num_squares <= 2) + dir = 1; + } + AddInvert(frame); + } +} + +void ac::SoftFeedbackRandFilter(cv::Mat &frame) { + static DrawFunction func[10] = {DifferenceXor, RandomXorOpposite, FadeInAndOut, FadeStrobe, AndPixelStrobe, AndStrobe, AndStrobeScale, AndPixelStrobe, AndOrXorStrobe, AndOrXorStrobeScale }; + + Rect source(0, 0, frame.cols-1, frame.rows-1); + cv::Mat frame_copy = frame.clone(); + int add_w = source.w/16; + int add_h = source.h/16; + while(source.x < frame.cols-1 && source.w > add_w) { + if(source.w > add_w && source.h > add_h) { + cv::Mat out_frame; + cv::resize(frame_copy, out_frame, cv::Size(source.w, source.h)); + func[rand()%10](out_frame); + copyMat(out_frame, 0, 0, frame, source.x, source.y, source.w, source.h); + } + source.x += add_w; + source.y += add_h; + source.w -= add_w*2; + source.h -= add_h*2; + } + AddInvert(frame); +} + +void ac::SoftFeedback32(cv::Mat &frame) { + Rect source(0, 0, frame.cols-1, frame.rows-1); + cv::Mat frame_copy = frame.clone(); + + int add_w = source.w/32; + int add_h = source.h/32; + + while(source.x < frame.cols-1 && source.w > add_w) { + if(source.w > 100 && source.h > 100) { + cv::Mat out_frame; + cv::resize(frame_copy, out_frame, cv::Size(source.w, source.h)); + copyMat(out_frame, 0, 0, frame, source.x, source.y, source.w, source.h); + } + source.x += add_w; + source.y += add_h; + source.w -= add_w*2; + source.h -= add_h*2; + } + AddInvert(frame); +} +void ac::SoftFeedbackFrames32(cv::Mat &frame) { + static MatrixCollection<24> collection; + collection.shiftFrames(frame); + Rect source(0, 0, frame.cols-1, frame.rows-1); + cv::Mat frame_copy = frame.clone(); + int add_w = source.w/32; + int add_h = source.h/32; + int offset = 0; + while(source.x < frame.cols-1 && source.w > add_w) { + if(offset < collection.size() && source.w > add_w+10 && source.h > add_h+10) { + cv::Mat out_frame; + cv::resize(collection.frames[offset], out_frame, cv::Size(source.w, source.h)); + copyMat(out_frame, 0, 0, frame, source.x, source.y, source.w, source.h); + } + source.x += add_w; + source.y += add_h; + source.w -= add_w*2; + source.h -= add_h*2; + offset++; + } + AddInvert(frame); +} + +void ac::ResizeSoftFeedback32(cv::Mat &frame) { + static MatrixCollection<32> collection; + collection.shiftFrames(frame); + Rect source(0, 0, frame.cols-1, frame.rows-1); + cv::Mat frame_copy = frame.clone(); + static int num_squares = 2; + int add_w = source.w/num_squares; + int add_h = source.h/num_squares; + static const int MAX_SQUARES=32; + int offset = 0; + while(source.x < frame.cols-1 && source.w > add_w+10 && source.h > add_h+10) { + if(offset < collection.size() && source.w > add_w && source.h > add_h) { + cv::Mat out_frame; + cv::resize(collection.frames[offset], out_frame, cv::Size(source.w, source.h)); + copyMat(out_frame, 0, 0, frame, source.x, source.y, source.w, source.h); + } + source.x += add_w; + source.y += add_h; + source.w -= add_w*2; + source.h -= add_h*2; + offset++; + } + static int dir = 1; + if(dir == 1) { + num_squares += 2; + if(num_squares >= MAX_SQUARES) + dir = 0; + } else if(dir == 0) { + num_squares -= 2; + if(num_squares <= 2) + dir = 1; + } + AddInvert(frame); +} + +void ac::SoftFeedbackRandFilter32(cv::Mat &frame) { + static DrawFunction func[10] = {DifferenceXor, RandomXorOpposite, FadeInAndOut, FadeStrobe, AndPixelStrobe, AndStrobe, AndStrobeScale, AndPixelStrobe, AndOrXorStrobe, AndOrXorStrobeScale }; + + Rect source(0, 0, frame.cols-1, frame.rows-1); + cv::Mat frame_copy = frame.clone(); + int add_w = source.w/32; + int add_h = source.h/32; + while(source.x < frame.cols-1 && source.w > add_w+10 && source.h > add_h+10) { + if(source.w > add_w && source.h > add_h) { + cv::Mat out_frame; + cv::resize(frame_copy, out_frame, cv::Size(source.w, source.h)); + func[rand()%10](out_frame); + copyMat(out_frame, 0, 0, frame, source.x, source.y, source.w, source.h); + } + source.x += add_w; + source.y += add_h; + source.w -= add_w*2; + source.h -= add_h*2; + } + AddInvert(frame); +} + + +void ac::SoftFeedbackSubFilter(cv::Mat &frame) { + + + if(subfilter != -1 && ac::draw_strings[subfilter] == "SoftFeedbackSubFilter") + return; + + Rect source(0, 0, frame.cols-1, frame.rows-1); + cv::Mat frame_copy = frame.clone(); + int add_w = source.w/32; + int add_h = source.h/32; + while(source.x < frame.cols-1 && source.w > add_w+10 && source.h > add_h+10) { + if(source.w > 100 && source.h > 100) { + cv::Mat out_frame; + cv::resize(frame_copy, out_frame, cv::Size(source.w, source.h)); + size_t rand_test = 0; + if(subfilter != -1) rand_test = ac::draw_strings[subfilter].find("Rand"); + if(testSize(out_frame) && rand_test == std::string::npos && subfilter != -1 && ac::draw_strings[subfilter] != "SoftFeedbackSubFilter" && ac::draw_strings[subfilter] != "Random Filter") { + ac::draw_func[ac::subfilter](out_frame); + } + copyMat(out_frame, 0, 0, frame, source.x, source.y, source.w, source.h); + } + source.x += add_w; + source.y += add_h; + source.w -= add_w*2; + source.h -= add_h*2; + } + AddInvert(frame); + +} +void ac::SoftFeedbackResizeSubFilter(cv::Mat &frame) { + + if(subfilter != -1 && ac::draw_strings[subfilter] == "SoftFeedbackResizeSubFilter") + return; + + static MatrixCollection<32> collection; + collection.shiftFrames(frame); + Rect source(0, 0, frame.cols-1, frame.rows-1); + cv::Mat frame_copy = frame.clone(); + static int num_squares = 2; + int add_w = source.w/num_squares; + int add_h = source.h/num_squares; + static const int MAX_SQUARES=32; + int offset = 0; + while(source.x < frame.cols-1 && source.w > add_w+10 && source.h > add_h+10) { + if(offset < collection.size() && source.w > add_w && source.h > add_h) { + cv::Mat out_frame; + cv::resize(collection.frames[offset], out_frame, cv::Size(source.w, source.h)); + size_t rand_test = 0; + if(subfilter != -1) rand_test = ac::draw_strings[subfilter].find("Rand"); + if(testSize(out_frame) && rand_test == std::string::npos && subfilter != -1 && ac::draw_strings[subfilter] != "SoftFeedbackResizeSubFilter" && ac::draw_strings[subfilter] != "Random Filter") { + ac::draw_func[ac::subfilter](out_frame); + } + copyMat(out_frame, 0, 0, frame, source.x, source.y, source.w, source.h); + } + source.x += add_w; + source.y += add_h; + source.w -= add_w*2; + source.h -= add_h*2; + offset++; + } + static int dir = 1; + if(dir == 1) { + num_squares += 2; + if(num_squares >= MAX_SQUARES) + dir = 0; + } else if(dir == 0) { + num_squares -= 2; + if(num_squares <= 2) + dir = 1; + } + AddInvert(frame); +} + +void ac::SoftFeedbackResizeSubFilter64(cv::Mat &frame) { + + if(subfilter != -1 && ac::draw_strings[subfilter] == "SoftFeedbackResizeSubFilter64") + return; + + static MatrixCollection<64> collection; + collection.shiftFrames(frame); + Rect source(0, 0, frame.cols-1, frame.rows-1); + cv::Mat frame_copy = frame.clone(); + static int num_squares = 2; + int add_w = source.w/num_squares; + int add_h = source.h/num_squares; + static const int MAX_SQUARES=64; + int offset = 0; + while(source.x >= 0 && source.x < frame.cols-1 && source.w > add_w+10 && source.h > add_h+10) { + if(offset >= 0 && offset < collection.size() && source.w > add_w && source.h > add_h) { + cv::Mat out_frame; + cv::resize(collection.frames[offset], out_frame, cv::Size(source.w, source.h)); + size_t rand_test = 0; + if(subfilter != -1) rand_test = ac::draw_strings[subfilter].find("Rand"); + if(testSize(out_frame) && rand_test == std::string::npos && subfilter != -1 && ac::draw_strings[subfilter] != "SoftFeedbackResizeSubFilter64") { + ac::draw_func[ac::subfilter](out_frame); + } + copyMat(out_frame, 0, 0, frame, source.x, source.y, source.w, source.h); + } + source.x += add_w; + source.y += add_h; + source.w -= add_w*2; + source.h -= add_h*2; + offset++; + } + static int dir = 1; + if(dir == 1) { + num_squares += 2; + if(num_squares >= MAX_SQUARES) + dir = 0; + } else if(dir == 0) { + num_squares -= 2; + if(num_squares <= 2) + dir = 1; + } + AddInvert(frame); +} + +void ac::SoftFeedbackResize64(cv::Mat &frame) { + + static MatrixCollection<64> collection; + collection.shiftFrames(frame); + Rect source(0, 0, frame.cols-1, frame.rows-1); + cv::Mat frame_copy = frame.clone(); + static int num_squares = 2; + int add_w = source.w/num_squares; + int add_h = source.h/num_squares; + static const int MAX_SQUARES=64; + int offset = 0; + while(source.x >= 0 && source.x < frame.cols-1 && source.w > add_w+10 && source.h > add_h+10) { + if(offset >= 0 && offset < collection.size() && source.w > add_w && source.h > add_h) { + cv::Mat out_frame; + cv::resize(collection.frames[offset], out_frame, cv::Size(source.w, source.h)); + copyMat(out_frame, 0, 0, frame, source.x, source.y, source.w, source.h); + } + source.x += add_w; + source.y += add_h; + source.w -= add_w*2; + source.h -= add_h*2; + offset++; + } + static int dir = 1; + if(dir == 1) { + num_squares += 2; + if(num_squares >= MAX_SQUARES) + dir = 0; + } else if(dir == 0) { + num_squares -= 2; + if(num_squares <= 2) + dir = 1; + } + AddInvert(frame); +} + +void ac::SoftFeedbackReszieSubFilter64_Negate(cv::Mat &frame) { + + if(subfilter != -1 && ac::draw_strings[subfilter] == "SoftFeedbackReszieSubFilter64_Negate") + return; + + static MatrixCollection<64> collection; + collection.shiftFrames(frame); + Rect source(0, 0, frame.cols-1, frame.rows-1); + cv::Mat frame_copy = frame.clone(); + static int num_squares = 2; + int add_w = source.w/num_squares; + int add_h = source.h/num_squares; + static const int MAX_SQUARES=64; + int offset = 0; + while(source.x < frame.cols-1 && source.w > add_w) { + if(offset < collection.size() && source.w > add_w && source.h > add_h) { + cv::Mat out_frame; + cv::resize(collection.frames[offset], out_frame, cv::Size(source.w, source.h)); + size_t rand_test = 0; + if(subfilter != -1) rand_test = ac::draw_strings[subfilter].find("Rand"); + + if(testSize(out_frame) && rand_test != std::string::npos && subfilter != -1 && ac::draw_strings[subfilter] != "SoftFeedbackResizeSubFilter64" && ac::draw_strings[subfilter] != "Random Filter") { + ac::draw_func[ac::subfilter](out_frame); + } + if((offset%2) == 0) + Negate(out_frame); + + copyMat(out_frame, 0, 0, frame, source.x, source.y, source.w, source.h); + } + source.x += add_w; + source.y += add_h; + source.w -= add_w*2; + source.h -= add_h*2; + offset++; + } + static int dir = 1; + if(dir == 1) { + num_squares += 2; + if(num_squares >= MAX_SQUARES) + dir = 0; + } else if(dir == 0) { + num_squares -= 2; + if(num_squares <= 2) + dir = 1; + } + AddInvert(frame); +} + +void ac::SoftFeedbackReszieSubFilter64_Mirror(cv::Mat &frame) { + + + if(subfilter != -1 && ac::draw_strings[subfilter] == "SoftFeedbackReszieSubFilter64_Mirror") + return; + + + static MatrixCollection<64> collection; + collection.shiftFrames(frame); + Rect source(0, 0, frame.cols-1, frame.rows-1); + cv::Mat frame_copy = frame.clone(); + static int num_squares = 2; + int add_w = source.w/num_squares; + int add_h = source.h/num_squares; + static const int MAX_SQUARES=64; + int offset = 0; + while(source.x < frame.cols-1 && source.w > add_w) { + if(offset < collection.size() && source.w > add_w && source.h > add_h) { + cv::Mat out_frame; + cv::resize(collection.frames[offset], out_frame, cv::Size(source.w, source.h)); + size_t rand_test = 0; + if(subfilter != -1) rand_test = ac::draw_strings[subfilter].find("Rand"); + + if(testSize(out_frame) && rand_test != std::string::npos && subfilter != -1 && ac::draw_strings[subfilter] != "SoftFeedbackResizeSubFilter64" && ac::draw_strings[subfilter] != "Random Filter") { + ac::draw_func[ac::subfilter](out_frame); + } + if((offset%2) == 0) + Reverse(out_frame); + + copyMat(out_frame, 0, 0, frame, source.x, source.y, source.w, source.h); + } + source.x += add_w; + source.y += add_h; + source.w -= add_w*2; + source.h -= add_h*2; + offset++; + } + static int dir = 1; + if(dir == 1) { + num_squares += 2; + if(num_squares >= MAX_SQUARES) + dir = 0; + } else if(dir == 0) { + num_squares -= 2; + if(num_squares <= 2) + dir = 1; + } + AddInvert(frame); +} + diff --git a/windows/Acid.Cam.Qt.Windows.Project/ac-filter9.cpp b/windows/Acid.Cam.Qt.Windows.Project/ac-filter9.cpp new file mode 100755 index 0000000..1624f53 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/ac-filter9.cpp @@ -0,0 +1,1061 @@ +/* + * Software written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + +#include "ac.h" + + +void ac::HalfNegateStrobe(cv::Mat &frame) { + int f_len = frame.cols/2; + auto neg = [](cv::Vec3b &pixel) { + for(int j = 0; j < 3; ++j) + pixel[j] = ~pixel[j]; + }; + static int off = 0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < f_len; ++i) { + if(off == 0) { + cv::Vec3b &pixel = frame.at(z, i); + neg(pixel); + } + + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + for(int i = f_len; i < frame.cols; ++i) { + if(off == 1) { + cv::Vec3b &pixel = frame.at(z, i); + neg(pixel); + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + ++off; + if(off >= 2) { + off = 0; + } +} + +void ac::MedianBlurXor(cv::Mat &frame) { + cv::Mat copy_f = frame.clone(); + MedianBlend(frame); + Negate(frame); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b v = copy_f.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j] ^ v[j]; + } + } + } + Negate(frame); + AddInvert(frame); +} + +void ac::NegateTrails(cv::Mat &frame) { + MovementRGBTrails(frame); + MedianBlur(frame); + RGBTrailsDark(frame); + MedianBlur(frame); + Negate(frame); + AddInvert(frame); +} + +void ac::RandomGradient(cv::Mat &frame) { + static std::vector svGradient { "CosSinMultiply","New Blend","Color Accumlate1", "Color Accumulate2", "Color Accumulate3", "Filter8", "Graident Rainbow","Gradient Rainbow Flash","Outward", "Outward Square","GradientLines","GradientSelf","GradientSelfVertical","GradientDown","GraidentHorizontal","GradientRGB","GradientStripes", "GradientReverse", "GradientReverseBox", "GradientReverseVertical", "GradientNewFilter", "AverageLines", "QuadCosSinMultiply", "GradientColors", "GradientColorsVertical", "GradientXorSelfScale", "GradientLeftRight", "GraidentUpDown", "GradientLeftRightInOut", "GradientUpDownInOut"}; + CallFilter(svGradient[rand()%svGradient.size()], frame); + AddInvert(frame); +} + +void ac::RandomStrobeFlash(cv::Mat &frame) { + static std::vector svStrobe{ "StrobeEffect", "Blank", "Type","Random Flash","Strobe Red Then Green Then Blue","StrobeScan", "RGBFlash", "ReinterpretDouble", "BitwiseXorStrobe","StrobeBlend", "FibFlash", "ScaleFlash", "FadeStrobe", "AndStrobe", "AndStrobeScale", "AndPixelStrobe", "AndOrXorStrobe", "AndOrXorStrobeScale", "BrightStrobe", "DarkStrobe", "RandomXorOpposite", "StrobeTransform", "OrStrobe", "DifferenceStrobe", "DifferenceXor", "DifferenceRand"}; + CallFilter(svStrobe[rand()%svStrobe.size()], frame); + AddInvert(frame); +} + +void ac::RandomMirror(cv::Mat &frame) { + static std::vector svMirror { "NewOne", "MirrorBlend", "Sideways Mirror","Mirror No Blend","Mirror Average", "Mirror Average Mix","Reverse","Double Vision","RGB Shift","RGB Sep","Side2Side","Top2Bottom", "Soft_Mirror", "KanapaTrip", "InterReverse", "InterMirror", "InterFullMirror", "MirrorRGB", "LineByLineReverse", "CycleShiftRGB", "CycleShiftRandomRGB", "CycleShiftRandomRGB_XorBlend", "RGBMirror", "MirrorStrobe"}; + CallFilter(svMirror[rand()%svMirror.size()], frame); + AddInvert(frame); +} + +void ac::RandomOther(cv::Mat &frame) { + static std::vector svOther_Custom { "Mean", "Laplacian", "Bitwise_XOR", "Bitwise_AND", "Bitwise_OR", "Channel Sort", "Reverse_XOR","Bitwise_Rotate","Bitwise_Rotate Diff", "Equalize","PixelSort", "GlitchSort","HPPD","FuzzyLines","Alpha Flame Filters","Scanlines", "TV Static","FlipTrip", "Canny","Inter","Circular","MoveRed","MoveRGB", "MoveRedGreenBlue", "Wave","HighWave","VerticalSort","VerticalChannelSort","ScanSwitch", "ScanAlphaSwitch","XorAddMul", "RandomIntertwine","RandomFour","RandomTwo","Darken","AverageRandom","RandomCollectionAverage","RandomCollectionAverageMax","BitwiseXorScale","XorChannelSort","Bitwise_XOR_Average","NotEqual","Sort_Vertical_Horizontal","Sort_Vertical_Horizontal_Bitwise_XOR", "Scalar_Average_Multiply","Scalar_Average","Total_Average","VerticalColorBars","inOrder","inOrderBySecond","DarkenFilter","RandomFilterBySecond","ThreeRandom","inOrderAlpha","XorBackwards", "MoveUpLeft", "Stuck", "StuckStrobe", "SoftFeedback", "SoftFeedbackFrames", "ResizeSoftFeedback", "SoftFeedback8","SoftFeedbackFrames8","ResizeSoftFeedback8", "ResizeSoftFeedbackSubFilter", "SoftFeedbackRandFilter", "SoftFeedback32","SoftFeedbackFrames32","ResizeSoftFeedback32", "SoftFeedbackRandFilter32", "SoftFeedbackSubFilter","SoftFeedbackResizeSubFilter", "SoftFeedbackResizeSubFilter64", "SoftFeedbackReszieSubFilter64_Negate", "SoftFeedbackReszieSubFilter64_Mirror"}; + CallFilter(svOther_Custom[rand()%svOther_Custom.size()], frame); + AddInvert(frame); +} + +void ac::RandomXorFilter(cv::Mat &frame) { + static std::vector Xor {"XorMultiBlend", "XorSine", "TrailsFilterXor", "BlockXor", "XorAddMul", "SurroundPixelXor", "BlendAlphaXor", "SelfXorScale","XorTrails","XorChannelSort", "GradientXorSelfScale", "RandomXor", "RandomXorFlash", "SoftXor", "SelfXorBlend", "SelfXorDoubleFlash", "CycleShiftRandomRGB_XorBlend", "inOrderAlphaXor", "SlideFilterXor", "SlideUpDownXor", "XorBackwards", "MatrixXorAnd", "XorAlpha", "SelfXorAverage", "RandomXorBlend", "RGBVerticalXor", "RGBVerticalXorScale", "RGBHorizontalXor", "RGBHorizontalXorScale", "AndOrXorStrobe", "AndOrXorStrobeScale", "RandomXorOpposite","RGBTrailsXor", "DifferenceXor","MedianBlurXor"}; + CallFilter(Xor[rand()%Xor.size()], frame); + AddInvert(frame); +} + +void ac::RandomMirrorBlend(cv::Mat &frame) { + cv::Mat frame_copy = frame.clone(); + RandomMirror(frame_copy); + static double alpha = 1.0, alpha_max = 7.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast((pixel[j]^pix[j])*alpha); + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 10.0, 0.005); + AddInvert(frame); +} + +void ac::RandomMirrorAlphaBlend(cv::Mat &frame) { + DarkenImage(frame, 4); + cv::Mat frame_copy = frame.clone(); + RandomMirror(frame_copy); + static double alpha = 1.0, alpha_max = 7.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast((pixel[j]*alpha)+(pix[j]*alpha)); + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); + AddInvert(frame); +} + +void ac::Bitwise_XOR_AlphaSubFilter(cv::Mat &frame) { + if(subfilter == -1) + return; + if(ac::draw_strings[subfilter] == "Bitwise_XOR_AlphaSubFilter") + return; + cv::Mat frame_copy = frame.clone(); + static double alpha = 1.0, alpha_max = 7.0; + CallFilter(subfilter, frame_copy); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast((pixel[j]^pix[j])*alpha); + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 10, 0.005); + AddInvert(frame); +} + +void ac::AlphaBlendSubFilter(cv::Mat &frame) { + if(subfilter == -1) + return; + if(ac::draw_strings[subfilter] == "AlphaBlendSubFilter") + return; + double alpha = 1.0, alpha_max = 7.0; + cv::Mat frame_copy = frame.clone(); + cv::Mat output_copy = frame.clone(); + CallFilter(subfilter, frame_copy); + AlphaBlend(frame_copy, output_copy, frame, alpha); + static int dir = 1; + procPos(dir, alpha, alpha_max, 10, 0.005); + AddInvert(frame); +} + +void ac::GradientSubFilterXor(cv::Mat &frame) { + if(subfilter == -1) + return; + if(ac::draw_strings[subfilter] == "GradientSubFilterXor") + return; + cv::Mat frame_copy = frame.clone(); + CallFilter(subfilter, frame_copy); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = (pixel[j]+z)^(pix[j]+i); + } + } + } + AddInvert(frame); +} + +void ac::XorBlend_SubFilter(cv::Mat &frame) { + if(subfilter == -1) + return; + if(ac::draw_strings[subfilter] == "XorBlend_SubFilter") + return; + cv::Mat frame_copy = frame.clone(); + static double alpha = 1.0, alpha_max = 7.0; + CallFilter(subfilter, frame_copy); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + for(int j = 0; j < 3; ++j) { + unsigned int alpha_val = static_cast(1+alpha); + pixel[j] = (static_cast((pixel[j]*alpha_val))) ^ (static_cast((pix[j]*alpha_val))); + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 10, 0.005); + AddInvert(frame); +} + +void ac::SmoothSubFilterAlphaBlend(cv::Mat &frame) { + if(subfilter == -1) + return; + if(ac::draw_strings[subfilter] == "SmoothSubFilterAlphaBlend") + return; + static MatrixCollection<8> collection; + cv::Mat frame_copy = frame.clone(); + cv::Mat same_copy = frame.clone(); + CallFilter(subfilter, frame_copy); + collection.shiftFrames(frame_copy); + Smooth(frame_copy, &collection); + static double alpha = 1.0, alpha_max = 3.0; + AlphaBlend(frame_copy, same_copy, frame, alpha); + static int dir = 1; + procPos(dir, alpha, alpha_max, 4.0, 0.1); + AddInvert(frame); +} + +void ac::SmoothSubFilterXorBlend(cv::Mat &frame) { + if(subfilter == -1) + return; + if(ac::draw_strings[subfilter] == "SmoothSubFilterXorBlend") + return; + static MatrixCollection<8> collection; + cv::Mat frame_copy = frame.clone(); + cv::Mat same_copy = frame.clone(); + CallFilter(subfilter, frame_copy); + collection.shiftFrames(frame_copy); + Smooth(frame_copy, &collection); + static double alpha = 1.0, alpha_max = 3.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] = (static_cast(pixel[j]*alpha)) ^ (static_cast(pix[j]*alpha)); + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 4.0, 0.1); + AddInvert(frame); +} + +void ac::IntertwineSubFilter(cv::Mat &frame) { + if(subfilter == -1) + return; + if(ac::draw_strings[subfilter] == "IntertwineSubFilter") + return; + + cv::Mat frame_copy = frame.clone(); + CallFilter(subfilter, frame_copy); + bool skip_val = true; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + if(skip_val == true) { + pixel = pix; + } + } + skip_val = (skip_val == true) ? false : true; + } + AddInvert(frame); +} + +void ac::RandBlend(cv::Mat &frame) { + static std::vector filter_names {"Self AlphaBlend", "Blend #3", "RandTriBlend", "Rainbow Blend", "Rand Blend","XorMultiBlend", "BlendedScanLines", "FrameBlend", "FrameBlendRGB", "PrevFrameBlend", "HorizontalBlend", "VerticalBlend", "OppositeBlend", "BlendSwitch", "IncreaseBlendHorizontal", "BlendIncrease","TrailsBlend", "BlendThree", "BlendTrails", "WeakBlend", "SmoothTrailsSelfAlphaBlend", "SmoothTrailsRainbowBlend","RandomAlphaBlend", "RandomTwoFilterAlphaBlend", "AlphaBlendPosition", "BlendAlphaXor", "AlphaBlendRandom", "ChannelSortAlphaBlend", "StrobeBlend", "GaussianBlend", "SelfXorBlend","CycleShiftRandomRGB_XorBlend", "CycleShiftRandomAlphaBlend","ParticleBlend", "BlendInAndOut", "BlendScaleInAndOut", "RandomXorBlend", "InitBlend"}; + + CallFilter(filter_names[rand()%filter_names.size()], frame); + AddInvert(frame); +} + +void ac::EveryOther(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 6.0; + bool on_off = true; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + if(on_off == true) { + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast(pixel[j]*alpha); + } + } + on_off = (on_off == true) ? false : true; + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); + AddInvert(frame); +} + +void ac::EveryOtherSubFilter(cv::Mat &frame) { + if(subfilter == -1) + return; + if(ac::draw_strings[subfilter] == "EveryOtherSubFilter") + return; + + cv::Mat frame_copy = frame.clone(); + CallFilter(subfilter, frame_copy); + bool on_off = true; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + if(on_off == true) { + cv::Vec3b pix = frame_copy.at(z, i); + pixel = pix; + } + on_off = (on_off == true) ? false : true; + } + } + AddInvert(frame); +} + +void ac::SmoothRandomFilter(cv::Mat &frame) { + static MatrixCollection<8> collection; + randomFilter(frame); + collection.shiftFrames(frame); + Smooth(frame, &collection); + AddInvert(frame); +} + +void ac::RandomFilterRandomTimes(cv::Mat &frame) { + randomFilter(frame); + int num = rand()%4; + for(int i = 0; i < num; ++i) { + randomFilter(frame); + } + AddInvert(frame); +} + +void ac::RandomSubFilterRandomTimes(cv::Mat &frame) { + if(subfilter == -1) + return; + if(ac::draw_strings[subfilter] == "RandomSubFilterRandomTimes") + return; + CallFilter(subfilter, frame); + int num = rand()%4; + for(int i = 0; i < num; ++i) { + CallFilter(subfilter, frame); + } + AddInvert(frame); +} + +void ac::AddToFrameSubFilter(cv::Mat &frame) { + if(subfilter == -1) + return; + if(ac::draw_strings[subfilter] == "AddToFrameSubFilter") + return; + + cv::Mat frame_copy = frame.clone(); + CallFilter(subfilter, frame_copy); + Add(frame, frame_copy); + AddInvert(frame); +} + +void ac::MirrorXor(cv::Mat &frame) { + cv::Mat frame_copy = frame.clone(); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b val = frame_copy.at(frame.rows-z-1, frame.cols-i-1); + for(int j = 0; j < 3; ++j) { + pixel[j] = (pixel[j] ^ val[j]); + } + } + } + AddInvert(frame); +} + +void ac::MirrorXorAll(cv::Mat &frame) { + cv::Mat frame_copy = frame.clone(); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b values[3]; + values[0] = frame_copy.at(frame.rows-z-1, frame.cols-i-1); + values[1] = frame_copy.at(frame.rows-z-1, i); + values[2] = frame_copy.at(z, frame.cols-i-1); + for(int j = 0; j < 3; ++j) { + pixel[j] = (pixel[j] ^ values[0][j] ^ values[1][j] ^ values[2][j]); + } + } + } + AddInvert(frame); +} + +void ac::MirrorXorScale(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 4.0; + cv::Mat frame_copy = frame.clone(); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b values[3]; + values[0] = frame_copy.at(frame.rows-z-1, frame.cols-i-1); + values[1] = frame_copy.at(frame.rows-z-1, i); + values[2] = frame_copy.at(z, frame.cols-i-1); + for(int j = 0; j < 3; ++j) { + pixel[j] = (pixel[j] ^ values[0][j] ^ values[1][j] ^ values[2][j]); + pixel[j] = static_cast(pixel[j]*alpha); + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 5.0, 0.01); + AddInvert(frame); +} + +void ac::EnergyMirror(cv::Mat &frame) { + static MatrixCollection<8> collection; + cv::Mat frame_copy = frame.clone(); + MirrorXorAll(frame_copy); + collection.shiftFrames(frame_copy); + Smooth(frame, &collection); + MedianBlend(frame); + AddInvert(frame); +} + +void ac::SmoothSubFilter(cv::Mat &frame) { + if(subfilter == -1) + return; + if(ac::draw_strings[subfilter] == "SmoothSubFilter") + return; + static MatrixCollection<8> collection; + cv::Mat frame_copy = frame.clone(); + CallFilter(subfilter, frame_copy); + collection.shiftFrames(frame_copy); + Smooth(frame, &collection); + AddInvert(frame); +} + +void ac::EnergizeSubFilter(cv::Mat &frame) { + if(subfilter == -1) + return; + if(ac::draw_strings[subfilter] == "EnergizeSubFilter") + return; + static MatrixCollection<8> collection; + cv::Mat frame_copy = frame.clone(); + CallFilter(subfilter, frame_copy); + collection.shiftFrames(frame_copy); + Smooth(frame, &collection); + MedianBlend(frame); + AddInvert(frame); +} + +void ac::SmoothSubFilter16(cv::Mat &frame) { + if(subfilter == -1) + return; + if(ac::draw_strings[subfilter] == "SmoothSubFilter16") + return; + static MatrixCollection<16> collection; + cv::Mat frame_copy = frame.clone(); + CallFilter(subfilter, frame_copy); + collection.shiftFrames(frame_copy); + Smooth(frame, &collection); + AddInvert(frame); +} + +void ac::EnergizeSubFilter16(cv::Mat &frame) { + if(subfilter == -1) + return; + if(ac::draw_strings[subfilter] == "EnergizeSubFilter16") + return; + static MatrixCollection<16> collection; + cv::Mat frame_copy = frame.clone(); + CallFilter(subfilter, frame_copy); + collection.shiftFrames(frame_copy); + Smooth(frame, &collection); + MedianBlend(frame); + AddInvert(frame); +} + +void ac::EnergizeSubFilter32(cv::Mat &frame) { + if(subfilter == -1) + return; + if(ac::draw_strings[subfilter] == "EnergizeSubFilter32") + return; + + static MatrixCollection<32> collection; + cv::Mat frame_copy = frame.clone(); + CallFilter(subfilter, frame_copy); + collection.shiftFrames(frame_copy); + Smooth(frame, &collection); + MedianBlend(frame); + AddInvert(frame); +} + +void ac::SmoothSubFilter32(cv::Mat &frame) { + if(subfilter == -1) + return; + if(ac::draw_strings[subfilter] == "SmoothSubFilter32") + return; + static MatrixCollection<32> collection; + cv::Mat frame_copy = frame.clone(); + CallFilter(subfilter, frame_copy); + collection.shiftFrames(frame_copy); + Smooth(frame, &collection); + AddInvert(frame); +} + +void ac::HalfAddSubFilter(cv::Mat &frame) { + if(subfilter == -1) + return; + if(ac::draw_strings[subfilter] == "HalfAddSubFilter") + return; + cv::Mat frame_copy = frame.clone(); + CallFilter(subfilter, frame_copy); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] /= 4; + pixel[j] += pix[j]; + } + } + } + AddInvert(frame); +} +void ac::HalfXorSubFilter(cv::Mat &frame) { + if(subfilter == -1) + return; + if(ac::draw_strings[subfilter] == "HalfXorSubFilter") + return; + cv::Mat frame_copy = frame.clone(); + CallFilter(subfilter, frame_copy); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = frame_copy.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] /= 4; + pixel[j] ^= pix[j]; + } + } + } + AddInvert(frame); +} + +void ac::StaticXorBlend(cv::Mat &frame) { + static cv::Vec3b value(rand()%255, rand()%255, rand()%255); + static MatrixCollection<8> collection; + ChannelSort(frame); + collection.shiftFrames(frame); + StaticXor(frame, &collection, value); + AddInvert(frame); +} + +void ac::PsycheSort(cv::Mat &frame) { + cv::Vec3b value(rand()%255,rand()%255,rand()%255); + static MatrixCollection<8> collection; + collection.shiftFrames(frame); + ChannelSort(frame); + StaticXor(frame, &collection,value); + AddInvert(frame); +} + +void ac::XorScale(cv::Mat &frame) { + static cv::Scalar scale(rand()%255, rand()%255, rand()%255); + static int speed = 1; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = pixel[j]^static_cast(scale[j]); + } + } + static int dir[3] = {1,1,1}; + for(int j = 0; j < 3; ++j) { + if(dir[j] == 1) { + scale[j] += speed; + + if(scale[j] >= 255) + dir[j] = 0; + + } else if(dir[j] == 0) { + scale[j] -= speed; + + if(scale[j] <= 0) + dir[j] = 1; + } + } + AddInvert(frame); +} + +void ac::ChannelMedianSubFilter(cv::Mat &frame) { + if(subfilter == -1) + return; + if(ac::draw_strings[subfilter] == "ChannelMedianSubFilter") + return; + cv::Mat frame_copy = frame.clone(), output; + ChannelSort(frame_copy); + CallFilter(subfilter, frame_copy); + MedianBlend(frame); + AddInvert(frame); +} + +void ac::GaussianStrobe(cv::Mat &frame) { + rainbowBlend(frame); + GaussianBlur(frame); + MedianBlend(frame); + AddInvert(frame); +} + +void ac::StrobeSort(cv::Mat &frame) { + ChannelSort(frame); + GaussianStrobe(frame); +} + +void ac::GlitchSortStrobe(cv::Mat &frame) { + static MatrixCollection<8> collection; + static cv::Vec3b color_(rand()%255, rand()%255, rand()%255); + cv::Mat frame_copy = frame.clone(); + glitchSort(frame_copy); + collection.shiftFrames(frame_copy); + StaticXor(frame, &collection, color_); + MedianBlend(frame); + AddInvert(frame); +} + +void ac::Bitwise_XOR_Blend(cv::Mat &frame) { + static MatrixCollection<8> collection; + static double alpha = 1.0, alpha_max = 4.0; + cv::Mat frame_copy = frame.clone(); + GaussianBlur(frame_copy); + collection.shiftFrames(frame_copy); + cv::Scalar values; + for(int z = 0; z < frame.rows; ++z) { + for(int i =0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < collection.size(); ++j) { + cv::Vec3b inner = collection.frames[j].at(z, i); + for(int q = 0; q < 3; ++q) { + values[q] += (inner[q]*alpha); + } + } + for(int q = 0; q < 3; ++q) { + values[q] /= collection.size(); + pixel[q] = static_cast(values[q]) ^ static_cast(pixel[q]*alpha); + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 6.0); + AddInvert(frame); +} + +void ac::Bitwise_XOR_Sort(cv::Mat &frame) { + ChannelSort(frame); + Bitwise_XOR_Blend(frame); +} + +void ac::Bitwise_OR_Blend(cv::Mat &frame) { + static MatrixCollection<8> collection; + static double alpha = 1.0, alpha_max = 4.0; + cv::Mat frame_copy = frame.clone(); + GaussianBlur(frame_copy); + collection.shiftFrames(frame_copy); + cv::Scalar values; + for(int z = 0; z < frame.rows; ++z) { + for(int i =0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < collection.size(); ++j) { + cv::Vec3b inner = collection.frames[j].at(z, i); + for(int q = 0; q < 3; ++q) { + values[q] += (inner[q]*alpha); + } + } + for(int q = 0; q < 3; ++q) { + values[q] /= collection.size(); + pixel[q] = static_cast(values[q]) | static_cast(pixel[3-q-1]*alpha); + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 6.0); + AddInvert(frame); +} + +void ac::Bitwise_AND_Blend(cv::Mat &frame) { + static MatrixCollection<8> collection; + static double alpha = 1.0, alpha_max = 4.0; + cv::Mat frame_copy = frame.clone(); + GaussianBlur(frame_copy); + collection.shiftFrames(frame_copy); + cv::Scalar values; + for(int z = 0; z < frame.rows; ++z) { + for(int i =0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < collection.size(); ++j) { + cv::Vec3b inner = collection.frames[j].at(z, i); + for(int q = 0; q < 3; ++q) { + values[q] += (inner[q]*alpha); + } + } + for(int q = 0; q < 3; ++q) { + values[q] /= collection.size(); + pixel[q] = static_cast(values[q]) & static_cast(pixel[3-q-1]*alpha); + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 6.0); + AddInvert(frame); +} + +void ac::BitwiseColorMatrix(cv::Mat &frame) { + static MatrixCollection<8> collection; + static double alpha[3] = {1.0,4.0,1.0}, alpha_max = 4.0; + cv::Mat frame_copy = frame.clone(); + GaussianBlur(frame_copy); + collection.shiftFrames(frame_copy); + cv::Scalar values; + for(int z = 0; z < frame.rows; ++z) { + for(int i =0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < collection.size(); ++j) { + cv::Vec3b inner = collection.frames[j].at(z, i); + for(int q = 0; q < 3; ++q) { + values[q] += (inner[q]*alpha[q]); + } + } + for(int q = 0; q < 3; ++q) { + values[q] /= collection.size(); + pixel[q] ^= static_cast(values[q]) & static_cast(pixel[3-q-1]*alpha[q]); + } + } + } + static int dir[3] = {1, 0, 1};; + + for(int j = 0; j < 3; ++j) + procPos(dir[j], alpha[j], alpha_max, 6.0, 0.1); + + AddInvert(frame); +} + +void ac::PixelReverseXor(cv::Mat &frame) { + static double alpha[3] = {1.0,4.0,1.0}, alpha_max = 4.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = pixel; + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast(pix[3-j-1]*alpha[j])^pixel[j]; + } + } + } + static int dir[3] = {1, 0, 1};; + for(int j = 0; j < 3; ++j) + procPos(dir[j], alpha[j], alpha_max, 6.0, 0.1); + AddInvert(frame); +} + +void ac::PixelatedSubFilterSort(cv::Mat &frame) { + if(ac::draw_strings[subfilter] == "PixelatedSubFilterSort") + return; + + static MatrixCollection<8> collection; + Block(frame); + ChannelSort(frame); + collection.shiftFrames(frame); + SmoothRGB(frame, &collection); + if(subfilter != -1) + CallFilter(subfilter, frame); +} + +void ac::SilverBlend(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 3.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + double total = (pixel[0]+pixel[1]+pixel[2]) * alpha; + unsigned int value = static_cast(total); + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j]^value; + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 4.0, 0.1); +} + +void ac::RandomPixelOrderSort(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 5.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + SwapColors(pixel); + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast(pixel[j]*alpha); + } + } + } + StrobeSort(frame); + static int dir = 1; + procPos(dir, alpha, alpha_max); + AddInvert(frame); +} + +void ac::ImageXorAlpha(cv::Mat &frame) { + if(blend_set == true) { + static double alpha = 1.0, alpha_max = 3.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + int cX = AC_GetFX(blend_image.cols, i, frame.cols); + int cY = AC_GetFZ(blend_image.rows, z, frame.rows); + cv::Vec3b pix = blend_image.at(cY, cX); + for(int j = 0; j < 3; ++j) { + pixel[j] = (static_cast((pixel[j]*alpha)) ^ static_cast((pix[j]*alpha))); + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 4.0, 0.01); + AddInvert(frame); + } +} + +void ac::ImageAverageXor(cv::Mat &frame) { + if(blend_set == true) { + static MatrixCollection<8> collection; + static double alpha = 1.0, alpha_max = 3.0; + collection.shiftFrames(frame); + DarkenFilter(frame); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Scalar values; + for(int q = 0; q < collection.size(); ++q) { + cv::Vec3b pix = collection.frames[q].at(z, i); + for(int j = 0; j < 3; ++j) + values[j] += pix[j]; + } + int cX = AC_GetFX(blend_image.cols, i, frame.cols); + int cY = AC_GetFZ(blend_image.rows, z, frame.rows); + cv::Vec3b pix = blend_image.at(cY, cX); + for(int j = 0; j < 3; ++j) { + values[j] /= collection.size(); + pixel[j] = (static_cast(pixel[j]*alpha) ^ static_cast((pix[j]*alpha)) ^ static_cast((values[j]*alpha))); + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 3.1, 0.1); + AddInvert(frame); + } +} + +void ac::PixelXorBlend(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 2.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pix = pixel; + for(int j = 0; j < 3; ++j) { + unsigned char v = static_cast(pix[j]*alpha); + pixel[j] = (pix[0]^pix[1]^pix[2])^v; + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 5.0, 0.1); + AddInvert(frame); +} + +void ac::SelfAlphaScale(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 4.0; + static int index[3] = {0,255/3,255/2}; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast((pixel[j]^index[j])*alpha); + } + } + + for(int j = 0; j < 3; ++j) { + ++index[j]; + if(index[j] >= 255) { + index[j] = 0; + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); + AddInvert(frame); +} + +void ac::SelfScaleAlpha(cv::Mat &frame) { + static double alpha = 1.0, alpha_max = 4.0; + static int index[3] = {0,255/3,255/2}; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast((pixel[j]*alpha))^index[j]; + } + } + static int direction[3] = {1,1,1}; + for(int j = 0; j < 3; ++j) { + if(direction[j] == 1) { + if(index[j] >= 255) + direction[j] = 0; + else + ++index[j]; + + } else if(direction[j] == 0) { + if(index[j] <= 1) + direction[j] = 1; + else + --index[j]; + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); + AddInvert(frame); +} + +void ac::RainbowXorBlend(cv::Mat &frame) { + static double alpha = 1.0f, alpha_max = 6.0; + static int rb = 0, gb = 0, bb = 0; + if(rb == 0) + rb = rand()%255; + else ++rb; + if(gb == 0) + gb = rand()%255; + else ++gb; + if(bb == 0) + bb = rand()%255; + else ++bb; + static int i = 0, z = 0; + for(z = 0; z < frame.rows; ++z) { + for(i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[0] = (pixel[0]^static_cast(alpha*rb)); + pixel[1] = (pixel[1]^static_cast(alpha*gb)); + pixel[2] = (pixel[2]^static_cast(alpha*bb)); + } + } + if(rb > 255) rb = 0; + if(gb > 255) gb = 0; + if(bb > 255) bb = 0; + static int direction = 1; + procPos(direction, alpha, alpha_max); + resetAlpha(direction, alpha); + AddInvert(frame); +} + +void ac::FrameDifference(cv::Mat &frame) { + static MatrixCollection<8> collection; + cv::Vec3b r(rand()%255, rand()%255, rand()%255); + ImageDifference(frame, &collection, [=](cv::Vec3b &val) { + for(int j = 0; j < 3; ++j) { + val[j] = val[j]^r[j]; + } + }); + AddInvert(frame); +} + +void ac::SmallDiffference(cv::Mat &frame) { + static MatrixCollection<8> collection; + cv::Vec3b pix_value(rand()%255, rand()%255, rand()%255); + ImageDifference(frame, &collection, [=](cv::Vec3b &val) { + for(int j = 0; j < 3; ++j) { + val[j] = val[j]^pix_value[j]; + } + }, 5); + AddInvert(frame); +} + +void ac::FadeBlend(cv::Mat &frame) { + static cv::Scalar fade(rand()%255, rand()%255, rand()%255); + static int dir[3] = { 1, 1, 1 }; + static double alpha = 1.0, alpha_max = 4.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + unsigned char ch = static_cast(fade[j]*alpha); + pixel[j] = pixel[j]^ch; + } + } + } + for(int j = 0; j < 3; ++j) { + if(dir[j] == 1) { + fade[j] += alpha_increase; + if(fade[j] >= 255) { + dir[j] = 0; + } + } else if(dir[j] == 0) { + fade[j] -= alpha_increase; + if(fade[j] <= 0) { + dir[j] = 1; + fade[j] = rand()%255; + } + } + } + static int direction = 1; + procPos(direction, alpha, alpha_max); + AddInvert(frame); +} + +void ac::FilteredDifferenceSubFilter(cv::Mat &frame) { + if(subfilter == -1 || ac::draw_strings[subfilter] == "FilteredDifferenceSubFilter") + return; + static MatrixCollection<8> collection; + cv::Mat copy_frame = frame.clone(); + CallFilter(subfilter,copy_frame); + ImageCopyDifference(frame, copy_frame, &collection); + AddInvert(frame); +} diff --git a/windows/Acid.Cam.Qt.Windows.Project/ac-grid.cpp b/windows/Acid.Cam.Qt.Windows.Project/ac-grid.cpp new file mode 100755 index 0000000..4d01444 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/ac-grid.cpp @@ -0,0 +1,285 @@ +/* + * Software written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + +#include "ac.h" + +ac::GridBox::GridBox() : color(rand()%255, rand()%255, rand()%255), on(true) {} +ac::GridBox::GridBox(const Rect &r, const cv::Vec3b &col) : location(r), color(col) {} +ac::GridBox::GridBox(const cv::Vec3b &col) : color(col), on(true) {} +ac::GridBox::GridBox(const ac::GridBox &gb) : location(gb.location),color(gb.color),on(gb.on) {} +ac::GridBox &ac::GridBox::operator=(const ac::GridBox &gb) { + color = gb.color; + location = gb.location; + on = gb.on; + return *this; +} +ac::Grid::Grid() :boxes(0), g_random(false) {} +ac::Grid::~Grid() { + if(boxes != 0) { + cleanBoxes(); + } +} + +bool operator<(const ac::Point &p1, const ac::Point &p2) { + if(p1.x < p2.x && p1.y < p2.y) + return true; + return false; +} + +void ac::Grid::cleanBoxes() { + if(boxes != 0) { + for(int j = 0; j < g_w; ++j) + delete [] boxes[j]; + + delete [] boxes; + boxes = 0; + } +} + +void ac::Grid::createGrid(cv::Mat &frame, int w, int h, int size) { + cleanBoxes(); + g_w = w; + g_h = h; + g_s = size; + boxes = new GridBox*[g_w]; + for(int i = 0; i < g_w; ++i) { + boxes[i] = new GridBox[h]; + } + if(!points.empty()) { + points.erase(points.begin(), points.end()); + } + for(int i = 0; i < g_w; ++i) { + for(int z = 0; z < g_h; ++z) { + cv::Vec3b pixel = frame.at(z*size, i*size); + Point p(i, z); + points.push_back(p); + boxes[i][z] = GridBox(pixel); + if(g_random) + boxes[i][z].on = ((rand()%4) == 0) ? false : true; + + } + } + std::shuffle(points.begin(), points.end(), rng); + current_offset = 0; +} + + +void ac::Grid::fillGrid(cv::Mat &frame) { + if(current_offset < points.size()) + return; + + for(int i = 0; i < g_w; ++i) { + for(int z = 0; z < g_h; ++z) { + cv::Vec3b pixel = frame.at(z*g_s, i*g_s); + boxes[i][z] = GridBox(pixel); + if(g_random) + boxes[i][z].on = ((rand()%4) == 0) ? false : true; + + } + } + current_offset = 0; + std::shuffle(points.begin(), points.end(), rng); +} + +void ac::Grid::updateGrid(int max) { + int iter_max = current_offset+max; + while(current_offset < points.size() && current_offset < iter_max) { + const Point &p = points[current_offset]; + boxes[p.x][p.y].on = false; + current_offset++; + } +} + +void ac::GridFilter8x(cv::Mat &frame) { + static cv::Size s(0, 0); + static const int box_size = 8; + static Grid grid; + if(frame.size() != s) { + grid.createGrid(frame, frame.cols/box_size, frame.rows/box_size, box_size); + s = frame.size(); + } + int num = 0; + if(frame.rows >= 1080) + num = 100; + else if(frame.rows >= 720) + num = 75; + else if(frame.rows >= 400) + num = 50; + else + num = 25; + grid.updateGrid(150+rand()%num); + grid.fillGrid(frame); + for(int z = 0; z < grid.g_h; ++z) { + for(int i = 0; i < grid.g_w; ++i) { + if(grid.boxes[i][z].on) + fillRect(frame, ac::Rect(i*box_size, z*box_size, grid.g_s, grid.g_s), grid.boxes[i][z].color); + } + } +} + +void ac::GridFilter16x(cv::Mat &frame) { + static cv::Size s(0, 0); + static const int box_size = 16; + static Grid grid; + if(frame.size() != s) { + grid.createGrid(frame, frame.cols/box_size, frame.rows/box_size, box_size); + s = frame.size(); + } + int num = 0; + if(frame.rows >= 1080) + num = 50; + else if(frame.rows >= 720) + num = 40; + else if(frame.rows >= 400) + num = 30; + else + num = 20; + grid.updateGrid(75+rand()%num); + grid.fillGrid(frame); + for(int z = 0; z < grid.g_h; ++z) { + for(int i = 0; i < grid.g_w; ++i) { + if(grid.boxes[i][z].on) + fillRect(frame, ac::Rect(i*box_size, z*box_size, grid.g_s, grid.g_s), grid.boxes[i][z].color); + } + } +} + +void ac::GridFilter8xBlend(cv::Mat &frame) { + static cv::Size s(0, 0); + static const int box_size = 8; + static double alpha = 1.0, alpha_max = 8.0; + static Grid grid; + if(frame.size() != s) { + grid.createGrid(frame, frame.cols/box_size, frame.rows/box_size, box_size); + s = frame.size(); + } + int num = 0; + if(frame.rows >= 1080) + num = 100; + else if(frame.rows >= 720) + num = 75; + else if(frame.rows >= 400) + num = 50; + else + num = 25; + grid.updateGrid(150+rand()%num); + grid.fillGrid(frame); + for(int z = 0; z < grid.g_h; ++z) { + for(int i = 0; i < grid.g_w; ++i) { + if(grid.boxes[i][z].on) { + cv::Vec3b pixel = frame.at(z*grid.g_s, i*grid.g_s); + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast((pixel[j]+grid.boxes[i][z].color[j])/2); + pixel[j] *= static_cast(alpha); + } + fillRect(frame, ac::Rect(i*box_size, z*box_size, grid.g_s, grid.g_s), pixel); + } + } + } + static int direction = 1; + procPos(direction, alpha, alpha_max); +} + +void ac::GridRandom(cv::Mat &frame) { + static cv::Size s(0, 0); + static const int box_size = 16; + static Grid grid; + if(frame.size() != s) { + grid.g_random = true; + grid.createGrid(frame, frame.cols/box_size, frame.rows/box_size, box_size); + s = frame.size(); + } + int num = 0; + if(frame.rows >= 2000) + num = 250; + if(frame.rows >= 1080) + num = 100; + else if(frame.rows >= 720) + num = 40; + else if(frame.rows >= 400) + num = 30; + else + num = 20; + grid.updateGrid(75+rand()%num); + grid.fillGrid(frame); + for(int z = 0; z < grid.g_h; ++z) { + for(int i = 0; i < grid.g_w; ++i) { + if(grid.boxes[i][z].on) + fillRect(frame, ac::Rect(i*box_size, z*box_size, grid.g_s, grid.g_s), grid.boxes[i][z].color); + } + } +} + +void ac::GridRandomPixel(cv::Mat &frame) { + static cv::Size s(0, 0); + static const int box_size = 8; + static Grid grid; + if(frame.size() != s) { + grid.createGrid(frame, frame.cols/box_size, frame.rows/box_size, box_size); + s = frame.size(); + } + int num = 0; + if(frame.rows >= 2000) + num = 400; + if(frame.rows >= 1080) + num = 200; + else if(frame.rows >= 720) + num = 100; + else if(frame.rows >= 400) + num = 50; + else + num = 20; + grid.updateGrid(75+rand()%num); + grid.fillGrid(frame); + for(int z = 0; z < grid.g_h; ++z) { + for(int i = 0; i < grid.g_w; ++i) { + if(grid.boxes[i][z].on) { + cv::Vec3b rpix(rand()%255,rand()%255,rand()%255); + for(int j = 0; j < 3; ++j) + rpix[j] += grid.boxes[i][z].color[j]; + fillRect(frame, ac::Rect(i*box_size, z*box_size, grid.g_s, grid.g_s),rpix); + } + } + } +} + diff --git a/windows/Acid.Cam.Qt.Windows.Project/ac-image.cpp b/windows/Acid.Cam.Qt.Windows.Project/ac-image.cpp new file mode 100755 index 0000000..f9ebb83 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/ac-image.cpp @@ -0,0 +1,601 @@ +/* + * Software written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + +#include"ac.h" + +// Image blend +// cv::Mat as reference +void ac::imageBlend(cv::Mat &frame) { + static double pos = 1.0f;// static pos set to 1 + if(blend_set == true) {// if image is set + int i,z; + for(i = 0; i < frame.cols; ++i) { // top to bottom + for(z = 0; z < frame.rows; ++z) {// left to right + // get resized x,y + int cX = AC_GetFX(blend_image.cols, i, frame.cols); + int cY = AC_GetFZ(blend_image.rows, z, frame.rows); + cv::Vec3b ¤t = frame.at(z, i);// get current pixel + cv::Vec3b im = blend_image.at(cY, cX);// get pixel to blend from resized x,y + // set pixel values + current[0] = static_cast(current[0]+(im[0]*pos)); + current[1] = static_cast(current[1]+(im[1]*pos)); + current[2] = static_cast(current[2]+(im[2]*pos)); + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// invert pixel + } + } + } + static double pos_max = 7.0f;// max pos value + static int direction = 1; + procPos(direction, pos, pos_max); +} +// takes cv::Mat reference +void ac::imageBlendTwo(cv::Mat &frame) { + static double pos = 1.0f; // static pos equal 1.0 + if(blend_set == true) {// if image is set to blend with + int i,z;// loop variables + for(i = 0; i < frame.cols; ++i) { // left to right + for(z = 0; z < frame.rows; ++z) {// top to bottom + // resize x,y + int cX = AC_GetFX(blend_image.cols, i, frame.cols); + int cY = AC_GetFZ(blend_image.rows, z, frame.rows); + // grab pixels + cv::Vec3b ¤t = frame.at(z, i); + cv::Vec3b im = blend_image.at(cY, cX); + // set pixel values + current[0] = static_cast(im[0]+(current[0]*pos)); + current[1] = static_cast(im[1]+(current[1]*pos)); + current[2] = static_cast(im[2]+(current[2]*pos)); + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i); // invert pixel + } + } + } + static double pos_max = 7.0f;// max position set to 7.0 + static int direction = 1; + procPos(direction, pos, pos_max); +} +// blend with Image +// takes cv::Mat reference +void ac::imageBlendThree(cv::Mat &frame) { + if(blend_set == true) { // if blend_set is true (image selected) + static double pos = 1.0f;// static pos equals 1.0 + for(int i = 0; i < frame.cols; ++i) { // from top to bottom + for(int z = 0; z < frame.rows; ++z) {// from left to right + // calculate x,y pixel position + int cX = AC_GetFX(blend_image.cols, i, frame.cols); + int cY = AC_GetFZ(blend_image.rows, z, frame.rows); + // get pixel to manipulate reference + cv::Vec3b &pixel = frame.at(z, i); + // get image pixel from calculated x,y positions + cv::Vec3b im = blend_image.at(cY, cX); + // calculate pixel data + pixel[0] += (pixel[0]^im[0]); + pixel[1] += (pixel[1]^im[1]); + pixel[2] += static_cast((pixel[2]^im[2])*pos); + swapColors(frame, z, i);//swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel + + } + } + // static int directione quals 1 + static int direction = 1; + // static pos_max equals 7.0 + static double pos_max = 7.0f; + if(direction == 1) {// if direction equals 1 + pos += 0.005;// pos plus equal 0.005 + if(pos > pos_max) {// pos greater than pos_max + pos = pos_max;// pos set to pos_max + direction = 0;// direction set to zero + pos_max += 0.5f;// pos_max plus equal 0.5 + } + } else if(direction == 0) {// direction is set to 0 + pos -= 0.005;// pos minus equal 0.005 + if(pos <= 1) {/// pos less than equal 1 + if(pos_max > 15) pos_max = 1.0f;//reset pos_max if greater than 15 + direction = 1;// direction set to 1 + } + } + } +} + +// imageblend4 +void ac::imageBlendFour(cv::Mat &frame) { + if(blend_set == true) { + static int state = 0; + static double pos = 1.0; + int w = frame.cols;// frame width + int h = frame.rows;// frame height + int cw = blend_image.cols; + int ch = blend_image.rows; + for(int z = 3; z < h-3; ++z) {// top to bottom + for(int i = 3; i < w-3; ++i) {// left to right + // current pixel by reference + cv::Vec3b &pixel = frame.at(z, i); + // calculate resized image based x,y positions + int cX = AC_GetFX(blend_image.cols, i, frame.cols); + int cY = AC_GetFZ(blend_image.rows, z, frame.rows); + // grab pixel refernces from blend_image + cv::Vec3b &pr = blend_image.at((ch-cY), (cw-cX)); + cv::Vec3b &pg = blend_image.at((ch-cY), cX); + cv::Vec3b &pb = blend_image.at(cY, (cw-cX)); + // perform operation based on current state variable + switch(state) { + case 0: + pixel[0] += static_cast((pr[0]+pg[1]+pb[2])*pos); + pixel[1] += static_cast((pr[2]+pg[1]+pb[0])*pos); + break; + case 1: + pixel[1] += static_cast((pr[2]+pg[1]+pb[0])*pos); + pixel[2] += static_cast((pr[0]+pg[1]+pb[2])*pos); + break; + case 2: + pixel[2] += static_cast((pr[0]+pg[1]+pb[2])*pos); + pixel[0] += static_cast((pr[2]+pg[1]+pb[0])*pos); + break; + } + + } + + } + ++state;// increase state + if(state > 2) state = 0; // greater than 2 reset state + static int direction = 1; + // static pos_max equals 7.0 + static double pos_max = 3.0f; + if(direction == 1) {// if direction equals 1 + pos += 0.005;// pos plus equal 0.005 + if(pos > pos_max) {// pos greater than pos_max + pos = pos_max;// pos set to pos_max + direction = 0;// direction set to zero + pos_max += 0.5f;// pos_max plus equal 0.5 + } + } else if(direction == 0) {// direction is set to 0 + pos -= 0.005;// pos minus equal 0.005 + if(pos <= 1) {/// pos less than equal 1 + if(pos_max > 3) pos_max = 1.0f;//reset pos_max if greater than 15 + direction = 1;// direction set to 1 + } + } + } +} + +void ac::ImageFile(cv::Mat &frame) { + if(blend_set == true) { + const int w = frame.cols; + const int h = frame.rows; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + int cX = AC_GetFX(blend_image.cols, i, frame.cols); + int cY = AC_GetFZ(blend_image.rows, z, frame.rows); + cv::Vec3b add_i = blend_image.at(cY, cX); + pixel[0] += add_i[0]; + pixel[1] += add_i[1]; + pixel[1] += add_i[2]; + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i); // invert pixel + } + } + } + +} +void ac::ImageXor(cv::Mat &frame) { + if(blend_set == true) { + const int w = frame.cols; + const int h = frame.rows; + static double alpha = 1.0, alpha_max = 4.0; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + int cX = AC_GetFX(blend_image.cols, i, frame.cols); + int cY = AC_GetFZ(blend_image.rows, z, frame.rows); + cv::Vec3b add_i = blend_image.at(cY, cX); + for(int j = 0; j < 3; ++j) + pixel[j] = cv::saturate_cast((pixel[j]^add_i[j])*alpha); + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i); // invert pixel + } + } + static int direction = 1; + procPos(direction, alpha, alpha_max); + } +} + +void ac::ImageAlphaBlend(cv::Mat &frame) { + if(blend_set == true) { + const int w = frame.cols; + const int h = frame.rows; + static double alpha = 1.0, alpha_max = 2.0; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + int cX = AC_GetFX(blend_image.cols, i, frame.cols); + int cY = AC_GetFZ(blend_image.rows, z, frame.rows); + cv::Vec3b add_i = blend_image.at(cY, cX); + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast((pixel[j]*alpha) + (add_i[j] * alpha)); + + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i); // invert pixel + } + } + static int direction = 1; + procPos(direction, alpha, alpha_max); + } +} + +void ac::ImageInter(cv::Mat &frame) { + if(blend_set == true) { + static int start = 0, restart = 0; + const int w = frame.cols; + const int h = frame.rows; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + int cX = AC_GetFX(blend_image.cols, i, frame.cols); + int cY = AC_GetFZ(blend_image.rows, z, frame.rows); + cv::Vec3b add_i = blend_image.at(cY, cX); + if(start == 0) { + pixel = add_i; + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i); // invert pixel + } + start = (start == 0) ? 1 : 0; + } + if(restart == 0) { + start = 1; + restart = 1; + } else { + start = 0; + restart = 0; + } + } +} + +// blend with image +void ac::ImageX(cv::Mat &frame) { + if(blend_set == true) { + + if(blend_image.empty()) + return; + + static double alpha = 1.0, alpha_max = 8.0; + static cv::Mat frame_blend = blend_image.clone(); + + for(int i = 1; i < frame.cols-2; ++i) { + for(int z = 1; z < frame.rows-2; ++z) { + int cX = AC_GetFX(frame_blend.cols, i, frame.cols); + int cY = AC_GetFZ(frame_blend.rows, z, frame.rows); + + if(cX >= frame_blend.cols || cY >= frame_blend.rows) + continue; + + cv::Vec3b &pixel = frame_blend.at(cY, cX); + cv::Vec3b pix = frame_blend.at(cY+1, cX+1); + pixel = pix; + cv::Vec3b &pix_value = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pix_value[j] = static_cast(pixel[j]+(pix_value[j]*alpha)); + } + } + static int direction = 1; + procPos(direction, alpha, alpha_max); + } +} + +void ac::SmoothRandomImageBlend(cv::Mat &frame) { + if(blend_set == true) { + + if(testSize(frame) == false) + return; + + static MatrixCollection<8> collection; + int index = 0; + DrawFunction rfunc = getRandomFilter(index); + cv::Mat temp_frame; + cv::resize(blend_image, temp_frame, frame.size()); + rfunc(temp_frame); + collection.shiftFrames(temp_frame); + Smooth(frame, &collection); + } +} + +void ac::SmoothImageAlphaBlend(cv::Mat &frame) { + if(blend_set == true) { + static double alpha = 1.0, alpha_max = 2.0; + static MatrixCollection<8> collection; + cv::Mat temp_frame; + cv::Mat temp_image; + cv::Mat blend_image_scaled; + cv::resize(blend_image, blend_image_scaled, frame.size()); + temp_frame = frame.clone(); + AlphaBlend(temp_frame,blend_image_scaled,frame,alpha); + collection.shiftFrames(frame); + Smooth(temp_frame, &collection); + frame = temp_frame.clone(); + static int direction = 1; + procPos(direction, alpha, alpha_max, 8, 0.05); + } +} + +void ac::BlendImageOnOff(cv::Mat &frame) { + if(blend_set == true) { + static double alpha = 1.0, alpha_max = 4.0; + static int index = 0; + for(int z = 3; z < frame.rows-3; ++z) { + for(int i = 3; i < frame.cols-3; ++i) { + int cX = AC_GetFX(blend_image.cols, i, frame.cols); + int cY = AC_GetFZ(blend_image.rows, z, frame.rows); + cv::Vec3b pix[4]; + pix[0] = blend_image.at(cY, cX); + pix[1] = blend_image.at(cY+1, cX); + pix[2] = blend_image.at(cY, cX+1); + pix[3] = blend_image.at(cY+1, cX+1); + cv::Scalar value; + for(int j = 0; j < 4; ++j) { + for(int q = 0; q < 3; ++q) { + value[q] += pix[j][q]; + } + } + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + value[j] /= 4; + unsigned char val = static_cast(value[j]); + switch(index) { + case 0: + pixel[j] += static_cast(val*alpha); + break; + case 1: + pixel[j] -= static_cast(val*alpha); + break; + } + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + ++index; + if(index > 1) index = 0; + + static int dir = 1; + procPos(dir, alpha, alpha_max); + } +} + +void ac::XorSelfAlphaImage(cv::Mat &frame) { + if(blend_set == true) { + static double alpha = 1.0, alpha_max = 2.0; + static double alpha_r = 14.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + int cX = AC_GetFX(blend_image.cols, i, frame.cols); + int cY = AC_GetFZ(blend_image.rows, z, frame.rows); + cv::Vec3b pix = blend_image.at(cY, cX); + for(int j = 0; j < 3; ++j) { + //pixel[j] ^= (1-((pixel[j] + pix[j])) * (2+static_cast(alpha))); + pixel[j] = static_cast((pixel[j] * alpha) + (pix[j] * alpha_r)); + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int dir = 1, dir_r = 0; + procPos(dir, alpha, alpha_max); + procPos(dir_r, alpha_r, alpha_max); + } +} + +void ac::AlphaBlendImageXor(cv::Mat &frame) { + if(blend_set == true) { + static MatrixCollection<8> collection; + SmoothImageAlphaBlend(frame); + Bitwise_XOR(frame); + collection.shiftFrames(frame); + Smooth(frame, &collection); + } +} + +void ac::ImageShiftUpLeft(cv::Mat &frame) { + if(blend_set) { + static double alpha = 1.0, alpha_max = 3.0; + static cv::Mat image = blend_image.clone(); + if(reset_filter == true) { + reset_filter = false; + image = blend_image.clone(); + } + for(int i = 0; i < image.cols-1; ++i) { + for(int z = 0; z < image.rows-1; ++z) { + cv::Vec3b val = image.at(z+1, i+1); + cv::Vec3b &target = image.at(z, i); + target = val; + } + } + for(int i = 0; i < frame.cols; ++i) { + for(int z = 0; z < frame.rows; ++z) { + int cX = AC_GetFX(image.cols, i, frame.cols); + int cY = AC_GetFZ(image.rows, z, frame.rows); + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b src_pixel = image.at(cY, cX); + for(int j = 0; j < 3; ++j) + pixel[j] = static_cast((alpha * pixel[j])) ^ src_pixel[j]; + + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); + } +} + +void ac::ExactImage(cv::Mat &frame) { + if(blend_set == true) { + const int w = frame.cols; + const int h = frame.rows; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + int cX = AC_GetFX(blend_image.cols, i, frame.cols); + int cY = AC_GetFZ(blend_image.rows, z, frame.rows); + cv::Vec3b add_i = blend_image.at(cY, cX); + pixel = add_i; + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i); // invert pixel + } + } + } +} + +// Use this with other filters like MedianBlend +void ac::BlendImageXor(cv::Mat &frame) { + if(blend_set == true) { + static double alpha = 1.0, alpha_max = 7.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + int cX = AC_GetFX(blend_image.cols, i, frame.cols); + int cY = AC_GetFZ(blend_image.rows, z, frame.rows); + cv::Vec3b add_i = blend_image.at(cY, cX); + for(int j = 0; j < 3; ++j) { + pixel[j] = static_cast((pixel[j]^add_i[j])*alpha); + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 8, 0.01); + DarkenFilter(frame); + DarkenFilter(frame); + } +} + +void ac::BlendImageAround_Median(cv::Mat &frame) { + if(blend_set == true) { + static double alpha = 1.0, alpha_max = 7.0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b pixel_data[4]; + pixel_data[0] = pixel; + pixel_data[1] = frame.at(frame.rows-z-1, i); + pixel_data[2] = frame.at(z, frame.cols-i-1); + pixel_data[3] = frame.at(frame.rows-z-1, frame.cols-i-1); + int cX = AC_GetFX(blend_image.cols, i, frame.cols); + int cY = AC_GetFZ(blend_image.rows, z, frame.rows); + cv::Vec3b add_i = blend_image.at(cY, cX); + cv::Scalar val; + for(int j = 0; j < 4; ++j) { + for(int q = 0; q < 3; ++q) + val[q] += pixel_data[j][q]; + } + val[0] /= 4; + val[1] /= 4; + val[2] /= 4; + for(int j = 0; j < 3; ++j) { + pixel[j] = pixel[j] ^ add_i[j] ^ static_cast(val[j]); + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 8, 0.01); + DarkenFilter(frame); + DarkenFilter(frame); + MedianBlend(frame); + } +} + +void ac::ImageBlendTransform(cv::Mat &frame) { + + if(blend_set == true) { + static double alpha = 1.0, alpha_max = 4.0, speed = 0.1; + static MatrixCollection<8> collection; + collection.shiftFrames(frame); + + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b orig_pix = pixel; + int cX = AC_GetFX(blend_image.cols, i, frame.cols); + int cY = AC_GetFZ(blend_image.rows, z, frame.rows); + cv::Vec3b add_i = blend_image.at(cY, cX); + for(int j = 0; j < collection.size(); ++j) { + cv::Vec3b color_v = collection.frames[j].at(z, i); + for(int q = 0; q < 3; ++q) { + pixel[q] ^= color_v[q]; + } + } + for(int q = 0; q < 3; ++q) { + pixel[q] ^= static_cast((orig_pix[q] * alpha) + (add_i[q] * alpha)); + } + } + } + static int dir = 1; + if(dir == 1) { + alpha += speed; + if(alpha > alpha_max) { + dir = 0; + speed += 0.1; + } + } else { + alpha -= speed; + if(alpha <= 0.1) { + dir = 1; + speed += 0.1; + } + } + if(speed > 4) speed = 0.1; + + DarkenFilter(frame); + DarkenFilter(frame); + MedianBlend(frame); + GaussianBlur(frame); + GaussianBlur(frame); + } +} + + + + + diff --git a/windows/Acid.Cam.Qt.Windows.Project/ac-obj.cpp b/windows/Acid.Cam.Qt.Windows.Project/ac-obj.cpp new file mode 100755 index 0000000..6dcad10 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/ac-obj.cpp @@ -0,0 +1,173 @@ +/* + * Software written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + +#include "ac.h" + +ac::Point::Point() : x(0), y(0) {} +ac::Point::Point(const ac::Point &p) : x(p.x), y(p.y) {} +ac::Point::Point(int xx, int yy) : x(xx), y(yy) {} + +ac::Point &ac::Point::operator=(const ac::Point &p) { + x = p.x; + y = p.y; + return *this; +} + +void ac::Point::setPoint(int xx, int yy) { + x = xx; + y = yy; +} + +ac::Rect::Rect() : x(0), y(0), w(0), h(0) {} +ac::Rect::Rect(const ac::Rect &r) : x(r.x), y(r.y), w(r.w), h(r.h) {} +ac::Rect::Rect(int xx, int yy, int ww, int hh) : x(xx), y(yy), w(ww), h(hh) {} +ac::Rect::Rect(int xx, int yy) : x(xx), y(yy), w(0), h(0) {} +ac::Rect::Rect(int xx, int yy, cv::Size s) : x(xx), y(yy), w(s.width), h(s.height) {} +ac::Rect::Rect(Point pt, int ww, int hh) : x(pt.x), y(pt.y), w(ww), h(hh) {} +ac::Rect::Rect(Point pt, cv::Size s) : x(pt.x), y(pt.y), w(s.width), h(s.height){} + +ac::Rect &ac::Rect::operator=(const ac::Rect &r) { + x = r.x; + y = r.y; + w = r.w; + h = r.h; + return *this; +} + +void ac::Rect::setRect(int xx, int yy, int ww, int hh) { + x = xx; + y = yy; + w = ww; + h = hh; +} + +std::vector ac::all_objects; +bool ac::frames_released = false; + +void ac::release_all_objects() { + for(int i = 0; i < all_objects.size(); ++i) { + cv::Mat *m = reinterpret_cast(all_objects[i]); + if(m != 0 && !m->empty()) { + m->release(); + } + } + frames_released = true; +} + +ac::HLine::HLine() : w(0), h(0) { + +} + +void ac::HLine::createLines(int size, int width, int height) { + w = width; + h = height; + for(int i = 0; i < size; ++i) { + int rand_y = ((rand()%height)/8); + LineObject l; + l.line_size = ac::Rect(0,rand_y,width,3); + l.on = true; + l.dir = ((rand()%2) == 1) ? 1 : 0; + lines.push_back(l); + } +} + +void ac::HLine::drawLines(cv::Mat &frame) { + for(int l = 0; l < lines.size(); ++l) { + ac::Rect rc = lines[l].line_size; + int num = rand()%50, skip = rand()%20; + int count = 0, skip_count = 0; + for(int x = rc.x; x < rc.x+rc.w; ++x) { + if(count < num) { + if(rc.y >= 0 && rc.y < frame.rows && x >= 0 && x < frame.cols) { + cv::Vec3b &pixel = frame.at(rc.y, x); + pixel[0] = pixel[1] = pixel[2] = 255; + ++count; + } + } else { + if(skip_count >= skip) { + skip_count = 0; + count = 0; + num = rand()%50; + skip = rand()%20; + } else { + ++skip_count; + } + } + if(lines[l].dir == 1) { + ++lines[l].line_size.y; + if(lines[l].line_size.y > frame.rows) { + lines[l].line_size.y = rand()%frame.rows; + lines[l].dir = ((rand()%2) == 1) ? 1 : 0; + } + + } else if(lines[l].dir == 0) { + --lines[l].line_size.y; + if(lines[l].line_size.y <= 0) { + lines[l].line_size.y = rand()%frame.rows; + lines[l].dir = ((rand()%2) == 1) ? 1 : 0; + + } + } + } + } +} + +void ac::HLine::clearLines() { + if(!lines.empty()) { + lines.erase(lines.begin(), lines.end()); + } +} + + + + + + + + + + + + + + diff --git a/windows/Acid.Cam.Qt.Windows.Project/ac-particle.cpp b/windows/Acid.Cam.Qt.Windows.Project/ac-particle.cpp new file mode 100755 index 0000000..ba76706 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/ac-particle.cpp @@ -0,0 +1,336 @@ +/* + * Software written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + +#include"ac.h" + +// initalize to null +ac::ParticleEmiter::ParticleEmiter() : part(0), w(0), h(0), speed(1){} + +// clean up after done +ac::ParticleEmiter::~ParticleEmiter() { + if(part != 0) { + for(int i = 0; i < w; ++i) + delete [] part[i]; + delete [] part; + part = 0; + } +} + +void ac::ParticleEmiter::reset() { + w = 0; + h = 0; +} + +// set frame pixel values +void ac::ParticleEmiter::set(cv::Mat &frame) { + if(static_cast(frame.cols) != w || static_cast(frame.rows) != h) { + if(part != 0) { + for(int i = 0; i < w; ++i) + delete [] part[i]; + delete [] part; + } + w = frame.cols; + h = frame.rows; + part = new Particle*[w]; + for(int i = 0; i < w; ++i) { + part[i] = new Particle[h]; + for(int z = 0; z < h; ++z) { + part[i][z].x = i; + part[i][z].y = z; + part[i][z].dir = rand()%8; + } + } + } + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b pixel = frame.at(z, i); + part[i][z].pixel = pixel; + } + } +} + +// draw pixel values to frame +void ac::ParticleEmiter::draw(cv::Mat &frame) { + speed = 1; + movePixels();//move values before drawing + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + int x_pos = part[i][z].x; + int y_pos = part[i][z].y; + if(x_pos > 0 && x_pos < frame.cols && y_pos > 0 && y_pos < frame.rows) { + cv::Vec3b &pixel = frame.at(y_pos, x_pos); + pixel = part[i][z].pixel; + } + } + } +} + +void ac::ParticleEmiter::draw_blend(cv::Mat &frame) { + speed = 5; + DarkenFilter(frame); + movePixels();//move values before drawing + static double alpha = 1.0, alpha_max = 5.0; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + int x_pos = part[i][z].x; + int y_pos = part[i][z].y; + if(x_pos > 0 && x_pos < frame.cols && y_pos > 0 && y_pos < frame.rows) { + cv::Vec3b &pixel = frame.at(y_pos, x_pos); + for(int j = 0; j < 3; ++j) + pixel[j] = pixel[j]+(part[i][z].pixel[j]^static_cast(alpha)); + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 10, 0.1); +} + +void ac::ParticleEmiter::draw_flash(cv::Mat &frame) { + speed = 10; + static int flash_index = 0; + static cv::Vec3b black(0,0,0); + cv::Vec3b color(rand()%255, rand()%255, rand()%255); + movePixels();//move values before drawing + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + int x_pos = part[i][z].x; + int y_pos = part[i][z].y; + if(x_pos > 0 && x_pos < frame.cols && y_pos > 0 && y_pos < frame.rows) { + cv::Vec3b &pixel = frame.at(y_pos, x_pos); + switch(flash_index) { + case 0: + pixel = part[i][z].pixel; + break; + case 1: + pixel = black; + break; + case 2: + pixel = color; + break; + } + ++flash_index; + if(flash_index > 2) + flash_index = 0; + } + } + } +} + +void ac::ParticleEmiter::draw_alpha(cv::Mat &frame) { + speed = 20; + movePixels();//move values before drawing + static double alpha = 1.0, alpha_max = 10; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + int x_pos = part[i][z].x; + int y_pos = part[i][z].y; + if(x_pos > 0 && x_pos < frame.cols && y_pos > 0 && y_pos < frame.rows) { + cv::Vec3b &pixel = frame.at(y_pos, x_pos); + for(int j = 0; j < 3; ++j) + pixel[j] += part[i][z].pixel[j]*static_cast(alpha); + + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max, 15, 0.01); +} + +// draw movement fast +void ac::ParticleEmiter::draw_move(cv::Mat &frame) { + speed = 50; + movePixels();//move values before drawing + static double alpha = 1.0, alpha_max = 6.0; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + int x_pos = part[i][z].x; + int y_pos = part[i][z].y; + if(x_pos > 0 && x_pos < frame.cols && y_pos > 0 && y_pos < frame.rows) { + cv::Vec3b &pixel = frame.at(y_pos, x_pos); + pixel = part[i][z].pixel; + } + } + } + static int dir = 1; + procPos(dir, alpha, alpha_max); +} + +void ac::ParticleEmiter::draw_op(cv::Mat &frame) { + speed = 1; + movePixels(); + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + int x_pos = part[i][z].x; + int y_pos = part[i][z].y; + if(x_pos > 0 && x_pos < frame.cols && y_pos > 0 && y_pos < frame.rows) { + cv::Vec3b &pixel = frame.at(y_pos, x_pos); + for(int j = 0; j < 3; ++j) + pixel[j] = part[i][z].pixel[j]^pixel[j]; + } + } + } +} + + +// move pixel coordinates around +void ac::ParticleEmiter::movePixels() { + for(int i = 0; i < w; ++i) { + for(int z = 0; z < h; ++z) { + Particle &p = part[i][z]; + p.m_count ++; + if(p.m_count > 250) { + p.m_count = 0; + p.dir = rand()%4; + continue; + } + switch(p.dir) { + case DIR_UP: + if(p.y > 0) { + p.y -= speed; + } else { + p.dir = rand()%8; + } + break; + case DIR_UP_LEFT: + + if(p.y > 0 && p.x > 0) { + p.y -= speed; + p.x -= speed; + } else { + p.dir = rand()%8; + } + + break; + case DIR_UP_RIGHT: + + if(p.y > 0 && p.x < w-1) { + p.y -= speed; + p.x += speed; + } else { + p.dir = rand()%8; + } + + break; + case DIR_DOWN_LEFT: + + if(p.y < h-1 && p.x > 0) { + p.y += speed; + p.x -= speed; + } else { + p.dir = rand()%8; + } + break; + case DIR_DOWN_RIGHT: + if(p.y < h-1 && p.x < w-1) { + p.y += speed; + p.x += speed; + } else { + p.dir = rand()*8; + } + break; + case DIR_DOWN: + if(p.y < h-1) { + p.y += speed; + } else { + p.dir = rand()%8; + } + break; + case DIR_LEFT: + if(p.x > 0) { + p.x -= speed; + } else { + p.dir = rand()%8; + } + break; + case DIR_RIGHT: + if(p.x < w-1) { + p.x += speed; + } else { + p.dir = rand()%8; + } + break; + default: + p.dir = rand()%8; + } + } + } +} + +ac::ParticleEmiter emiter; // initialize + +// Particle Filter +void ac::ParticleRelease(cv::Mat &frame) { + emiter.set(frame);// set values each frame + emiter.draw(frame); // draw values each frame +} + +void ac::ParticleBlend(cv::Mat &frame) { + emiter.set(frame); + emiter.draw_blend(frame); +} + +void ac::ParticleFlash(cv::Mat &frame) { + emiter.set(frame); + emiter.draw_flash(frame); +} + +void ac::ParticleAlpha(cv::Mat &frame) { + emiter.set(frame); + emiter.draw_alpha(frame); +} + +void ac::ParticleFast(cv::Mat &frame) { + static ParticleEmiter emiter; + if(frames_released == true || reset_alpha == true) { + emiter.reset(); + } + emiter.set(frame); + emiter.draw_move(frame); +} + +void ac::ParticleSnow(cv::Mat &frame) { + emiter.set(frame); + emiter.draw_op(frame); +} + + diff --git a/windows/Acid.Cam.Qt.Windows.Project/ac-square.cpp b/windows/Acid.Cam.Qt.Windows.Project/ac-square.cpp new file mode 100755 index 0000000..ad1246d --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/ac-square.cpp @@ -0,0 +1,309 @@ +/* + * Software written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + + +#include "ac.h" + +void ac::Square::setSize(const int &xx, const int &yy, const int &w, const int &h) { + x = xx; + y = yy; + if(width != w || height != h) { + width = w; + height = h; + image.create(cvSize(w, h), CV_8UC3); + } +} +void ac::Square::setPos(const int &p) { + pos = p; +} +void ac::Square::copyImage(const cv::Mat &f) { + for(int i = 0, src_x = x; i < width; ++i, ++src_x) { + for(int z = 0, src_y = y; z < height; ++z, ++src_y) { + cv::Vec3b &pixel = image.at(z, i); + cv::Vec3b src = f.at(src_y, src_x); + pixel = src; + } + } +} +void ac::Square::copyImageToTarget(int xx, int yy, cv::Mat &f) { + for(int i = 0, dst_x = xx; i < width; ++i, ++dst_x) { + for(int z = 0, dst_y = yy; z < height; ++z, ++dst_y) { + cv::Vec3b &pixel = f.at(dst_y, dst_x); + cv::Vec3b src = image.at(z, i); + pixel = src; + } + } +} + +void Square_Swap(ac::Square *squares, int num_w, int num_h, cv::Mat &frame, bool random = false) { + const int w = frame.cols;// frame width + const int h = frame.rows;// frame height + int square_w=(w/num_w), square_h=(h/num_h); + int pos = 0; + ac::Point *points = new ac::Point[num_w*num_h]; + std::vector square_vec; + for(int rx = 0; rx < num_w; ++rx) { + for(int ry = 0; ry < num_h; ++ry) { + int cx = rx*square_w; + int cy = ry*square_h; + points[pos].x = cx; + points[pos].y = cy; + squares[pos].setPos(pos); + squares[pos].setSize(cx, cy, square_w, square_h); + squares[pos].copyImage(frame); + square_vec.push_back(&squares[pos]); + ++pos; + } + } + + static auto rng = std::default_random_engine {}; + // shuffle instead of randomize + if(random == false) std::shuffle(square_vec.begin(), square_vec.end(),rng); + for(int i = 0; i < pos; ++i) { + if(random == false) + // use shuffled + square_vec[i]->copyImageToTarget(points[i].x, points[i].y,frame); + else + // use random + square_vec[rand()%pos]->copyImageToTarget(points[i].x, points[i].y,frame); + } + delete [] points; +} + + +// SquareSwap +void ac::SquareSwap(cv::Mat &frame) { + static int cnt = 0; + switch(cnt) { + case 0: + SquareSwap4x2(frame); + break; + case 1: + SquareSwap8x4(frame); + break; + case 2: + SquareSwap16x8(frame); + break; + case 3: + SquareSwap64x32(frame); + break; + } + ++cnt; + if(cnt > 3) cnt = 0; +} + +void ac::SquareSwap4x2(cv::Mat &frame) { + const int num_w = 4, num_h = 2; + static Square squares[num_w*num_h]; + Square_Swap(squares, num_w, num_h, frame); +} + +void ac::SquareSwap8x4(cv::Mat &frame) { + const int num_w = 8, num_h = 4; + static Square squares[num_w*num_h]; + Square_Swap(squares, num_w, num_h, frame); +} + +void ac::SquareSwap16x8(cv::Mat &frame) { + const int num_w = 16, num_h = 8; + static Square squares[num_w*num_h]; + Square_Swap(squares, num_w, num_h, frame); +} + +void ac::SquareSwap64x32(cv::Mat &) { + //const int num_w = 64, num_h = 32; + //static Square squares[num_w*num_h]; + //Square_Swap(squares, num_w, num_h, frame); +} + +void ac::SquareBars(cv::Mat &frame) { + static const int num_w = 16, num_h = 1; + static Square squares[num_w*num_h]; + Square_Swap(squares, num_w, num_h, frame); +} + +void ac::SquareBars8(cv::Mat &frame) { + static const int num_w = 8, num_h = 1; + static Square squares[num_w*num_h]; + Square_Swap(squares, num_w, num_h, frame); +} + +void ac::SquareSwapRand16x8(cv::Mat &frame) { + static const int num_w = 16, num_h = 8; + static Square squares[num_w*num_h]; + Square_Swap(squares, num_w, num_h, frame, true); +} + +void ac::SquareVertical8(cv::Mat &frame) { + static const int num_w = 1, num_h = 8; + static Square squares[num_w*num_h]; + Square_Swap(squares, num_w, num_h, frame); +} + +void ac::SquareVertical16(cv::Mat &frame) { + static const int num_w = 1, num_h = 16; + static Square squares[num_w*num_h]; + Square_Swap(squares, num_w, num_h, frame); +} + + +void ShiftSquares(std::vector &s, int pos, bool direction=true) { + if(direction == true) { + for(int i = 0; i < s.size(); ++i) { + int p = s[i]->getPos(); + if(p+1 > (int)s.size()-1) { + s[i]->setPos(0); + } else { + ++p; + s[i]->setPos(p); + } + } + } else { + for(int i = 0; i < pos; ++i) { + int p = s[i]->getPos(); + --p; + s[i]->setPos(p); + if(p < 0) { + s[i]->setPos(pos-1); + } + } + } +} + +void SquareVertical(const int num_w, const int num_h, ac::Square *squares, cv::Mat &frame, bool direction=true) { + int w = frame.cols;// frame width + int h = frame.rows;// frame height + + if(w <= 25 || h <= 25) + return; + + int square_w=(w/num_w), square_h=(h/num_h); + int pos = 0; + ac::Point *points = new ac::Point[num_w*num_h]; + std::vector square_vec; + for(int rx = 0; rx < (int)num_w; ++rx) { + for(int ry = 0; ry < (int)num_h; ++ry) { + int cx = rx*square_w; + int cy = ry*square_h; + points[pos].x = cx; + points[pos].y = cy; + squares[pos].setSize(cx, cy, square_w, square_h); + squares[pos].copyImage(frame); + square_vec.push_back(&squares[pos]); + ++pos; + } + } + ShiftSquares(square_vec,pos,direction); + for(int i = 0; i < pos; ++i) { + const int p = square_vec[i]->getPos(); + square_vec[i]->copyImageToTarget(points[p].x, points[p].y, frame); + } + delete [] points; +} + +void ac::SquareVertical_Roll(cv::Mat &frame) { + const int num_w = 1, num_h = 20; + static Square squares[num_w*num_h]; + static int lazy = 0; + if(lazy == 0) { + int cpos = 0; + for(int cx = 0; cx < num_w; ++cx) + for(int cy = 0; cy < num_h; ++cy) { + squares[cpos].setPos(cpos); + ++cpos; + } + lazy = 1; + } + SquareVertical(num_w, num_h, squares, frame); +} + +void ac::SquareSwapSort_Roll(cv::Mat &frame) { + const int num_w = 16, num_h = 8; + static Square squares[num_w*num_h]; + static int lazy = 0; + if(lazy == 0) { + int cpos = 0; + for(int cx = 0; cx < num_w; ++cx) + for(int cy = 0; cy < num_h; ++cy) { + squares[cpos].setPos(cpos); + ++cpos; + } + lazy = 1; + } + SquareVertical(num_w, num_h, squares, frame); +} + +void ac::SquareVertical_RollReverse(cv::Mat &frame) { + const int num_w = 1, num_h = 20; + static Square squares[num_w*num_h]; + static int lazy = 0; + if(lazy == 0) { + int cpos = 0; + for(int cx = 0; cx < num_w; ++cx) + for(int cy = 0; cy < num_h; ++cy) { + squares[cpos].setPos(cpos); + cpos++; + + } + lazy = 1; + } + SquareVertical(num_w, num_h, squares, frame, false); +} + +void ac::SquareSwapSort_RollReverse(cv::Mat &frame) { + const int num_w = 16, num_h = 8; + static Square squares[num_w*num_h]; + static int lazy = 0; + if(lazy == 0) { + int cpos = 0; + for(int cx = 0; cx < num_w; ++cx) + for(int cy = 0; cy < num_h; ++cy) { + ++cpos; + squares[cpos].setPos(cpos); + } + lazy = 1; + } + SquareVertical(num_w, num_h, squares, frame,false); +} + + diff --git a/windows/Acid.Cam.Qt.Windows.Project/ac-util.cpp b/windows/Acid.Cam.Qt.Windows.Project/ac-util.cpp new file mode 100755 index 0000000..aace29e --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/ac-util.cpp @@ -0,0 +1,420 @@ +/* + * Software written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + + +#include "ac.h" + +// Apply color map to cv::Mat +void ac::ApplyColorMap(cv::Mat &frame) { + if(set_color_map > 0 && set_color_map < 13) { + cv::Mat output_f1 = frame.clone(); + cv::applyColorMap(output_f1, frame, (int)set_color_map-1); + const int w = frame.cols; + const int h = frame.rows; + color_map_set = true; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + ac::swapColors(frame, z, i); + if(isNegative) ac::invert(frame, z, i); + } + } + color_map_set = false; + } +} + +// set cv::Mat brightness +void ac::setBrightness(cv::Mat &frame, double alpha, int beta) { + cv::Mat c = frame.clone(); + c.convertTo(frame, -1, alpha, beta); +} + +// set cv::Mat gamma +void ac::setGamma(cv::Mat &frame, cv::Mat &outframe, const double gamma) { + cv::Mat lookUpTable(1, 256, CV_8U); + uchar* p = lookUpTable.ptr(); + for(int i = 0; i < 256; ++i) { + p[i] = cv::saturate_cast(pow(i / 255.0, gamma) * 255.0); + } + cv::Mat res = frame.clone(); + LUT(frame, lookUpTable, outframe); +} + +// set cv::Mat saturation +void ac::setSaturation(cv::Mat &frame, int saturation) { + cv::Mat image; + cv::cvtColor(frame, image, CV_BGR2HSV); + const int w = frame.cols; + const int h = frame.rows; + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = image.at(z, i); + pixel[1] = static_cast(saturation); + } + } + cv::cvtColor(image, frame, CV_HSV2BGR); +} + +void ac::Negate(cv::Mat &frame) { + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = ~pixel[j]; + } + } +} + +void ac::Add(cv::Mat &src, cv::Mat &add, bool sat) { + if(src.size() != add.size()) + return; + if(src.empty() || add.empty()) + return; + + for(int z = 0; z < src.rows; ++z) { + for(int i = 0; i < src.cols; ++i) { + cv::Vec3b &pixel = src.at(z, i); + cv::Vec3b pix = add.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = (sat == true) ? cv::saturate_cast(pixel[j]+pix[j]) : static_cast(pixel[j]+pix[j]); + } + } +} + +void ac::Sub(cv::Mat &src, cv::Mat &sub, bool sat) { + if(src.size() != sub.size()) + return; + if(src.empty() || sub.empty()) + return; + + for(int z = 0; z < src.rows; ++z) { + for(int i = 0; i < src.cols; ++i) { + cv::Vec3b &pixel = src.at(z, i); + cv::Vec3b pix = sub.at(z, i); + for(int j = 0; j < 3; ++j) + pixel[j] = (sat == true) ? cv::saturate_cast(pixel[j]-pix[j]) : static_cast(pixel[j]-pix[j]); + } + } +} + + + +void ac::ScalarAverage(const cv::Mat &frame, cv::Scalar &s) { + s = cv::Scalar(); + if(frame.empty()) return; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b col = frame.at(z, i); + for(int j = 0; j < 3; ++j) + s[j] += col[j]; + } + } + unsigned long total_pixels = frame.rows * frame.cols; + for(int j = 0; j < 3; ++j) + s[j] /= total_pixels; +} + +void ac::TotalAverageOffset(cv::Mat &frame, unsigned long &value) { + if(frame.empty()) return; + value = 0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + value += (pixel[0]+pixel[1]+pixel[2]); + } + } + value /= (frame.rows * frame.cols); +} + +// filter color keyed image +void ac::filterColorKeyed(const cv::Vec3b &color, const cv::Mat &orig, const cv::Mat &filtered, cv::Mat &output) { + if(colorkey_set == false || color_image.empty()) return; + if(orig.size()!=filtered.size()) { + std::cerr << "filterColorKeyed: Error not same size...\n"; + return; + } + output = orig.clone(); + for(int z = 0; z < orig.rows; ++z) { + for(int i = 0; i < orig.cols; ++i) { + int cX = AC_GetFX(color_image.cols, i, orig.cols); + int cY = AC_GetFZ(color_image.rows, z, orig.rows); + cv::Vec3b add_i = color_image.at(cY, cX); + if(add_i == color) { + cv::Vec3b pixel = filtered.at(z, i); + cv::Vec3b &dst = output.at(z, i); + dst = pixel; + } + } + } +} + +// Alpha Blend function +void ac::AlphaBlend(const cv::Mat &one, const cv::Mat &two, cv::Mat &output,double alpha) { + if(one.size() != two.size()) { + return; + } + + if(output.empty() || output.size() != one.size()) + output.create(one.size(), CV_8UC3); + + for(int z = 0; z < one.rows; ++z) { + for(int i = 0; i < one.cols; ++i) { + cv::Vec3b pix[2]; + cv::Vec3b &pixel = output.at(z, i); + pix[0] = one.at(z, i); + pix[1] = two.at(z, i); + pixel[0] = static_cast((pix[0][0] * alpha) + (pix[1][0] * alpha)); + pixel[1] = static_cast((pix[0][1] * alpha) + (pix[1][1] * alpha)); + pixel[2] = static_cast((pix[0][2] * alpha) + (pix[1][2] * alpha)); + } + } +} + +void ac::AlphaXorBlend(const cv::Mat &one, const cv::Mat &two, cv::Mat &output, double alpha) { + if(one.size() != two.size()) { + return; + } + + if(output.empty() || output.size() != one.size()) + output.create(one.size(), CV_8UC3); + + for(int z = 0; z < one.rows; ++z) { + for(int i = 0; i < one.cols; ++i) { + cv::Vec3b pix[2]; + cv::Vec3b &pixel = output.at(z, i); + pix[0] = one.at(z, i); + pix[1] = two.at(z, i); + pixel[0] = static_cast((pix[0][0] * static_cast(alpha)) ^ (pix[1][0] * static_cast(alpha))); + pixel[1] = static_cast((pix[0][1] * static_cast(alpha)) ^ (pix[1][1] * static_cast(alpha))); + pixel[2] = static_cast((pix[0][2] * static_cast(alpha)) ^ (pix[1][2] * static_cast(alpha))); + } + } + +} + +bool ac::reset_alpha = false; + +void ac::resetAlpha(int &dir, double &alpha) { + if(reset_alpha == true) { + alpha = 1.0; + dir = 1; + } +} + +void ac::resetAlpha(double &alpha) { + if(reset_alpha == true) { + alpha = 1.0; + } +} + +void ac::AddInvert(cv::Mat &frame) { + if(in_custom == true) return; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel */ + } + } +} + +// Make two copies of the current frame, apply filter1 to one, filter2 to the other +// then Alpha Blend them together +void ac::filterFade(cv::Mat &frame, int filter1, int filter2, double alpha) { + const int h = frame.rows; // frame height + const int w = frame.cols;// framew idth + // make copies of original frame + cv::Mat frame1 = frame.clone(), frame2 = frame.clone(); + // apply filters on two copies of original frame + ac::draw_func[filter1](frame1); + ac::draw_func[filter2](frame2); + // loop through image setting each pixel with alphablended pixel + for(int z = 0; z < h; ++z) { + for(int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); // target pixel + cv::Vec3b frame1_pix = frame1.at(z, i); // frame1 pixel + cv::Vec3b frame2_pix = frame2.at(z, i); // frame2 pixel + // loop through pixel components and set target pixel to alpha blended pixel of two frames + for(int q = 0; q < 3; ++q) + pixel[q] = static_cast(frame2_pix[q]+(frame1_pix[q]*alpha)); + } + } +} + +// Copy cv::Mat +void ac::copyMat(const cv::Mat &src,int src_x, int src_y ,cv::Mat &target, const ac::Rect &rc) { + for(int i = 0; i < rc.w; ++i) { + for(int z = 0; z < rc.h; ++z) { + if(src_y+z < src.rows && src_x+i < src.cols && rc.y+z < target.rows && rc.x+i < target.cols) { + ASSERT(src_y+z < src.rows && src_x+i < src.cols && rc.y+z < target.rows && rc.x+i < target.cols); + cv::Vec3b &pixel = target.at(rc.y+z, rc.x+i); + cv::Vec3b src_pixel = src.at(src_y+z, src_x+i); + pixel = src_pixel; + } + } + } +} + +void ac::copyMat(const cv::Mat &src, const Point &p, cv::Mat &target, const ac::Rect &rc) { + copyMat(src, p.x, p.y, target, rc); +} + +void ac::copyMat(const cv::Mat &src, int x, int y, cv::Mat &target, int rx, int ry, int rw, int rh) { + copyMat(src, x,y,target,Rect(rx,ry,rw,rh)); +} + +void ac::fillRect(cv::Mat &m, const Rect &r, cv::Vec3b pixel) { + for(int i = r.x; i < r.x+r.w; ++i) { + for(int z = r.y; z < r.y+r.h; ++z) { + ASSERT(i < m.cols && z < m.rows); + cv::Vec3b &pix = m.at(z, i); + pix = pixel; + } + } +} +// set custom callback +void ac::setCustom(DrawFunction f) { + custom_callback = f; +} + +// call custom fitler defined elsewhere +void ac::custom(cv::Mat &frame) { + if(custom_callback != 0) + custom_callback(frame); +} + +void ac::setPlugin(DrawFunction f) { + plugin_func = f; +} + +void ac::plugin(cv::Mat &frame) { + if(plugin_func != 0) { + plugin_func(frame); + } +} + +ac::DrawFunction ac::getFilter(std::string name) { + return ac::draw_func[filter_map[name]]; +} + +bool ac::testSize(cv::Mat &frame) { + if(frame.cols < frame.cols/64 || frame.rows < frame.rows/64) + return false; + + return true; +} + +ac::DrawFunction ac::getRandomFilter(int &index) { + int num; + do { + num = rand()%(draw_max-6); + size_t pos = 0; + pos = ac::draw_strings[num].find("Feedback"); + if(pos != std::string::npos) + continue; + } while(ac::draw_strings[num] == "Blend Fractal" || ac::draw_strings[num] == "Blend Fractal Mood"); + index = num; + return draw_func[num]; +} + +int ac::subfilter = -1; + +void ac::setSubFilter(int value) { + subfilter = value; +} + +void ac::clearSubFilter() { + subfilter = -1; +} + +void ac::DarkenImage(cv::Mat &frame, unsigned int size) { + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + pixel[j] /= size; + } + } + } +} + +void ac::SwapColors(cv::Vec3b &cur) { + cv::Vec3b temp = cur; + int color_order = rand()%5; + switch(color_order) { + case 1: cur[0] = temp[2]; + cur[1] = temp[1]; + cur[2] = temp[0]; + break; + case 2: + cur[0] = temp[1]; + cur[1] = temp[0]; + break; + case 3: + cur[1] = temp[2]; + cur[2] = temp[1]; + break; + case 4: + cur[0] = temp[1]; + cur[1] = temp[2]; + cur[2] = temp[0]; + break; + } +} + +void ac::FillRow(cv::Mat &frame, unsigned int row, unsigned char value) { + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Vec3b &pixel = frame.at(z, i); + pixel[row] = value; + } + } +} + +void ac::Shuffle(int &index, cv::Mat &frame, std::vector &filter_array) { + static auto rng = std::default_random_engine{}; + CallFilter(filter_array[index], frame); + ++index; + if(index > filter_array.size()-1) { + index = 0; + std::shuffle(filter_array.begin(), filter_array.end(),rng); + } +} diff --git a/windows/Acid.Cam.Qt.Windows.Project/ac.h b/windows/Acid.Cam.Qt.Windows.Project/ac.h new file mode 100755 index 0000000..81e77f1 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/ac.h @@ -0,0 +1,1120 @@ +/* + * Acid Cam Functions for OpenCV + * written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef __AC_H__ +#define __AC_H__ +#ifdef __APPLE__ +#include +#include +#include +#else +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#define ASSERT_CHECK +// Macro for assert testing +#ifdef ASSERT_CHECK +#define ASSERT(X) assert(X) +#else +#define ASSERT(X) +#endif +/* + * + * Be sure to call fill_filter_map + * to use set appropriate variables, call the function + * + * ac::SelfAlphaBlend(mat); + * + * or use draw_func + * + * ac::draw_func[function_index](mat); + * + * then just use function_index to point to whatever filter + * + * for text of the filter use the following array of strings + * + * ac::draw_strings[function_index]; + * + */ +// exernal variables +extern int current_filterx, bytesPerSample, bytesPerRow, width, height, red, green, blue, offset, randomNumber, reverse; +extern bool negate, blend_set, colorkey_set; +extern cv::Mat blend_image,color_image; + +int AC_GetFX(int oldw,int x, int nw); +int AC_GetFZ(int oldh, int y, int nh); + +// acid cam namespace +namespace ac { + // get version string + extern std::string getVersion(); + // version string + extern const std::string version; + extern double translation_variable, pass2_alpha; + extern double alpha, tr; + extern bool isNegative, noRecord,iRev; + extern int color_order; + extern double fps; + extern int draw_offset; + extern int subfilter; + extern std::string fileName; + extern cv::Mat orig_frame; + extern cv::Mat blendW_frame; + extern cv::Mat image_files[4]; + extern bool images_Enabled,fps_force; + extern int snapshot_Type; + extern bool in_custom; + extern int swapColor_r, swapColor_g, swapColor_b; + extern cv::Size resolution; + extern bool strobe_It; + extern int set_color_map; + extern bool color_map_set; + extern int GetFX(cv::Mat &frame, int x, int nw); + extern int GetFY(cv::Mat &frame, int y, int nh); + extern bool reset_alpha; + void invert(cv::Mat &frame, int x, int y); + /* filter typedef */ + typedef void (*DrawFunction)(cv::Mat &frame); + typedef std::pair FilterType; + extern DrawFunction custom_callback; + extern DrawFunction plugin_func; + // ror/rol tempaltes + template + inline T ror(T x, int m){ + return (x >> m) | (x << (sizeof(T)*8 - m)); + } + template + inline T rol(T x, int m) { + return (x << m) | (x >> (sizeof(T)*8 -m)); + } + // be sure to call this when the application starts + void fill_filter_map(); + // draw functions + DrawFunction getRandomFilter(int &index); + void DrawFilter(const std::string &name, const cv::Mat &frame, cv::Mat &outframe); + void DrawFilter(int index, const cv::Mat &frame, cv::Mat &outframe); + void DrawFilter(int index, cv::Mat &frame); + void DrawFilter(const std::string &name, cv::Mat &frame); + DrawFunction getFilter(std::string name); + FilterType filterByIndex(const int &num); + FilterType filterByString(const std::string &num); + bool CallFilter(int index, cv::Mat &frame); + bool CallFilter(const std::string &name, cv::Mat &frame); + // Acid Cam Filter Function prototypes + void SelfAlphaBlend(cv::Mat &frame); + void SelfScale(cv::Mat &frame); + void StrobeEffect(cv::Mat &frame); + void Blend3(cv::Mat &frame); + void NegParadox(cv::Mat &frame); + void ThoughtMode(cv::Mat &frame); + void Pass2Blend(cv::Mat &frame); + void RandTriBlend(cv::Mat &frame); + void Blank(cv::Mat &frame); + void Tri(cv::Mat &frame); + void Distort(cv::Mat &frame); + void CDraw(cv::Mat &frame); + void Type(cv::Mat &frame); + void NewOne(cv::Mat &frame); + void blendWithImage(cv::Mat &frame); + void triBlendWithImage(cv::Mat &frame); + void imageStrobe(cv::Mat &frame); + void imageDistraction(cv::Mat &frame); + void blendFractal(cv::Mat &frame); + void blendFractalMood(cv::Mat &frame); + void cossinMultiply(cv::Mat &frame); + void colorAccumulate1(cv::Mat &frame); + void colorAccumulate2(cv::Mat &frame); + void colorAccumulate3(cv::Mat &frame); + void filter8(cv::Mat &frame); + void filter3(cv::Mat &frame); + void rainbowBlend(cv::Mat &frame); + void randBlend(cv::Mat &frame); + void newBlend(cv::Mat &frame); + void alphaFlame(cv::Mat &frame); + void custom(cv::Mat &frame); + void pixelScale(cv::Mat &frame); + void glitchSort(cv::Mat &frame); + void pixelSort(cv::Mat &frame); + void randomFilter(cv::Mat &frame); + void randomFlash(cv::Mat &frame); + void imageBlend(cv::Mat &frame); + void imageBlendTwo(cv::Mat &frame); + void imageBlendThree(cv::Mat &frame); + void imageBlendFour(cv::Mat &frame); + void GaussianBlur(cv::Mat &frame); + void MedianBlur(cv::Mat &frame); + void BlurDistortion(cv::Mat &frame); + void DiamondPattern(cv::Mat &frame); + void MirrorBlend(cv::Mat &frame); + void Pulse(cv::Mat &frame); + void SidewaysMirror(cv:: Mat &frame); + void MirrorNoBlend(cv::Mat &frame); + void SortFuzz(cv::Mat &frame); + void Fuzz(cv::Mat &frame); + void DoubleVision(cv::Mat &frame); + void RGBShift(cv::Mat &frame); + void RGBSep(cv::Mat &frame); + void GradientRainbow(cv::Mat &frame); + void GradientRainbowFlash(cv::Mat &frame); + void Reverse(cv::Mat &frame); + void Scanlines(cv::Mat &frame); + void TVStatic(cv::Mat &frame); + void MirrorAverage(cv::Mat &frame); + void MirrorAverageMix(cv::Mat &frame); + void Mean(cv::Mat &frame); + void Laplacian(cv::Mat &frame); + void Bitwise_XOR(cv::Mat &frame); + void Bitwise_AND(cv::Mat &frame); + void Bitwise_OR(cv::Mat &frame); + void Equalize(cv::Mat &frame); + void ChannelSort(cv::Mat &frame); + void Reverse_XOR(cv::Mat &frame); + void CombinePixels(cv::Mat &frame); + void FlipTrip(cv::Mat &frame); + void Canny(cv::Mat &frame); + void Boxes(cv::Mat &frame); + void BoxesFade(cv::Mat &frame); + void FlashBlack(cv::Mat &frame); + void SlideRGB(cv::Mat &frame); + void Side2Side(cv::Mat &frame); + void Top2Bottom(cv::Mat &frame); + void StrobeRedGreenBlue(cv::Mat &frame); + void Outward(cv::Mat &frame); + void OutwardSquare(cv::Mat &frame); + void Blend_Angle(cv::Mat &frame); + void ShiftPixels(cv::Mat &frame); + void ShiftPixelsDown(cv::Mat &frame); + void XorMultiBlend(cv::Mat &frame); + void BitwiseRotate(cv::Mat &frame); + void BitwiseRotateDiff(cv::Mat &frame); + void HPPD(cv::Mat &frame); + void FuzzyLines(cv::Mat &frame); + void GradientLines(cv::Mat &frame); + void GradientSelf(cv::Mat &frame); + void GradientDown(cv::Mat &frame); + void GraidentHorizontal(cv::Mat &frame); + void GradientSelfVertical(cv::Mat &frame); + void GradientRGB(cv::Mat &frame); + void Inter(cv::Mat &frame); + void UpDown(cv::Mat &frame); + void LeftRight(cv::Mat &frame); + void StrobeScan(cv::Mat &frame); + void BlendedScanLines(cv::Mat &frame); + void GradientStripes(cv::Mat &frame); + void XorSine(cv::Mat &frame); + void SquareSwap(cv::Mat &frame); + void SquareSwap4x2(cv::Mat &frame); + void SquareSwap8x4(cv::Mat &frame); + void SquareSwap16x8(cv::Mat &frame); + void SquareSwap64x32(cv::Mat &frame); + void SquareBars(cv::Mat &frame); + void SquareBars8(cv::Mat &frame); + void SquareVertical8(cv::Mat &frame); + void SquareVertical16(cv::Mat &frame); + void SquareVertical_Roll(cv::Mat &frame); + void SquareSwapRand16x8(cv::Mat &frame); + void SquareSwapSort_Roll(cv::Mat &frame); + void SquareVertical_RollReverse(cv::Mat &frame); + void SquareSwapSort_RollReverse(cv::Mat &frame); + void Circular(cv::Mat &frame); + void WhitePixel(cv::Mat &frame); + void FrameBlend(cv::Mat &frame); + void FrameBlendRGB(cv::Mat &frame); + void TrailsFilter(cv::Mat &frame); + void TrailsFilterIntense(cv::Mat &frame); + void TrailsFilterSelfAlpha(cv::Mat &frame); + void TrailsFilterXor(cv::Mat &frame); + void ColorTrails(cv::Mat &frame); + void MoveRed(cv::Mat &frame); + void MoveRGB(cv::Mat &frame); + void MoveRedGreenBlue(cv::Mat &frame); + void BlurSim(cv::Mat &frame); + void Block(cv::Mat &frame); + void BlockXor(cv::Mat &frame); + void BlockScale(cv::Mat &frame); + void BlockStrobe(cv::Mat &frame); + void PrevFrameBlend(cv::Mat &frame); + void Wave(cv::Mat &frame); + void HighWave(cv::Mat &frame); + void VerticalSort(cv::Mat &frame); + void VerticalChannelSort(cv::Mat &frame); + void HorizontalBlend(cv::Mat &frame); + void VerticalBlend(cv::Mat &frame); + void OppositeBlend(cv::Mat &frame); + void DiagonalLines(cv::Mat &frame); + void HorizontalLines(cv::Mat &frame); + void InvertedScanlines(cv::Mat &frame); + void Soft_Mirror(cv::Mat &frame); + void KanapaTrip(cv::Mat &frame); + void ColorMorphing(cv::Mat &frame); + void ScanSwitch(cv::Mat &frame); + void ScanAlphaSwitch(cv::Mat &frame); + void NegativeStrobe(cv::Mat &frame); + void XorAddMul(cv::Mat &frame); + void ParticleRelease(cv::Mat &frame); + void BlendSwitch(cv::Mat &frame); + void AllRed(cv::Mat &frame); + void AllGreen(cv::Mat &frame); + void AllBlue(cv::Mat &frame); + void LineRGB(cv::Mat &frame); + void PixelRGB(cv::Mat &frame); + void BoxedRGB(cv::Mat &frame); + void KruegerSweater(cv::Mat &frame); + void RGBFlash(cv::Mat &frame); + void IncreaseBlendHorizontal(cv::Mat &frame); + void BlendIncrease(cv::Mat &frame); + void GradientReverse(cv::Mat &frame); + void GradientReverseVertical(cv::Mat &frame); + void GradientReverseBox(cv::Mat &frame); + void GradientNewFilter(cv::Mat &frame); + void ReinterpretDouble(cv::Mat &frame); + void ReinterpSelfScale(cv::Mat &frame); + void AverageLines(cv::Mat &frame); + void ImageFile(cv::Mat &frame); + void ImageXor(cv::Mat &frame); + void ImageAlphaBlend(cv::Mat &frame); + void ColorRange(cv::Mat &frame); + void ImageInter(cv::Mat &frame); + void TrailsInter(cv::Mat &frame); + void TrailsBlend(cv::Mat &frame); + void TrailsNegate(cv::Mat &frame); + void InterReverse(cv::Mat &frame); + void InterMirror(cv::Mat &frame); + void InterFullMirror(cv::Mat &frame); + void MirrorRGB(cv::Mat &frame); + void RGBStatic1(cv::Mat &frame); + void RGBStatic2(cv::Mat &frame); + void VectorIncrease(cv::Mat &frame); + void LineByLineReverse(cv::Mat &frame); + void RandomIntertwine(cv::Mat &frame); + void RandomFour(cv::Mat &frame); + void BlendThree(cv::Mat &frame); + void AcidTrails(cv::Mat &frame); + void RandomTwo(cv::Mat &frame); + void HorizontalTrailsInter(cv::Mat &frame); + void Trails(cv::Mat &frame); + void BlendTrails(cv::Mat &frame); + void RandomFilteredSquare(cv::Mat &frame); + void ImageX(cv::Mat &frame); + void RandomQuads(cv::Mat &frame); + void QuadCosSinMultiply(cv::Mat &frame); + void QuadRandomFilter(cv::Mat &frame); + void RollRandom(cv::Mat &frame); + void AverageRandom(cv::Mat &frame); + void HorizontalStripes(cv::Mat &frame); + void DiamondStrobe(cv::Mat &frame); + void SmoothTrails(cv::Mat &frame); + void GridFilter8x(cv::Mat &frame); + void GridFilter16x(cv::Mat &frame); + void GridFilter8xBlend(cv::Mat &frame); + void GridRandom(cv::Mat &frame); + void GridRandomPixel(cv::Mat &frame); + void Dual_SelfAlphaRainbow(cv::Mat &frame); + void Dual_SelfAlphaBlur(cv::Mat &frame); + void SurroundPixelXor(cv::Mat &frame); + void Darken(cv::Mat &frame); + void WeakBlend(cv::Mat &frame); + void AverageVertical(cv::Mat &frame); + void RandomCollectionAverage(cv::Mat &frame); + void RandomCollectionAverageMax(cv::Mat &frame); + void SmoothTrailsSelfAlphaBlend(cv::Mat &frame); + void SmoothTrailsRainbowBlend(cv::Mat &frame); + void MedianBlend(cv::Mat &frame); + void SmoothRandomImageBlend(cv::Mat &frame); + void SmoothImageAlphaBlend(cv::Mat &frame); + void RandomAlphaBlend(cv::Mat &frame); + void RandomTwoFilterAlphaBlend(cv::Mat &frame); + void PixelatedSquare(cv::Mat &frame); + void AlphaBlendPosition(cv::Mat &frame); + void BlendRowAlpha(cv::Mat &frame); + void BlendRow(cv::Mat &frame); + void BlendRowByVar(cv::Mat &frame); + void BlendRowByDirection(cv::Mat &frame); + void BlendAlphaXor(cv::Mat &frame); + void SelfXorScale(cv::Mat &frame); + void BitwiseXorScale(cv::Mat &frame); + void XorTrails(cv::Mat &frame); + void RainbowTrails(cv::Mat &frame); + void NegativeTrails(cv::Mat &frame); + void IntenseTrails(cv::Mat &frame); + void SelfAlphaRGB(cv::Mat &frame); + void BlendImageOnOff(cv::Mat &frame); + void XorSelfAlphaImage(cv::Mat &frame); + void BitwiseXorStrobe(cv::Mat &frame); + void AlphaBlendRandom(cv::Mat &frame); + void ChannelSortAlphaBlend(cv::Mat &frame); + void XorChannelSort(cv::Mat &frame); + void GradientColors(cv::Mat &frame); + void GradientColorsVertical(cv::Mat &frame); + void Bitwise_XOR_Average(cv::Mat &frame); + void NotEqual(cv::Mat &frame); + void ImageShiftUpLeft(cv::Mat &frame); + void GradientXorSelfScale(cv::Mat &frame); + void SmoothSourcePixel(cv::Mat &frame); + void StrobeBlend(cv::Mat &frame); + void FrameBars(cv::Mat &frame); + void Sort_Vertical_Horizontal(cv::Mat &frame); + void Sort_Vertical_Horizontal_Bitwise_XOR(cv::Mat &frame); + void Scalar_Average_Multiply(cv::Mat &frame); + void Scalar_Average(cv::Mat &frame); + void Total_Average(cv::Mat &frame); + void AlphaBlendImageXor(cv::Mat &frame); + void FlashWhite(cv::Mat &frame); + void FlashBlackAndWhite(cv::Mat &frame); + void GaussianBlend(cv::Mat &frame); + void RandomXor(cv::Mat &frame); + void RandomXorFlash(cv::Mat &frame); + void RandomAmountMedianBlur(cv::Mat &frame); + void SoftXor(cv::Mat &frame); + void SelfXorBlend(cv::Mat &frame); + void SelfXorDoubleFlash(cv::Mat &frame); + void SelfOrDoubleFlash(cv::Mat &frame); + void BlendRowCurvedSqrt(cv::Mat &frame); + void CycleShiftRGB(cv::Mat &frame); + void CycleShiftRandomRGB(cv::Mat &frame); + void CycleShiftRandomRGB_XorBlend(cv::Mat &frame); + void CycleShiftRandomAlphaBlend(cv::Mat &frame); + void VerticalColorBars(cv::Mat &frame); + void GradientLeftRight(cv::Mat &frame); + void GraidentUpDown(cv::Mat &frame); + void GradientLeftRightInOut(cv::Mat &frame); + void GradientUpDownInOut(cv::Mat &frame); + void Lines(cv::Mat &frame); + void ColorLines(cv::Mat &frame); + void WhiteLines(cv::Mat &frame); + void ThickWhiteLines(cv::Mat &frame); + void UseLineObject(cv::Mat &frame); + void TanAlphaGrid(cv::Mat &frame); + void MedianBlendAnimation(cv::Mat &frame); + void FibFlash(cv::Mat &frame); + void ScaleFlash(cv::Mat &frame); + void LeftLines(cv::Mat &frame); + void Curtain(cv::Mat &frame); + void RandomCurtain(cv::Mat &frame); + void CurtainVertical(cv::Mat &frame); + void RandomCurtainVertical(cv::Mat &frame); + void inOrder(cv::Mat &frame); + void inOrderBySecond(cv::Mat &frame); + void DarkenFilter(cv::Mat &frame); + void RandomFilterBySecond(cv::Mat &frame); + void ThreeRandom(cv::Mat &frame); + void inOrderAlpha(cv::Mat &frame); + void inOrderAlphaXor(cv::Mat &frame); + void SlideFilterXor(cv::Mat &frame); + void SlideFilter(cv::Mat &frame); + void RandomSlideFilter(cv::Mat &frame); + void SlideUpDown(cv::Mat &frame); + void SlideUpDownXor(cv::Mat &frame); + void SlideUpDownRandom(cv::Mat &frame); + void SlideSubFilter(cv::Mat &frame); + void SlideSubUpDownFilter(cv::Mat &frame); + void ParticleBlend(cv::Mat &frame); + void ParticleFlash(cv::Mat &frame); + void ExactImage(cv::Mat &frame); + void ParticleAlpha(cv::Mat &frame); + void BlendInAndOut(cv::Mat &frame); + void BlendScaleInAndOut(cv::Mat &frame); + void AcidGlitch(cv::Mat &frame); + void XorBackwards(cv::Mat &frame); + void LiquidFilter(cv::Mat &frame); + void MatrixXorAnd(cv::Mat &frame); + void XorAlpha(cv::Mat &frame); + void AlphaAcidTrails(cv::Mat &frame); + void SelfXorAverage(cv::Mat &frame); + void RandomXorBlend(cv::Mat &frame); + void RGBVerticalXor(cv::Mat &frame); + void RGBVerticalXorScale(cv::Mat &frame); + void RGBHorizontalXor(cv::Mat &frame); + void RGBHorizontalXorScale(cv::Mat &frame); + void FadeStrobe(cv::Mat &frame); + void RGBMirror(cv::Mat &frame); + void MirrorStrobe(cv::Mat &frame); + void AndStrobe(cv::Mat &frame); + void AndStrobeScale(cv::Mat &frame); + void AndPixelStrobe(cv::Mat &frame); + void AndOrXorStrobe(cv::Mat &frame); + void AndOrXorStrobeScale(cv::Mat &frame); + void FadeInAndOut(cv::Mat &frame); + void BrightStrobe(cv::Mat &frame); + void DarkStrobe(cv::Mat &frame); + void ParticleFast(cv::Mat &frame); + void RandomXorOpposite(cv::Mat &frame); + void StrobeTransform(cv::Mat &frame); + void InitBlend(cv::Mat &frame); + void MoveUpLeft(cv::Mat &frame); + void RandomStrobe(cv::Mat &frame); + void RandomBlur(cv::Mat &frame); + void Stuck(cv::Mat &frame); + void StuckStrobe(cv::Mat &frame); + void OrStrobe(cv::Mat &frame); + void LagBlend(cv::Mat &frame); + void SubFilter(cv::Mat &frame); + void AddFilter(cv::Mat &frame); + void BlendImageXor(cv::Mat &frame); + void BlendImageAround_Median(cv::Mat &frame); + void ImageBlendTransform(cv::Mat &frame); + void RGBTrails(cv::Mat &frame); + void RGBTrailsDark(cv::Mat &frame); + void RGBTrailsAlpha(cv::Mat &frame); + void RGBTrailsNegativeAlpha(cv::Mat &frame); + void MovementRGBTrails(cv::Mat &frame); + void RGBTrailsXor(cv::Mat &frame); + void DifferenceStrobe(cv::Mat &frame); + void BlackAndWhiteDifferenceStrobe(cv::Mat &frame); + void DifferenceXor(cv::Mat &frame); + void DifferenceRand(cv::Mat &frame); + void DifferenceBrightStrobe(cv::Mat &frame); + void PsycheTrails(cv::Mat &frame); + void FourSquare(cv::Mat &frame); + void EightSquare(cv::Mat &frame); + void DiagonalSquare(cv::Mat &frame); + void DiagonalSquareRandom(cv::Mat &frame); + void SquareStretchDown(cv::Mat &frame); + void SquareStretchRight(cv::Mat &frame); + void SquareStretchUp(cv::Mat &frame); + void SquareStretchLeft(cv::Mat &frame); + void DarkTrails(cv::Mat &frame); + void SoftFeedback(cv::Mat &frame); + void SoftFeedbackFrames(cv::Mat &frame); + void ResizeSoftFeedback(cv::Mat &frame); + void SoftFeedback8(cv::Mat &frame); + void SoftFeedbackFrames8(cv::Mat &frame); + void ResizeSoftFeedback8(cv::Mat &frame); + void ResizeSoftFeedbackSubFilter(cv::Mat &frame); + void SoftFeedbackRandFilter(cv::Mat &frame); + void SoftFeedback32(cv::Mat &frame); + void SoftFeedbackFrames32(cv::Mat &frame); + void ResizeSoftFeedback32(cv::Mat &frame); + void SoftFeedbackRandFilter32(cv::Mat &frame); + void SoftFeedbackSubFilter(cv::Mat &frame); + void SoftFeedbackResize64(cv::Mat &frame); + void SoftFeedbackResizeSubFilter(cv::Mat &frame); + void SoftFeedbackResizeSubFilter64(cv::Mat &frame); + void SoftFeedbackReszieSubFilter64_Negate(cv::Mat &frame); + void SoftFeedbackReszieSubFilter64_Mirror(cv::Mat &frame); + void HalfNegateStrobe(cv::Mat &frame); + void MedianBlurXor(cv::Mat &frame); + void NegateTrails(cv::Mat &frame); + void RandomGradient(cv::Mat &frame); + void RandomStrobeFlash(cv::Mat &frame); + void RandomMirror(cv::Mat &frame); + void RandomOther(cv::Mat &frame); + void RandomXorFilter(cv::Mat &frame); + void RandomMirrorBlend(cv::Mat &frame); + void RandomMirrorAlphaBlend(cv::Mat &frame); + void Bitwise_XOR_AlphaSubFilter(cv::Mat &frame); + void AlphaBlendSubFilter(cv::Mat &frame); + void GradientSubFilterXor(cv::Mat &frame); + void XorBlend_SubFilter(cv::Mat &frame); + void SmoothSubFilterAlphaBlend(cv::Mat &frame); + void SmoothSubFilterXorBlend(cv::Mat &frame); + void IntertwineSubFilter(cv::Mat &frame); + void RandBlend(cv::Mat &frame); + void EveryOther(cv::Mat &frame); + void EveryOtherSubFilter(cv::Mat &frame); + void SmoothRandomFilter(cv::Mat &frame); + void RandomFilterRandomTimes(cv::Mat &frame); + void RandomSubFilterRandomTimes(cv::Mat &frame); + void AddToFrameSubFilter(cv::Mat &frame); + void MirrorXor(cv::Mat &frame); + void MirrorXorAll(cv::Mat &frame); + void MirrorXorScale(cv::Mat &frame); + void EnergyMirror(cv::Mat &frame); + void SmoothSubFilter(cv::Mat &frame); + void SmoothSubFilter16(cv::Mat &frame); + void EnergizeSubFilter(cv::Mat &frame); + void EnergizeSubFilter16(cv::Mat &frame); + void EnergizeSubFilter32(cv::Mat &frame); + void SmoothSubFilter32(cv::Mat &frame); + void HalfAddSubFilter(cv::Mat &frame); + void HalfXorSubFilter(cv::Mat &frame); + void StaticXorBlend(cv::Mat &frame); + void PsycheSort(cv::Mat &frame); + void XorScale(cv::Mat &frame); + void ChannelMedianSubFilter(cv::Mat &frame); + void GaussianStrobe(cv::Mat &frame); + void StrobeSort(cv::Mat &frame); + void GlitchSortStrobe(cv::Mat &frame); + void Bitwise_XOR_Blend(cv::Mat &frame); + void Bitwise_XOR_Sort(cv::Mat &frame); + void Bitwise_OR_Blend(cv::Mat &frame); + void Bitwise_AND_Blend(cv::Mat &frame); + void BitwiseColorMatrix(cv::Mat &frame); + void PixelReverseXor(cv::Mat &frame); + void PixelatedSubFilterSort(cv::Mat &frame); + void SilverBlend(cv::Mat &frame); + void RandomPixelOrderSort(cv::Mat &frame); + void ImageXorAlpha(cv::Mat &frame); + void ImageAverageXor(cv::Mat &frame); + void PixelXorBlend(cv::Mat &frame); + void SelfAlphaScale(cv::Mat &frame); + void SelfScaleAlpha(cv::Mat &frame); + void RainbowXorBlend(cv::Mat &frame); + void FrameDifference(cv::Mat &frame); + void SmallDiffference(cv::Mat &frame); + void FadeBlend(cv::Mat &frame); + void FilteredDifferenceSubFilter(cv::Mat &frame); + void ExpandSquareSubFilter(cv::Mat &frame); + void ExpandSquareBlendSubFilter(cv::Mat &frame); + void ExpandSquareVerticalSubFilter(cv::Mat &frame); + void DarkImageMedianBlend(cv::Mat &frame); + void GammaDarken5(cv::Mat &frame); + void GammaDarken10(cv::Mat &frame); + void SelfAlphaScaleBlend(cv::Mat &frame); + void FadeBars(cv::Mat &frame); + void MirrorXorAlpha(cv::Mat &frame); + void MirrorEnergizeSubFilter(cv::Mat &frame); + void StrobeXor(cv::Mat &frame); + void IntertwinedMirror(cv::Mat &frame); + void BlurredMirror(cv::Mat &frame); + void ShadeRGB(cv::Mat &frame); + void InterRGB_SubFilter(cv::Mat &frame); + void InterSmoothSubFilter(cv::Mat &frame); + void InterRGB_Bars_XY(cv::Mat &frame); + void InterRGB_Bars_X(cv::Mat &frame); + void InterRGB_Bars_Y(cv::Mat &frame); + void StoredFramesAlphaBlend_SubFilter(cv::Mat &frame); + void BlendSubFilter(cv::Mat &frame); + void BlendAlphaSubFilter(cv::Mat &frame); + void ReverseFrameBlend(cv::Mat &frame); + void ReverseFrameBlendSwitch(cv::Mat &frame); + void DoubleRandomMirror(cv::Mat &frame); + void Blend_AlphaSubFilter(cv::Mat &frame); + void RandomBlendFilter(cv::Mat &frame); + void DoubleRandomBlendFilter(cv::Mat &frame); + void FlipBlendWH(cv::Mat &frame); + void FlipBlendW(cv::Mat &frame); + void FlipBlendH(cv::Mat &frame); + void FlipBlendAll(cv::Mat &frame); + void FrameMedianBlendSubFilter(cv::Mat &frame); + void FrameBlurSubFilter(cv::Mat &frame); + void ImageBlendSubFilter(cv::Mat &frame); + void ImageBlendXorSubFilter(cv::Mat &frame); + void ImageCollectionSubFilter(cv::Mat &frame); + void SelfScaleXorIncrease(cv::Mat &frame); + void Blend_RedGreenBlue(cv::Mat &frame); + void XorBlend_RedGreenBlue(cv::Mat &frame); + void BlendIncrease_RedGreenBlue(cv::Mat &frame); + void Blend_RedReenBlue_Dark(cv::Mat &frame); + void DarkModBlend(cv::Mat &frame); + void PictureBuzz(cv::Mat &frame); + void IncDifference(cv::Mat &frame); + void IncDifferenceAlpha(cv::Mat &frame); + void MirrorMedianBlend(cv::Mat &frame); + void SubFilterMedianBlend(cv::Mat &frame); + void DarkenBlend(cv::Mat &frame); + void DarkCollectionSubFilter(cv::Mat &frame); + void ChannelSort_NoBlend_Descending(cv::Mat &frame); + void ChannelSort_NoBlend_Ascending(cv::Mat &frame); + void Headrush(cv::Mat &frame); + void DarkSmooth_Filter(cv::Mat &frame); + void DarkSelfAlpha(cv::Mat &frame); + void FlipMedian(cv::Mat &frame); + void FlipMedianSubFilter(cv::Mat &frame); + void FlipMirror(cv::Mat &frame); + void FlipMirrorAverage(cv::Mat &frame); + void FlipMirrorSubFilter(cv::Mat &frame); + void ShuffleMedian(cv::Mat &frame); + void ShuffleRGB(cv::Mat &frame); + void ParticleSnow(cv::Mat &frame); + void RandomPixels(cv::Mat &frame); + void DarkRandomPixels(cv::Mat &frame); + void MedianBlurSubFilter(cv::Mat &frame); + void Bars(cv::Mat &frame); + void ShuffleAlpha(cv::Mat &frame); + void AlphaMorph(cv::Mat &frame); + void ShuffleSelf(cv::Mat &frame); + // No filter (do nothing) + void NoFilter(cv::Mat &frame); + // Alpha blend with original image + void BlendWithSource(cv::Mat &frame); + // plugin must be implemented in project + void plugin(cv::Mat &frame); + // set Custom Filter callback function + void setCustom(DrawFunction f); + void setPlugin(DrawFunction f); + void setProcMode(int value); + void setSubFilter(int value); + void clearSubFilter(); + // color maps + void Negate(cv::Mat &frame); + void ApplyColorMap(cv::Mat &frame); + void AddInvert(cv::Mat &frame); + // color correction + void setBlendPercentage(const double &value); + void setBrightness(cv::Mat &frame, double alpha, int beta); + void setGamma(cv::Mat &frame, cv::Mat &outframe, double gamma); + void setSaturation(cv::Mat &frame, int saturation); + void AlphaBlend(const cv::Mat &one, const cv::Mat &two, cv::Mat &output, double alpha); + void AlphaXorBlend(const cv::Mat &one, const cv::Mat &two, cv::Mat &output, double alpha); + void DarkenImage(cv::Mat &frame, unsigned int size); + void Add(cv::Mat &src, cv::Mat &add, bool sat = false); + void Sub(cv::Mat &src, cv::Mat &sub, bool sat = false); + void ScalarAverage(const cv::Mat &frame, cv::Scalar &s); + void TotalAverageOffset(cv::Mat &frame, unsigned long &value); + void swapColors(cv::Mat &frame, int x, int y); + void swapColors_(cv::Mat &frame, int x, int y); + void procPos(int &direction, double &pos, double &pos_max, const double max_size = 15, double iter = 0.05); + // Alpha Blend two filters and set to frame by alpha variable + void filterFade(cv::Mat &frame, int filter1, int filter2, double alpha); + void filterColorKeyed(const cv::Vec3b &color, const cv::Mat &orig, const cv::Mat &filtered, cv::Mat &output); + void resetAlpha(int &dir, double &alpha); + void resetAlpha(double &alpha); + void SwapColors(cv::Vec3b &v); + void FillRow(cv::Mat &frame, unsigned int row, unsigned char value); + void Shuffle(int &index, cv::Mat &frame, std::vector &filter_array); + // draw functions / strings + extern std::string *draw_strings; + extern DrawFunction plugin_func; + extern DrawFunction *draw_func; + extern FilterType *filter_array; + extern int draw_max; + extern bool snapShot; + extern bool reset_filter; + extern double alpha_increase; + extern std::unordered_map filter_map; + extern bool frames_released; + extern std::vector all_objects; + // Matrix Collection template + template + class MatrixCollection { + public: + static constexpr int ArraySize = Size; + MatrixCollection() : w(0), h(0) { + for(int i = 0; i < Size; ++i) + all_objects.push_back(&frames[i]); + } + cv::Mat frames[Size+4]; + int w, h; + void shiftFrames(cv::Mat &frame) { + int wx = frame.cols; + int wh = frame.rows; + // check if any frames were released. + bool check_released = false; + for(int i = 0; i < Size; ++i) { + if(frames[i].empty()) { + check_released = true; + break; + } + } + if(check_released == true || (w != wx || h != wh) || reset_filter == true || frames_released == true) { + for(int i = 0; i < Size; ++i) + frames[i] = frame.clone(); + w = wx; + h = wh; + reset_filter = false; + return; + } + for(int i = Size-1; i > 0; --i) { + frames[i] = frames[i-1]; + } + frames[0] = frame.clone(); + } + + int size() const { return ArraySize; } + }; + extern void release_all_objects(); + extern bool testSize(cv::Mat &frame); + // Trails function + template + void Smooth(cv::Mat &frame, MatrixCollection *collection, bool addframe = true) { + if(addframe == true) + collection->shiftFrames(frame); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Scalar test; + for(int q = 0; q < collection->size()-1; ++q) { + cv::Mat &framev = collection->frames[q]; + cv::Vec3b pix = framev.at(z, i); + for(int j = 0; j < 3; ++j) { + test[j] += pix[j]; + } + } + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + test[j] /= (collection->size()-1); + pixel[j] = cv::saturate_cast(test[j]); + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel + } + } + } + + template + void DarkSmooth(cv::Mat &frame, MatrixCollection *collection, int dark) { + collection->shiftFrames(frame); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Scalar test; + for(int q = 1; q < collection->size(); ++q) { + cv::Mat &framev = collection->frames[q]; + cv::Vec3b pix = framev.at(z, i); + for(int j = 0; j < 3; ++j) { + test[j] += pix[j]; + } + } + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + test[j] /= (collection->size()); + test[j] /= dark; + pixel[j] /= dark; + pixel[j] = pixel[j]^static_cast(test[j]); + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel + } + } + } + // Trails function + template + void StaticXor(cv::Mat &frame, MatrixCollection *collection, cv::Vec3b r) { + collection->shiftFrames(frame); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Scalar test; + for(int q = 0; q < collection->size()-1; ++q) { + cv::Mat &framev = collection->frames[q]; + cv::Vec3b pix = framev.at(z, i); + for(int j = 0; j < 3; ++j) { + test[j] += pix[j]; + } + } + cv::Vec3b &pixel = frame.at(z, i); + for(int j = 0; j < 3; ++j) { + test[j] /= (collection->size()); + pixel[j] = static_cast(test[j])^r[j]; + } + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel + } + } + } + // Trails function + template + void SmoothRGB(cv::Mat &frame, MatrixCollection *collection) { + collection->shiftFrames(frame); + static int index = 0; + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Scalar test; + for(int q = 0; q < collection->size()-1; ++q) { + cv::Mat &framev = collection->frames[q]; + cv::Vec3b pix = framev.at(z, i); + for(int j = 0; j < 3; ++j) { + test[j] += pix[j]; + } + } + cv::Vec3b &pixel = frame.at(z, i); + test[index] /= (collection->size()-1); + pixel[index] = cv::saturate_cast(test[index]); + swapColors(frame, z, i);// swap colors + if(isNegative) invert(frame, z, i);// if isNegative invert pixel + } + } + ++index; + if(index > 2) + index = 0; + } + + template + void ImageDifference(cv::Mat &frame, MatrixCollection *collection, Func func_call, int range = 30) { + collection->shiftFrames(frame); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Scalar values; + for(int q = 0; q < collection->size(); ++q) { + cv::Mat &pix_val = collection->frames[q]; + cv::Vec3b pix = pix_val.at(z, i); + for(int j = 0; j < 3; ++j) { + values[j] += pix[j]; + } + } + cv::Vec3b &pixel = frame.at(z, i); + bool found = false; + for(int j = 0; j < 3; ++j) { + values[j] /= collection->size(); + unsigned char val = static_cast(values[j]); + if(pixel[j] > val+range || pixel[j] < val-range) { + found = true; + break; + } + } + if(found == true) { + func_call(pixel); + } + } + } + } + template + void ImageCopyDifference(cv::Mat &frame,cv::Mat &filtered, MatrixCollection *collection, int range = 5) { + if(frame.size() != filtered.size()) + return; + collection->shiftFrames(frame); + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + cv::Scalar values; + for(int q = 0; q < collection->size(); ++q) { + cv::Mat &pix_val = collection->frames[q]; + cv::Vec3b pix = pix_val.at(z, i); + for(int j = 0; j < 3; ++j) { + values[j] += pix[j]; + } + } + cv::Vec3b &pixel = frame.at(z, i); + cv::Vec3b copypix = filtered.at(z, i); + bool found = false; + for(int j = 0; j < 3; ++j) { + values[j] /= collection->size(); + unsigned char val = static_cast(values[j]); + if(pixel[j] > val+range || pixel[j] < val-range) { + found = true; + break; + } + } + if(found == true) { + pixel = copypix; + } + } + } + } + // point class + class Point { + public: + Point(); + Point(const Point &p); + Point(int xx, int yy); + int x, y; + void setPoint(int xx, int yy); + Point &operator=(const Point &p); + }; + // Rectangle class + class Rect { + public: + Rect(); + Rect(const Rect &r); + Rect(int xx, int yy, int ww, int hh); + Rect(int xx, int yy); + Rect(int xx, int yy, cv::Size s); + Rect(Point pt, int ww, int hh); + Rect(Point pt, cv::Size s); + void setRect(int xx, int yy, int ww, int hh); + Rect &operator=(const Rect &r); + int x,y,w,h; + }; + // classes to be used by the filter + // Square class to hold broken up cv::Mat + class Square { + public: + // constructor init's vars + Square() : pos(0), width(0), height(0), x(0), y(0) {} + // change the size of a square + void setSize(const int &xx, const int &yy, const int &w, const int &h); + // set position + void setPos(const int &p); + // copy image from cv::Mat + void copyImage(const cv::Mat &f); + // copy Image to Target Matrix + void copyImageToTarget(int xx, int yy, cv::Mat &f); + // get position + int getPos() const { return pos; } + // get square width + int getWidth() const { return width; } + // get square height + int getHeight() const { return height; } + protected: + // protected vars + int pos,width,height,x,y; + cv::Mat image; + }; + // Particle movement directions + enum { DIR_UP=0, DIR_UP_LEFT, DIR_UP_RIGHT, DIR_DOWN, DIR_DOWN_LEFT, DIR_DOWN_RIGHT, DIR_LEFT, DIR_RIGHT }; + // contains info for each pixel + class Particle { + public: + Particle() : x(0), y(0), dir(0), m_count(0) {} + cv::Vec3b pixel;// color + int x, y, dir; // position/direction + int m_count; // counter + }; + // class to process the pixel + class ParticleEmiter { + public: + // initalize to null + ParticleEmiter(); + // clean up after done + ~ParticleEmiter(); + // set frame pixel values + void set(cv::Mat &frame); + // draw pixel values to frame + void draw(cv::Mat &frame); + void draw_blend(cv::Mat &frame); + void draw_flash(cv::Mat &frame); + void draw_alpha(cv::Mat &frame); + void draw_move(cv::Mat &frame); + void draw_op(cv::Mat &frame); + + // move pixel coordinates around + void movePixels(); + // reset + void reset(); + private: + Particle **part; // array of pointers for Particles + int w, h; // frame width/height + int speed; + }; + extern int colors[3]; + // class to use for random growing filtered rects. + class Box { + public: + Box() : x(0), y(0), w(0), h(0), steps(0), index(0), frame_index(0) {} + void initBox(int w, int h); + void drawBox(cv::Mat &frame); + void sizeBox(); + int x,y,w,h,steps,index,frame_index; + static int frame_width, frame_height; // current resolution + }; + + class GridBox { + public: + GridBox(); + GridBox(const GridBox &gb); + GridBox(const Rect &r, const cv::Vec3b &col); + GridBox(const cv::Vec3b &col); + Rect location; + cv::Vec3b color; + bool on; + GridBox &operator=(const GridBox &gb); + }; + + class Grid { + public: + GridBox **boxes; + Grid(); + ~Grid(); + void createGrid(cv::Mat &frame, int w, int h, int size); + void updateGrid(int max); + void Release(); + void cleanBoxes(); + void fillGrid(cv::Mat &frame); + int g_w, g_h, g_s; + std::vector points; + std::default_random_engine rng; + int current_offset; + bool g_random; + }; + + class LineObject { + public: + ac::Rect line_size; + cv::Vec3b color; + bool on; + int dir; + }; + + class HLine { + public: + HLine(); + void drawLines(cv::Mat &frame); + void createLines(int size, int width, int height); + void clearLines(); + bool empty() const { return lines.empty(); } + protected: + int w, h; + std::vector lines; + }; + + bool operator<(const Point &p1, const Point &p2); + + // slow copy functions + void copyMat(const cv::Mat &src,int src_x, int src_y, cv::Mat &target, const Rect &rc); + void copyMat(const cv::Mat &src, const Point &p, cv::Mat &target, const Rect &rc); + void copyMat(const cv::Mat &src, int x, int y, cv::Mat &target, int rx, int ry, int rw, int rh); + void fillRect(cv::Mat &m, const Rect &r, cv::Vec3b pixel); + + // Transform Template + template + void Transform(const cv::Mat &source, cv::Mat &output, Func func) { + if(output.empty() || output.size() != source.size()) + output.create(source.size(), CV_8UC3); + + for(int z = 0; z < source.rows; ++z) { + for(int i = 0; i < source.cols; ++i) { + cv::Vec3b &pixel = output.at(z, i); + cv::Vec3b value = source.at(z, i); + func(value, i, z); + pixel = value; + swapColors(output, z, i); + if(isNegative) invert(output, z, i); + } + } + } + + template + void transformMat(cv::Mat &src, const Rect &rc,F func) { + for(int z = rc.y; z < rc.y+rc.h && z < src.rows; ++z) { + for(int i = rc.x; i < rc.x+rc.w && i < src.cols; ++i) { + cv::Vec3b &pixel = src.at(z, i); + func(pixel, i, z); + } + } + } + +} + +extern ac::ParticleEmiter emiter; +void changePixel(cv::Mat &full_buffer, int i, int z, cv::Vec3b &buffer, double pos, double *count); + +#endif diff --git a/windows/Acid.Cam.Qt.Windows.Project/acidcam.ifp b/windows/Acid.Cam.Qt.Windows.Project/acidcam.ifp new file mode 100755 index 0000000..c896eea Binary files /dev/null and b/windows/Acid.Cam.Qt.Windows.Project/acidcam.ifp differ diff --git a/windows/Acid.Cam.Qt.Windows.Project/display_window.cpp b/windows/Acid.Cam.Qt.Windows.Project/display_window.cpp new file mode 100755 index 0000000..cbd4715 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/display_window.cpp @@ -0,0 +1,42 @@ + +/* + * Acid Cam v2 - Qt/OpenCV Edition + * written by Jared Bruni ( http://lostsidedead.com ) + * (C) 2017 GPL + */ + +#include"display_window.h" + +DisplayWindow::DisplayWindow(QWidget *parent) : QDialog(parent) { + createControls(); + setGeometry(950, 200, 640, 480); + setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint); + setWindowTitle(tr("Acid Cam v2 - Display Window")); + hide(); +} +void DisplayWindow::createControls() { + img_label = new QLabel(this); + img_label->setGeometry(0,0,640, 480); +} +void DisplayWindow::displayImage(const QImage &img) { + QRect src(QPoint(0, 0), size()); + QPixmap p = QPixmap::fromImage(img).scaled(size(),Qt::KeepAspectRatio, Qt::FastTransformation); + QRect dst(QPoint(0,0),p.size()); + dst.moveCenter(src.center()); + img_label->setGeometry(dst); + img_label->setPixmap(p); +} + + +void DisplayWindow::paintEvent(QPaintEvent *) { + QPainter painter(this); + painter.fillRect(QRect(QPoint(0, 0), size()), QColor(0,0,0)); +} + +void DisplayWindow::keyPressEvent(QKeyEvent *) { + +} + +void DisplayWindow::keyReleaseEvent(QKeyEvent *) { + +} diff --git a/windows/Acid.Cam.Qt.Windows.Project/display_window.h b/windows/Acid.Cam.Qt.Windows.Project/display_window.h new file mode 100755 index 0000000..1743cdc --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/display_window.h @@ -0,0 +1,26 @@ +/* + * Acid Cam v2 - Qt/OpenCV Edition + * written by Jared Bruni ( http://lostsidedead.com ) + * (C) 2017 GPL +*/ + + +#ifndef __DISPLAY_WINDOW_H__ +#define __DISPLAY_WINDOW_H__ + +#include"qtheaders.h" + +class DisplayWindow : public QDialog { + Q_OBJECT +public: + DisplayWindow(QWidget *parent = 0); + void createControls(); + void displayImage(const QImage &img); + void paintEvent(QPaintEvent *paint); + void keyPressEvent(QKeyEvent *ke); + void keyReleaseEvent(QKeyEvent *ke); +private: + QLabel *img_label; +}; + +#endif diff --git a/windows/Acid.Cam.Qt.Windows.Project/fractal.cpp b/windows/Acid.Cam.Qt.Windows.Project/fractal.cpp new file mode 100755 index 0000000..44e053a --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/fractal.cpp @@ -0,0 +1,157 @@ +/* + * Software written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute it online as long + as you do not charge anything for this program. This program is meant to be + 100% free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + +#include "fractal.h" + +namespace frac { + double paramA = -1.0;//0.519; + double paramB = 0.2; + float zoom_x = 1.5, zoom_y = 1.5, zoom_w = 0.5, zoom_h = 0.5; + double red_color = 6; + double green_color = 25; + double blue_color = 50; + float mod_x = 0.5; + float mod_y = 0.5; + float radius = 180.0f; + int dir = 1; + long max_iter = 40; +} + +void frac::FractalLogic() { + static double alpha_r = 1.0; + alpha_r += 0.05; + red_color += alpha_r; + green_color += alpha_r; + blue_color += alpha_r; + if(alpha_r > 255) alpha_r = 1.0; + if(red_color > 255) red_color = rand()%255; + if(green_color > 255) green_color = rand()%255; + if(blue_color > 255) blue_color = rand()%255; + + switch(dir) { + case 1: { + paramA += 0.005; + if(paramA >= 1.0) { + dir = 2; + paramB += 0.05; + if(paramB >= 1.0) { + dir = 3; + + } + } + } + break; + case 2: { + paramA -= 0.005; + if(paramA <= -1) { + paramB += 0.05; + dir = 1; + if(paramB >= 1.0) { + dir = 4; + } + } + } + break; + case 3: { + paramB -= 0.005; + if(paramB <= -1.0) { + dir = 3; + paramA -= 0.05; + if(paramA <= -1) { + dir = 1; + } + } + + } + break; + case 4: { + paramB += 0.005; + if(paramB >= 1) { + paramA += 0.05; + dir = 3; + if(paramA >= 1) { + dir = 2; + } + + } + } + + break; + } + // std::cout << paramA << ": " << paramB << " :" << " dir: " << dir << "\n"; +} + +void frac::DrawFractal(cv::Mat &frame, bool) +{ + float x1=mod_x-1.0f*zoom_x; + float x2=mod_x+1.0f*zoom_w; + float y1=mod_y-1.0f*zoom_y; + float y2=mod_y+1.0f*zoom_h; + int width=frame.cols, height=frame.rows; + std::complex C (paramA, paramB); + std::complex Z; + int i = 0; + for (int x = 0; x < width; ++x) + { + for (int y = 0; y < height; ++y) + { + //C=std::complex((double)(x*(x2-x1)/width+x1), (double)(y*(y2-y1)/height+y1)); + Z=std::complex((double)(x*(x2-x1)/width+x1), (double)(y*(y2-y1)/height+y1)); + //Z=std::complex(0, 0); + for (i = 0; i < max_iter && std::abs(Z) < 2; i++) + { + Z=Z*Z+C; + } + cv::Vec3b &cf = frame.at(y, x); + if(i == max_iter) { + + } else { + cf[2] += static_cast(sin(i*red_color/100)*255); + cf[1] += static_cast(sin(i*green_color/100)*255); + cf[0] += static_cast(sin(i*blue_color/100)*255); + } + } + if(x > frame.size().width) break; + } +} + diff --git a/windows/Acid.Cam.Qt.Windows.Project/fractal.h b/windows/Acid.Cam.Qt.Windows.Project/fractal.h new file mode 100755 index 0000000..5fe193f --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/fractal.h @@ -0,0 +1,63 @@ +/* + * Acid Cam v2 - OpenCV Edition + * written by Jared Bruni ( http://lostsidedead.com / https://github.com/lostjared ) + + This software is dedicated to all the people that struggle with mental illness. + + GitHub: http://github.com/lostjared + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute as long + as you do not charge anything for this program. This program is 100% + Free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + +#ifndef __FRACTAL__H_ +#define __FRACTAL__H_ +#include +#include +#include + +namespace frac { + extern double paramA,paramB; + extern float radius; + extern float zoom_x, zoom_y, zoom_w, zoom_h; + extern long max_iter; + extern double red_color, green_color, blue_color; + void FractalLogic(); + void DrawFractal(cv::Mat &frame, bool neg=false); +} + +#endif + diff --git a/windows/Acid.Cam.Qt.Windows.Project/goto_window.cpp b/windows/Acid.Cam.Qt.Windows.Project/goto_window.cpp new file mode 100755 index 0000000..d496396 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/goto_window.cpp @@ -0,0 +1,97 @@ +#include "goto_window.h" +#include "main_window.h" + + +GotoWindow::GotoWindow(QWidget *parent) : QDialog(parent) { + createControls(); + setFixedSize(400, 70); + setWindowTitle(tr("Jump to Frame")); + setGeometry(300, 50, 400, 70); +} + +void GotoWindow::setPlayback(Playback *playback) { + playback_thread = playback; +} + +void GotoWindow::setVideoCapture(cv::VideoCapture *cap) { + capture_device = cap; +} +void GotoWindow::setDisplayWindow(DisplayWindow *win) { + disp_window = win; +} + +void GotoWindow::createControls() { + goto_pos = new QSlider(Qt::Horizontal, this); + goto_pos->setGeometry(10, 10, 380, 20); + goto_pos->setMaximum(1); + goto_pos->setMinimum(0); + goto_pos->setTickInterval(0); + + QLabel *lbl_sec = new QLabel(tr("Second: "), this); + QLabel *lbl_frame = new QLabel(tr("Frame: "), this); + lbl_sec->setGeometry(10, 30, 50, 20); + lbl_frame->setGeometry(180, 30, 50, 20); + goto_sec = new QLineEdit("0", this); + goto_sec->setGeometry(70,30,100, 20); + goto_frame = new QLineEdit("0", this); + goto_frame->setGeometry(230,30,100,20); + goto_jump = new QPushButton("Go", this); + goto_jump->setGeometry(340, 30, 45, 20); + + connect(goto_jump, SIGNAL(clicked()), this, SLOT(pressedGo())); + connect(goto_pos, SIGNAL(valueChanged(int)), this, SLOT(slideChanged(int))); + +} + +void GotoWindow::setFrameIndex(int i) { + if(i < goto_pos->minimum() || i > goto_pos->maximum()) { + QMessageBox::information(this, tr("Error"), tr("Index out of range")); + return; + } + frame_index = i; + QString frame_string; + QTextStream frame_stream(&frame_string); + frame_stream << "(Current/Total Frames/Seconds) - (" << frame_index << "/" << goto_pos->maximum() << "/" << (unsigned long)(goto_pos->minimum()/goto_pos->maximum()) << ") "; + main_window->setFrameIndex(frame_index); + main_window->statusBar()->showMessage(frame_string); +} + +void GotoWindow::setMainWindow(AC_MainWindow *window) { + main_window = window; +} + +void GotoWindow::showImage() { + QImage img; + if(playback_thread->getFrame(img, frame_index)) { + disp_window->displayImage(img); + } +} + +void GotoWindow::showWindow(int frame_index, int min, int max) { + goto_pos->setMaximum(min); + goto_pos->setMaximum(max); + goto_pos->setSliderPosition(frame_index); + slideChanged(frame_index); + show(); +} + +void GotoWindow::pressedGo() { + QString fpos = goto_frame->text(); + int f_pos = atoi(fpos.toStdString().c_str()); + if(f_pos != goto_pos->sliderPosition()) { + goto_pos->setSliderPosition(f_pos); + } + setFrameIndex(f_pos); + showImage(); +} + +void GotoWindow::slideChanged(int pos) { + QString text; + QTextStream stream(&text); + stream << static_cast(pos/ac::fps); + goto_sec->setText(text); + text = ""; + stream << (pos); + goto_frame->setText(text); + +} diff --git a/windows/Acid.Cam.Qt.Windows.Project/goto_window.h b/windows/Acid.Cam.Qt.Windows.Project/goto_window.h new file mode 100755 index 0000000..21e36c8 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/goto_window.h @@ -0,0 +1,38 @@ +#ifndef __GOTO_WINDOW__H_ +#define __GOTO_WINDOW__H_ + +#include "qtheaders.h" +#include "display_window.h" +#include "playback_thread.h" + +class AC_MainWindow; + +class GotoWindow : public QDialog { + Q_OBJECT +public: + GotoWindow(QWidget *parent); + void setVideoCapture(cv::VideoCapture *cap); + void setDisplayWindow(DisplayWindow *win); + void setMainWindow(AC_MainWindow *window); + void setPlayback(Playback *playb); + void createControls(); + void setFrameIndex(int index); + void showImage(); + void showWindow(int frame_index, int min, int max); +private: + int frame_index; + DisplayWindow *disp_window; + AC_MainWindow *main_window; + cv::VideoCapture *capture_device; + QSlider *goto_pos; + QLineEdit *goto_sec, *goto_frame; + QPushButton *goto_jump; + Playback *playback_thread; +public slots: + void pressedGo(); + void slideChanged(int pos); + +}; + +#endif + diff --git a/windows/Acid.Cam.Qt.Windows.Project/images/Video.-2018.5.9_18.22.59_AC2.Output.1.mov b/windows/Acid.Cam.Qt.Windows.Project/images/Video.-2018.5.9_18.22.59_AC2.Output.1.mov new file mode 100755 index 0000000..60b54f9 Binary files /dev/null and b/windows/Acid.Cam.Qt.Windows.Project/images/Video.-2018.5.9_18.22.59_AC2.Output.1.mov differ diff --git a/windows/Acid.Cam.Qt.Windows.Project/images/Video.-2018.5.9_18.23.11_AC2.Output.2.mov b/windows/Acid.Cam.Qt.Windows.Project/images/Video.-2018.5.9_18.23.11_AC2.Output.2.mov new file mode 100755 index 0000000..be0512c Binary files /dev/null and b/windows/Acid.Cam.Qt.Windows.Project/images/Video.-2018.5.9_18.23.11_AC2.Output.2.mov differ diff --git a/windows/Acid.Cam.Build.zip b/windows/Acid.Cam.Qt.Windows.Project/images/icon.png old mode 100644 new mode 100755 similarity index 83% rename from windows/Acid.Cam.Build.zip rename to windows/Acid.Cam.Qt.Windows.Project/images/icon.png index 1c7253f..c0d61ac Binary files a/windows/Acid.Cam.Build.zip and b/windows/Acid.Cam.Qt.Windows.Project/images/icon.png differ diff --git a/windows/Acid.Cam.Qt.Windows.Project/main.cpp b/windows/Acid.Cam.Qt.Windows.Project/main.cpp new file mode 100755 index 0000000..1b9aaca --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/main.cpp @@ -0,0 +1,29 @@ +/* + * Acid Cam v2 - Qt/OpenCV Edition + * written by Jared Bruni ( http://lostsidedead.com ) + * (C) 2017 GPL + */ + + +//#define LINUX_RELEASE + +#include"qtheaders.h" +#include "main_window.h" +#ifdef LINUX_RELEASE +#include +#endif + +int main(int argc, char **argv) { + +#ifdef LINUX_RELEASE + if(chdir("/usr/share/acidcam") == 0) { + std::cout << "Changed directory to: /usr/share/acidcam\n"; + } +#endif + + QApplication app(argc, argv); + AC_MainWindow window; + window.show(); + return app.exec(); + +} diff --git a/windows/Acid.Cam.Qt.Windows.Project/main_window.cpp b/windows/Acid.Cam.Qt.Windows.Project/main_window.cpp new file mode 100755 index 0000000..f31214b --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/main_window.cpp @@ -0,0 +1,1227 @@ +/* + * Acid Cam v2 - Qt/OpenCV Edition + * written by Jared Bruni ( http://lostsidedead.com ) + * (C) 2017 GPL + */ + + +#include "main_window.h" +#include +#include"plugin.h" +#include + +std::unordered_map filter_map; +void custom_filter(cv::Mat &); + +const char *filter_names[] = { "AC Self AlphaBlend", "Reverse Self AlphaBlend", + "Opposite Self AlphaBlend", "AC2 Distort", "Reverse Distort", "Opposite Distort", + "Full Distort", "A New One", "AC NewOne", "AC Thought Filter", "Line Draw", + "Gradient Square", "Color Wave", "Pixelated Gradient", "Combined Gradient", + "Diagonal", "Average", "Average Divide", "Cos/Sin Multiply", "Modulus Multiply", + "Positive/Negative", "z+1 Blend", "Diamond Pattern", "Pixelated Shift","Pixelated Mix", + "Color Accumulate", "Color Accumulate #2", "Color Accumulate #3", "Angle", + "Vertical Average", "Circular Blend", "Average Blend", "~Divide", "Mix", "Random Number", + "Gradient Repeat", 0 }; + +void generate_map() { + for(int i = 0; i < ac::draw_max; ++i ) + filter_map[ac::draw_strings[i]] = FilterValue(0, i, -1); + + int index = 0; + while(filter_names[index] != 0) { + std::string filter_n = "AF_"; + filter_n += filter_names[index]; + filter_map[filter_n] = FilterValue(1, index, -1); + ++index; + } + for(unsigned int j = 0; j < plugins.plugin_list.size(); ++j) { + std::string name = "plugin " + plugins.plugin_list[j]->name(); + filter_map[name] = FilterValue(2, j, -1); + } +} + +void custom_filter(cv::Mat &) { + +} + + +AC_MainWindow::~AC_MainWindow() { + controls_Stop(); + delete playback; +} + +AC_MainWindow::AC_MainWindow(QWidget *parent) : QMainWindow(parent) { + programMode = MODE_CAMERA; + init_plugins(); + generate_map(); + setGeometry(100, 100, 800, 700); + setFixedSize(800, 700); + setWindowTitle(tr("Acid Cam v2 - Qt")); + createControls(); + createMenu(); + + cap_camera = new CaptureCamera(this); + cap_camera->setParent(this); + + cap_video = new CaptureVideo(this); + cap_video->setParent(this); + + search_box = new SearchWindow(this); + search_box->setParent(this); + search_box->setFiltersControl(filters, custom_filters); + search_box->main_window = this; + statusBar()->showMessage(tr("Acid Cam v2 Loaded - Use File Menu to Start")); + take_snapshot = false; + goto_window = new GotoWindow(this); + disp = new DisplayWindow(this); + playback = new Playback(); + + goto_window->setParent(this); + goto_window->setDisplayWindow(disp); + goto_window->setPlayback(playback); + goto_window->setMainWindow(this); + + QObject::connect(playback, SIGNAL(procImage(QImage)), this, SLOT(updateFrame(QImage))); + QObject::connect(playback, SIGNAL(stopRecording()), this, SLOT(stopRecording())); + QObject::connect(playback, SIGNAL(frameIncrement()), this, SLOT(frameInc())); + QObject::connect(playback, SIGNAL(resetIndex()), this, SLOT(resetIndex())); + + for(unsigned int i = 0; i < plugins.plugin_list.size(); ++i) { + QString text; + QTextStream stream(&text); + stream << "Loaded Plugin: " << plugins.plugin_list[i]->name().c_str() << "\n"; + Log(text); + } + + int cindex = filters->findText("Self AlphaBlend"); + filters->setCurrentIndex(cindex); +} + +void AC_MainWindow::createControls() { + /* + filters = new QListWidget(this); + filters->setGeometry(10, 30, 390, 180); + filters->show(); + */ + custom_filters = new QListWidget(this); + custom_filters->setGeometry(400, 30, 390, 180); + custom_filters->show(); + + filters = new QComboBox(this); + filters->setGeometry(10, 105, 380, 30); + + std::vector fnames; + for(int i = 0; i < ac::draw_max-5; ++i) { + fnames.push_back(ac::draw_strings[i].c_str()); + } + + std::sort(fnames.begin(), fnames.end()); + + for(unsigned long i = 0; i < fnames.size(); ++i) { + filters->addItem(fnames[i].c_str()); + } + + for(int i = 0; filter_names[i] != 0; ++i) { + std::string filter_n = "AF_"; + filter_n += filter_names[i]; + filters->addItem(filter_n.c_str()); + } + + for(unsigned int i = 0; i < plugins.plugin_list.size(); ++i) { + std::string name = "plugin " + plugins.plugin_list[i]->name(); + filters->addItem(name.c_str()); + } + + connect(filters, SIGNAL(currentIndexChanged(int)), this, SLOT(comboFilterChanged(int))); + + filter_single = new QRadioButton(tr("Single Filter"), this); + filter_single->setGeometry(30, 40, 100, 15); + filter_custom = new QRadioButton(tr("Custom Filter"), this); + filter_custom->setGeometry(30, 65, 100, 15); + + filter_single->setChecked(true); + + connect(filter_single, SIGNAL(pressed()), this, SLOT(setFilterSingle())); + connect(filter_custom, SIGNAL(pressed()), this, SLOT(setFilterCustom())); + + btn_add = new QPushButton(tr("Add"), this); + btn_remove = new QPushButton(tr("Remove"), this); + btn_moveup = new QPushButton(tr("Move Up"), this); + btn_movedown = new QPushButton(tr("Move Down"), this); + btn_sub = new QPushButton(tr("Subfilter"), this); + btn_clr = new QPushButton(tr("Clear Sub"), this); + btn_add->setGeometry(10, 215, 100, 20); + btn_remove->setGeometry(400, 215, 100, 20); + btn_moveup->setGeometry(500, 215, 100, 20); + btn_movedown->setGeometry(600, 215, 100, 20); + btn_sub->setGeometry(10, 145, 100, 20); + btn_clr->setGeometry(115, 145, 100, 20); + + connect(btn_add, SIGNAL(clicked()), this, SLOT(addClicked())); + connect(btn_remove, SIGNAL(clicked()), this, SLOT(rmvClicked())); + connect(btn_moveup, SIGNAL(clicked()), this, SLOT(upClicked())); + connect(btn_movedown, SIGNAL(clicked()), this, SLOT(downClicked())); + connect(btn_sub, SIGNAL(clicked()), this, SLOT(setSub())); + connect(btn_clr, SIGNAL(clicked()), this, SLOT(clear_subfilter())); + + QLabel *r_label = new QLabel(tr("Red: "), this); + r_label->setGeometry(10, 255, 50, 20); + slide_r = new QSlider(Qt::Horizontal,this); + slide_r->setGeometry(40, 250, 100, 30); + slide_r->setMaximum(255); + slide_r->setMinimum(0); + slide_r->setTickInterval(0); + + QLabel *g_label = new QLabel(tr("Green: "), this); + g_label->setGeometry(150, 255, 50, 20); + slide_g = new QSlider(Qt::Horizontal, this); + slide_g->setGeometry(190, 250, 100, 30); + slide_g->setMaximum(255); + slide_g->setMinimum(0); + slide_g->setTickInterval(0); + + QLabel *b_label = new QLabel(tr("Blue: "), this); + b_label->setGeometry(300, 255, 50, 20); + slide_b = new QSlider(Qt::Horizontal, this); + slide_b->setGeometry(330, 250, 100, 30); + slide_b->setMaximum(255); + slide_b->setMinimum(0); + slide_b->setTickInterval(0); + + connect(slide_r, SIGNAL(valueChanged(int)), this, SLOT(slideChanged(int))); + connect(slide_g, SIGNAL(valueChanged(int)), this, SLOT(slideChanged(int))); + connect(slide_b, SIGNAL(valueChanged(int)), this, SLOT(slideChanged(int))); + + QLabel *label_slide_bright = new QLabel(tr("Brightness: "), this); + label_slide_bright->setGeometry(10, 280, 75, 20); + slide_bright = new QSlider(Qt::Horizontal, this); + slide_bright->setGeometry(80, 275, 100, 30); + slide_bright->setMaximum(255); + slide_bright->setMinimum(0); + slide_bright->setTickInterval(0); + + + QLabel *label_slide_gamma = new QLabel(tr("Gamma: "), this); + label_slide_gamma->setGeometry(190, 280, 65, 20); + slide_gamma = new QSlider(Qt::Horizontal, this); + slide_gamma->setGeometry(245, 275, 100, 30); + slide_gamma->setMaximum(255); + slide_gamma->setMinimum(0); + slide_gamma->setTickInterval(0); + + QLabel *label_sat = new QLabel(tr("Saturation: "), this); + label_sat->setGeometry(350, 280, 100, 20); + slide_saturation = new QSlider(Qt::Horizontal, this); + slide_saturation->setGeometry(420, 275, 100, 30); + slide_saturation->setMaximum(255); + slide_saturation->setMinimum(0); + slide_saturation->setTickInterval(0); + + connect(slide_bright, SIGNAL(valueChanged(int)), this, SLOT(colorChanged(int))); + connect(slide_gamma, SIGNAL(valueChanged(int)), this, SLOT(colorChanged(int))); + connect(slide_saturation, SIGNAL(valueChanged(int)), this, SLOT(colorChanged(int))); + + QLabel *color_maps_label = new QLabel("Color Maps", this); + color_maps_label->setGeometry(545, 260, 75, 20); + + color_maps = new QComboBox(this); + color_maps->setGeometry(540, 275, 250, 30); + color_maps->addItem(tr("None")); + color_maps->addItem(tr("Autum")); + color_maps->addItem(tr("Bone")); + color_maps->addItem(tr("Jet")); + color_maps->addItem(tr("Winter")); + color_maps->addItem(tr("Rainbow")); + color_maps->addItem(tr("Ocean")); + color_maps->addItem(tr("Summer")); + color_maps->addItem(tr("Cool")); + color_maps->addItem(tr("HSV")); + color_maps->addItem(tr("Pink")); + color_maps->addItem(tr("Hot")); + color_maps->addItem(tr("Parula")); + + connect(color_maps, SIGNAL(currentIndexChanged(int)), this, SLOT(colorMapChanged(int))); + + log_text = new QTextEdit(this); + log_text->setGeometry(10, 325, 780,310); + log_text->setReadOnly(true); + + QString text; + QTextStream stream(&text); + stream << tr("Acid Cam Filters v"); + stream << ac::version.c_str(); + stream << " loaded " << filters->count() << " filters.\n"; + log_text->setText(text); + chk_negate = new QCheckBox(tr("Negate"), this); + chk_negate->setGeometry(120,215,100, 20); + chk_negate->setCheckState(Qt::Unchecked); + + connect(chk_negate, SIGNAL(clicked()), this, SLOT(chk_Clicked())); + + combo_rgb = new QComboBox(this); + combo_rgb->setGeometry(200,215, 190, 25); + combo_rgb->addItem(tr("RGB")); + combo_rgb->addItem(tr("BGR")); + combo_rgb->addItem(tr("BRG")); + combo_rgb->addItem(tr("GRB")); + + setWindowIcon(QPixmap(":/images/icon.png")); + + progress_bar = new QProgressBar(this); + progress_bar->setGeometry(0, 640, 800, 20); + progress_bar->setMinimum(0); + progress_bar->setMaximum(100); + progress_bar->hide(); +} + +void AC_MainWindow::createMenu() { + + file_menu = menuBar()->addMenu(tr("&File")); + controls_menu = menuBar()->addMenu(tr("&Controls")); + options = menuBar()->addMenu(tr("&Options")); + help_menu = menuBar()->addMenu(tr("Help")); + + file_new_capture = new QAction(tr("Capture from Webcam"),this); + file_new_capture->setShortcut(tr("Ctrl+N")); + file_menu->addAction(file_new_capture); + + file_new_video = new QAction(tr("Capture from Video"), this); + file_new_video->setShortcut(tr("Ctrl+V")); + file_menu->addAction(file_new_video); + + file_exit = new QAction(tr("E&xit"), this); + file_exit->setShortcut(tr("Ctrl+X")); + file_menu->addAction(file_exit); + + movement = options->addMenu(tr("Movement")); + in_out_increase = new QAction(tr("Move In, Move Out, Increase"), this); + in_out_increase->setCheckable(true); + in_out_increase->setChecked(true); + movement->addAction(in_out_increase); + + in_out = new QAction(tr("Move in, Move Out"), this); + in_out->setCheckable(true); + movement->addAction(in_out); + + out_reset = new QAction(tr("Move Out, Reset"), this); + out_reset->setCheckable(true); + movement->addAction(out_reset); + speed_actions[0] = 0.001; + speed_actions[1] = 0.05; + speed_actions[2] = 0.01; + speed_actions[3] = 0.1; + speed_actions[4] = 0.5; + speed_actions[5] = 1.0; + speed_actions[6] = 3.0; + const QString act_val[] = { "0.001 (Very Slow)", "0.05 (Slow)", "0.01 (Normal)", "0.1 (Regular)", "0.5 (Fast)", "1.0 (Faster)", "3.0 (Very Fast)"}; + speed_menu = options->addMenu("Movement Speed"); + for(int i = 0; i < 7; ++i) { + speed_action_items[i] = new QAction(act_val[i], this); + speed_action_items[i]->setCheckable(true); + speed_menu->addAction(speed_action_items[i]); + } + image_menu = options->addMenu(tr("Image")); + noflip = new QAction(tr("Normal"), this); + noflip->setCheckable(true); + noflip->setChecked(true); + image_menu->addAction(noflip); + flip1 = new QAction(tr("Flip Vertical"), this); + flip1->setCheckable(true); + flip1->setChecked(false); + image_menu->addAction(flip1); + flip2 = new QAction(tr("Flip Horizontal"), this); + flip2->setCheckable(true); + flip2->setChecked(false); + image_menu->addAction(flip2); + flip3 = new QAction(tr("Flip Vertical and Horizontal"), this); + flip3->setCheckable(true); + flip3->setChecked(false); + image_menu->addAction(flip3); + options->addSeparator(); + clear_sub = new QAction(tr("Clear SubFilter"), this); + options->addAction(clear_sub); + clear_sub->setShortcut(tr("Ctrl+F")); + clear_image = new QAction(tr("Clear Image"), this); + options->addAction(clear_image); + options->addSeparator(); + repeat_v = new QAction(tr("Repeat"), this); + repeat_v->setCheckable(true); + repeat_v->setChecked(false); + + fade_on = new QAction(tr("Fade"), this); + fade_on->setCheckable(true); + fade_on->setChecked(true); + options->addAction(fade_on); + options->addAction(repeat_v); + + connect(fade_on, SIGNAL(triggered()), this, SLOT(setFade())); + connect(repeat_v, SIGNAL(triggered()), this, SLOT(repeat_vid())); + connect(clear_image, SIGNAL(triggered()), this, SLOT(clear_img())); + connect(clear_sub, SIGNAL(triggered()), this, SLOT(clear_subfilter())); + connect(flip1, SIGNAL(triggered()), this, SLOT(flip1_action())); + connect(flip2, SIGNAL(triggered()), this, SLOT(flip2_action())); + connect(flip3, SIGNAL(triggered()), this, SLOT(flip3_action())); + connect(noflip, SIGNAL(triggered()), this, SLOT(noflip_action())); + connect(speed_action_items[0], SIGNAL(triggered()), this, SLOT(speed1())); + connect(speed_action_items[1], SIGNAL(triggered()), this, SLOT(speed2())); + connect(speed_action_items[2], SIGNAL(triggered()), this, SLOT(speed3())); + connect(speed_action_items[3], SIGNAL(triggered()), this, SLOT(speed4())); + connect(speed_action_items[4], SIGNAL(triggered()), this, SLOT(speed5())); + connect(speed_action_items[5], SIGNAL(triggered()), this, SLOT(speed6())); + connect(speed_action_items[6], SIGNAL(triggered()), this, SLOT(speed7())); + speed2(); + connect(file_new_capture, SIGNAL(triggered()), this, SLOT(file_NewCamera())); + connect(file_new_video, SIGNAL(triggered()), this, SLOT(file_NewVideo())); + connect(file_exit, SIGNAL(triggered()), this, SLOT(file_Exit())); + connect(in_out_increase, SIGNAL(triggered()), this, SLOT(movementOption1())); + connect(in_out, SIGNAL(triggered()), this, SLOT(movementOption2())); + connect(out_reset, SIGNAL(triggered()), this, SLOT(movementOption3())); + controls_stop = new QAction(tr("Sto&p"), this); + controls_stop->setShortcut(tr("Ctrl+C")); + controls_menu->addAction(controls_stop); + controls_stop->setEnabled(false); + controls_snapshot = new QAction(tr("Take &Snapshot"), this); + controls_snapshot->setShortcut(tr("Ctrl+A")); + controls_menu->addAction(controls_snapshot); + controls_pause = new QAction(tr("&Pause"), this); + controls_pause->setShortcut(tr("Ctrl+P")); + controls_menu->addAction(controls_pause); + controls_step = new QAction(tr("Step"), this); + controls_step->setShortcut(tr("Ctrl+I")); + controls_menu->addAction(controls_step); + controls_setimage = new QAction(tr("Set Image"), this); + //controls_setimage->setShortcut(tr("Ctrl+Q")); + controls_menu->addAction(controls_setimage); + controls_setkey = new QAction(tr("Set Color Key Image"), this); + //controls_setkey->setShortcut(tr("Ctrl+K")); + controls_menu->addAction(controls_setkey); + controls_showvideo = new QAction(tr("Hide Display Video"), this); + controls_showvideo->setShortcut(tr("Ctrl+V")); + controls_menu->addAction(controls_showvideo); + reset_filters = new QAction(tr("Reset Filters"), this); + reset_filters->setShortcut(tr("Ctrl+R")); + controls_menu->addAction(reset_filters); + controls_showvideo->setEnabled(false); + controls_showvideo->setCheckable(true); + open_search = new QAction(tr("Search Filters"), this); + open_search->setShortcut(tr("Ctrl+S")); + controls_menu->addAction(open_search); + connect(open_search,SIGNAL(triggered()), this, SLOT(openSearch())); + connect(controls_snapshot, SIGNAL(triggered()), this, SLOT(controls_Snap())); + connect(controls_pause, SIGNAL(triggered()), this, SLOT(controls_Pause())); + connect(controls_step, SIGNAL(triggered()), this, SLOT(controls_Step())); + connect(controls_stop, SIGNAL(triggered()), this, SLOT(controls_Stop())); + connect(controls_setimage, SIGNAL(triggered()), this, SLOT(controls_SetImage())); + connect(controls_setkey, SIGNAL(triggered()), this, SLOT(controls_SetKey())); + connect(controls_showvideo, SIGNAL(triggered()), this, SLOT(controls_ShowVideo())); + connect(reset_filters, SIGNAL(triggered()), this, SLOT(controls_Reset())); + connect(combo_rgb, SIGNAL(currentIndexChanged(int)), this, SLOT(cb_SetIndex(int))); + controls_pause->setText(tr("Pause")); + help_about = new QAction(tr("About"), this); + help_about->setShortcut(tr("Ctrl+A")); + help_menu->addAction(help_about); + connect(help_about, SIGNAL(triggered()), this, SLOT(help_About())); + controls_stop->setEnabled(false); + controls_pause->setEnabled(false); + controls_step->setEnabled(false); + controls_snapshot->setEnabled(false); +} + +void AC_MainWindow::resetIndex() { + frame_index = 0; +} + +void AC_MainWindow::clear_subfilter() { + int crow = custom_filters->currentRow(); + if(crow >= 0) { + QListWidgetItem *item = custom_filters->item(crow); + std::string text = item->text().toStdString(); + if(text.find(":") == std::string::npos) + return; + std::string val = text.substr(0, text.find(":")); + item->setText(val.c_str()); + std::vector v; + buildVector(v); + Log(tr("Cleared SubFilter")); + } + ac::setSubFilter(-1); +} + +void AC_MainWindow::clear_img() { + blend_set = false; + blend_image.release(); + Log(tr("Cleared Image\n")); +} + +void AC_MainWindow::flip1_action() { + flip1->setChecked(true); + flip2->setChecked(false); + flip3->setChecked(false); + noflip->setChecked(false); + playback->SetFlip(false, true); + Log(tr("Flipped Image\n")); +} + +void AC_MainWindow::flip2_action() { + flip1->setChecked(false); + flip2->setChecked(true); + flip3->setChecked(false); + noflip->setChecked(false); + playback->SetFlip(true, false); + Log(tr("Flipped Image\n")); +} + +void AC_MainWindow::flip3_action() { + flip1->setChecked(false); + flip2->setChecked(false); + flip3->setChecked(true); + noflip->setChecked(false); + playback->SetFlip(true, true); + Log(tr("Flipped Image\n")); +} + +void AC_MainWindow::noflip_action() { + flip1->setChecked(false); + flip2->setChecked(false); + flip3->setChecked(false); + noflip->setChecked(true); + playback->SetFlip(false, false); + Log(tr("Removed Flip Action\n")); + +} + +void AC_MainWindow::repeat_vid() { + bool val = repeat_v->isChecked(); + playback->enableRepeat(val); + if(val == true) { + Log(tr("Repeat Enabled\n")); + } else { + Log(tr("Repeat Disabled\n")); + } +} + +void AC_MainWindow::speed1() { + ac::alpha_increase = speed_actions[0]; + QString text; + QTextStream stream(&text); + stream << "Movements Speed Set to: " << ac::alpha_increase << "\n"; + Log(text); + for(int i = 0; i < 7; ++i) { + speed_action_items[i]->setChecked(false); + } + speed_action_items[0]->setChecked(true); + +} +void AC_MainWindow::speed2() { + QString text; + QTextStream stream(&text); + ac::alpha_increase = speed_actions[1]; + stream << "Movements Speed Set to: " << ac::alpha_increase << "\n"; + Log(text); + for(int i = 0; i < 7; ++i) { + speed_action_items[i]->setChecked(false); + } + speed_action_items[1]->setChecked(true); + +} +void AC_MainWindow::speed3() { + ac::alpha_increase = speed_actions[2]; + QString text; + QTextStream stream(&text); + stream << "Movements Speed Set to: " << ac::alpha_increase << "\n"; + Log(text); + for(int i = 0; i < 7; ++i) { + speed_action_items[i]->setChecked(false); + } + speed_action_items[2]->setChecked(true); + +} +void AC_MainWindow::speed4() { + ac::alpha_increase = speed_actions[3]; + QString text; + QTextStream stream(&text); + stream << "Movements Speed Set to: " << ac::alpha_increase << "\n"; + Log(text); + for(int i = 0; i < 7; ++i) { + speed_action_items[i]->setChecked(false); + } + speed_action_items[3]->setChecked(true); +} +void AC_MainWindow::speed5() { + ac::alpha_increase = speed_actions[4]; + QString text; + QTextStream stream(&text); + stream << "Movements Speed Set to: " << ac::alpha_increase << "\n"; + Log(text); + for(int i = 0; i < 7; ++i) { + speed_action_items[i]->setChecked(false); + } + speed_action_items[4]->setChecked(true); +} +void AC_MainWindow::speed6() { + ac::alpha_increase = speed_actions[5]; + QString text; + QTextStream stream(&text); + stream << "Movements Speed Set to: " << ac::alpha_increase << "\n"; + Log(text); + for(int i = 0; i < 7; ++i) { + speed_action_items[i]->setChecked(false); + } + speed_action_items[5]->setChecked(true); +} + +void AC_MainWindow::speed7() { + QString text; + QTextStream stream(&text); + ac::alpha_increase = speed_actions[6]; + stream << "Movements Speed Set to: " << ac::alpha_increase << "\n"; + Log(text); + for(int i = 0; i < 7; ++i) { + speed_action_items[i]->setChecked(false); + } + speed_action_items[6]->setChecked(true); +} + +void AC_MainWindow::movementOption1() { + ac::setProcMode(0); + in_out_increase->setChecked(true); + in_out->setChecked(false); + out_reset->setChecked(false); + Log(tr("Proc Mode set to: 0\n")); +} +void AC_MainWindow::movementOption2() { + in_out_increase->setChecked(false); + in_out->setChecked(true); + out_reset->setChecked(false); + ac::setProcMode(1); + Log(tr("Proc Mode set to: 1\n")); +} + +void AC_MainWindow::movementOption3() { + in_out_increase->setChecked(false); + in_out->setChecked(false); + out_reset->setChecked(true); + ac::setProcMode(2); + Log(tr("Proc Mode set to: 2\n")); +} + +void AC_MainWindow::chk_Clicked() { + playback->setOptions(chk_negate->isChecked(), combo_rgb->currentIndex()); +} +void AC_MainWindow::cb_SetIndex(int index) { + playback->setOptions(chk_negate->isChecked(), index); +} + +void AC_MainWindow::slideChanged(int) { + playback->setRGB(slide_r->sliderPosition(), slide_g->sliderPosition(), slide_b->sliderPosition()); +} + +void AC_MainWindow::colorChanged(int) { + playback->setColorOptions(slide_bright->sliderPosition(), slide_gamma->sliderPosition(), slide_saturation->sliderPosition()); +} + +void AC_MainWindow::colorMapChanged(int pos) { + playback->setColorMap(pos); + Log("Changed Color Map\n"); +} + +void AC_MainWindow::comboFilterChanged(int) { + playback->setIndexChanged(filters->currentText().toStdString()); + QString str; + QTextStream stream(&str); + stream << "Filter changed to: " << filters->currentText() << "\n"; + Log(str); + std::string text = filters->currentText().toStdString(); + if(blend_set == false && text.find("Image") != std::string::npos) + Log(tr("Set an Image to use this filter\n")); + else if(ac::subfilter == -1 && text.find("SubFilter") != std::string::npos) + Log(tr("Set a SubFilter to use this filter\n")); + +} + +void AC_MainWindow::setFilterSingle() { + playback->setSingleMode(true); + Log("Set to Single Filter Mode\n"); +} +void AC_MainWindow::setFilterCustom() { + playback->setSingleMode(false); + Log("Set to Custom Filter Mode\n"); +} + +void AC_MainWindow::addClicked() { + int row = filters->currentIndex(); + if(row != -1) { + //QListWidgetItem *item = filters->item(row); + + std::string sub_str = filters->currentText().toStdString(); + custom_filters->addItem(filters->currentText()); + //custom_filters->addItem(sub_str.c_str()); + QString qs; + QTextStream stream(&qs); + stream << "Added Filter: " << filters->currentText() << "\n"; + Log(qs); + std::vector v; + buildVector(v); + playback->setVector(v); + } +} +void AC_MainWindow::updateList() { + std::vector v; + buildVector(v); + playback->setVector(v); +} + +void AC_MainWindow::rmvClicked() { + int item = custom_filters->currentRow(); + if(item != -1) { + QListWidgetItem *i = custom_filters->takeItem(item); + QString qs; + QTextStream stream(&qs); + stream << "Removed Filter: " << i->text() << "\n"; + Log(qs); + std::vector v; + buildVector(v); + playback->setVector(v); + } +} + +void AC_MainWindow::upClicked() { + int item = custom_filters->currentRow(); + if(item > 0) { + QListWidgetItem *i = custom_filters->takeItem(item); + custom_filters->insertItem(item-1, i->text()); + custom_filters->setCurrentRow(item-1); + std::vector v; + buildVector(v); + playback->setVector(v); + } +} + +void AC_MainWindow::downClicked() { + int item = custom_filters->currentRow(); + if(item >= 0 && item < custom_filters->count()-1) { + QListWidgetItem *i = custom_filters->takeItem(item); + custom_filters->insertItem(item+1, i->text()); + custom_filters->setCurrentRow(item+1); + std::vector v; + buildVector(v); + playback->setVector(v); + } +} + +void AC_MainWindow::setSub() { + int row = filters->currentIndex(); + int crow = custom_filters->currentRow(); + if(row != -1 && crow != -1) { + std::ostringstream stream; + QListWidgetItem *item = custom_filters->item(crow); + QString filter_num = filters->currentText(); + int value_index = filter_map[filter_num.toStdString()].index; + int filter_index = filter_map[filter_num.toStdString()].filter; + if(value_index == 0) { + std::string fname = filters->currentText().toStdString(); + std::string filter_val = item->text().toStdString(); + if(filter_val.find(":") != std::string::npos) + filter_val = filter_val.substr(0, filter_val.find(":")); + + if(!(fname.find("SubFilter") == std::string::npos && filter_val.find("SubFilter") != std::string::npos)) { + stream << filter_val << " does not support a subfilter.\n"; + Log(stream.str().c_str()); + return; + } + stream << "SubFilter set to: " << filter_num.toStdString() << "\n"; + stream << "SubFilter index: " << filter_index << "\n"; + std::ostringstream stream1; + stream1 << filter_val << ":" << fname; + item->setText(stream1.str().c_str()); + std::vector v; + buildVector(v); + playback->setVector(v); + QString l = stream.str().c_str(); + Log(l); + } + } +} +void AC_MainWindow::Log(const QString &s) { + QString text; + text = log_text->toPlainText(); + text += s; + log_text->setText(text); + QTextCursor tmpCursor = log_text->textCursor(); + tmpCursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor); + log_text->setTextCursor(tmpCursor); +} + +bool AC_MainWindow::startCamera(int res, int dev, const QString &outdir, bool record, int type) { + programMode = MODE_CAMERA; + progress_bar->hide(); + controls_showvideo->setEnabled(false); + playback->setDisplayed(true); + controls_stop->setEnabled(true); + controls_pause->setEnabled(true); + controls_step->setEnabled(false); + controls_snapshot->setEnabled(true); + // setup device + step_frame = false; + video_file_name = ""; + frame_index = 0; + /* + capture_camera.open(dev); + if(!capture_camera.isOpened()) { + return false; + }*/ + video_frames = 0; + video_fps = 24; /* + int ores_w = capture_camera.get(CV_CAP_PROP_FRAME_WIDTH); + int ores_h = capture_camera.get(CV_CAP_PROP_FRAME_HEIGHT); + */ + int res_w = 0; + int res_h = 0; + /*QString str; + QTextStream stream(&str); + stream << "Opened capture device " << res_w << "x" << res_h << "\n"; + stream << "FPS: " << video_fps << "\n";*/ + output_directory = outdir; + frame_index = 0; + //Log(str); + paused = false; + recording = record; + QString output_name; + QTextStream stream_(&output_name); + static unsigned int index = 0; + time_t t = time(0); + struct tm *m; + m = localtime(&t); + QString ext; + ext = (type == 0) ? ".mov" : ".avi"; + Log(tr("Capture Device Opened [Camera]\n")); + std::ostringstream time_stream; + time_stream << "-" << (m->tm_year + 1900) << "." << (m->tm_mon + 1) << "." << m->tm_mday << "_" << m->tm_hour << "." << m->tm_min << "." << m->tm_sec << "_"; + stream_ << outdir << "/" << "Video" << time_stream.str().c_str() << "AC2.Output." << (++index) << ext; + switch(res) { + case 0: + res_w = 640; + res_h = 480; + break; + case 1: + res_w = 1280; + res_h = 720; + break; + case 2: + res_w = 1920; + res_h = 1080; + + break; + } + + /* + bool cw = capture_camera.set(CV_CAP_PROP_FRAME_WIDTH, res_w); + bool ch = capture_camera.set(CV_CAP_PROP_FRAME_HEIGHT, res_h); + + if(cw == false || ch == false) { + QMessageBox::information(this, tr("Info"), tr("Could not set resolution reverting to default ..")); + res_w = ores_w; + res_h = ores_h; + capture_camera.set(CV_CAP_PROP_FRAME_WIDTH, res_w); + capture_camera.set(CV_CAP_PROP_FRAME_HEIGHT, res_h); + } */ + + if(recording) { + video_file_name = output_name; + writer = cv::VideoWriter(output_name.toStdString(), (type == 0) ? CV_FOURCC('m', 'p', '4', 'v') : CV_FOURCC('X','V','I','D'), video_fps, cv::Size(res_w, res_h), true); + + if(!writer.isOpened()) { + Log(tr("Could not create video writer..\n")); + QMessageBox::information(this, tr("Error"), tr("Incorrect Pathname/Or you do not have permission to write to the directory.")); + return false; + } + QString out_s; + QTextStream out_stream(&out_s); + out_stream << "Now recording to: " << output_name << "\nResolution: " << res_w << "x" << res_h << " FPS: " << video_fps << "\n"; + Log(out_s); + } + // if successful + file_new_capture->setEnabled(false); + file_new_video->setEnabled(false); + controls_stop->setEnabled(true); + bool rt_val = playback->setVideoCamera(dev, res, writer, recording); + if(rt_val == false) return false; + playback->Play(); + disp->show(); + return true; +} + +bool AC_MainWindow::startVideo(const QString &filename, const QString &outdir, bool record, int type) { + programMode = MODE_VIDEO; + controls_stop->setEnabled(true); + controls_pause->setEnabled(true); + controls_step->setEnabled(true); + controls_snapshot->setEnabled(true); + if(record == true) + controls_showvideo->setEnabled(true); + + progress_bar->show(); + playback->setDisplayed(true); + video_file_name = ""; + step_frame = false; + capture_video.open(filename.toStdString()); + if(!capture_video.isOpened()) { + return false; + } + video_frames = capture_video.get(CV_CAP_PROP_FRAME_COUNT); + if(video_frames <= 0) return false; + video_fps = capture_video.get(CV_CAP_PROP_FPS); + int res_w = capture_video.get(CV_CAP_PROP_FRAME_WIDTH); + int res_h = capture_video.get(CV_CAP_PROP_FRAME_HEIGHT); + QString str; + QTextStream stream(&str); + stream << "Opened capture device [Video] " << res_w << "x" << res_h << "\n"; + stream << "Video File: " << filename << "\n"; + stream << "FPS: " << video_fps << "\n"; + stream << "Frame Count: " << video_frames << "\n"; + output_directory = outdir; + frame_index = 0; + Log(str); + // if successful + file_new_capture->setEnabled(false); + file_new_video->setEnabled(false); + controls_stop->setEnabled(true); + paused = false; + recording = record; + QString output_name; + QTextStream stream_(&output_name); + static unsigned int index = 0; + time_t t = time(0); + struct tm *m; + m = localtime(&t); + QString ext; + ext = (type == 0) ? ".mov" : ".avi"; + std::ostringstream time_stream; + time_stream << "-" << (m->tm_year + 1900) << "." << (m->tm_mon + 1) << "." << m->tm_mday << "_" << m->tm_hour << "." << m->tm_min << "." << m->tm_sec << "_"; + stream_ << outdir << "/" << "Video" << time_stream.str().c_str() << "AC2.Output." << (++index) << ext; + + + if(recording) { + video_file_name = output_name; + writer = cv::VideoWriter(output_name.toStdString(), (type == 0) ? CV_FOURCC('m', 'p', '4', 'v') : CV_FOURCC('X','V','I','D'), video_fps, cv::Size(res_w, res_h), true); + + if(!writer.isOpened()) { + Log("Error could not open video writer.\n"); + QMessageBox::information(this, tr("Error invalid path"), tr("Incorrect Pathname/Or you do not have permission to write to the directory.")); + return false; + } + QString out_s; + QTextStream out_stream(&out_s); + out_stream << "Now recording to: " << output_name << "\nResolution: " << res_w << "x" << res_h << " FPS: " << video_fps << "\n"; + Log(out_s); + } + playback->setVideo(capture_video,writer,recording); + playback->Play(); + disp->show(); + return true; +} + +void AC_MainWindow::controls_Stop() { + playback->Stop(); + goto_window->hide(); + progress_bar->hide(); + controls_showvideo->setEnabled(false); + controls_stop->setEnabled(false); + controls_pause->setEnabled(false); + controls_step->setEnabled(false); + controls_snapshot->setEnabled(false); + if(capture_video.isOpened()) { + capture_video.release(); + if(recording == true) writer.release(); + file_new_capture->setEnabled(true); + file_new_video->setEnabled(true); + if(recording) { + QString stream_; + QTextStream stream(&stream_); + stream << "Wrote video file: " << video_file_name << "\n"; + Log(stream_); + } + disp->hide(); + playback->Release(); + } + if(programMode == MODE_CAMERA) { + //capture_camera.release(); + if(recording == true) writer.release(); + file_new_capture->setEnabled(true); + file_new_video->setEnabled(true); + if(recording) { + QString stream_; + QTextStream stream(&stream_); + stream << "Wrote video file: " << video_file_name << "\n"; + Log(stream_); + } + disp->hide(); + playback->Release(); + } + Log(tr("Capture device [Closed]\n"));; +} + +void AC_MainWindow::controls_ShowVideo() { + QString st = controls_showvideo->text(); + + if(st == "Hide Display Video") { + playback->setDisplayed(Qt::Unchecked); + disp->hide(); + controls_showvideo->setText("Show Display Video"); + } else { + controls_showvideo->setText("Hide Display Video"); + playback->setDisplayed(true); + disp->show(); + } +} + +void AC_MainWindow::controls_Reset() { + playback->reset_filters(); +} + +void AC_MainWindow::file_Exit() { + QApplication::exit(0); +} + +void AC_MainWindow::file_NewVideo() { + cap_video->show(); + goto_window->hide(); +} + +void AC_MainWindow::file_NewCamera() { + cap_camera->show(); + goto_window->hide(); +} + +void AC_MainWindow::controls_Snap() { + take_snapshot = true; +} + +void AC_MainWindow::controls_Pause() { + QString p = controls_pause->text(); + if(p == "Pause") { + controls_pause->setText("Paused"); + controls_pause->setChecked(true); + paused = true; + if(programMode == MODE_VIDEO) goto_window->showWindow(frame_index, 0, video_frames); + playback->Stop(); + } else { + controls_pause->setText("Pause"); + controls_pause->setChecked(false); + goto_window->hide(); + playback->Play(); + paused = false; + } +} + +void AC_MainWindow::controls_SetImage() { + QString fileName = QFileDialog::getOpenFileName(this,tr("Open Image"), "/home", tr("Image Files (*.png *.jpg)")); + if(fileName != "") { + cv::Mat tblend_image = cv::imread(fileName.toStdString()); + if(!tblend_image.empty()) { + playback->setImage(tblend_image); + QString text; + QTextStream stream(&text); + stream << "Successfully Loaded Image: [" << fileName << "] Size: " << tblend_image.cols << "x" << tblend_image.rows << "\n"; + Log(text); + } else { + QMessageBox::information(this, tr("Image Load failed"), tr("Could not load image")); + } + } +} + +void AC_MainWindow::controls_SetKey() { + QString fileName = QFileDialog::getOpenFileName(this,tr("Open Color Key Image"), "/home", tr("Image Files (*.png)")); + if(fileName != "") { + cv::Mat tblend_image = cv::imread(fileName.toStdString()); + if(!tblend_image.empty()) { + playback->setColorKey(tblend_image); + QString str_value; + QTextStream stream(&str_value); + stream << "ColorKey is (255,0,255)\n Image Set: " << fileName; + QMessageBox::information(this, tr("Loaded Image"), tr(str_value.toStdString().c_str())); + } else { + QMessageBox::information(this, tr("Image Load failed"), tr("Could not load ColorKey image")); + } + } +} + +void AC_MainWindow::controls_Step() { + playback->setStep(); + playback->Play(); + step_frame = true; +} + +void AC_MainWindow::buildVector(std::vector &v) { + if(!v.empty()) v.erase(v.begin(), v.end()); + for(int i = 0; i < custom_filters->count(); ++i) { + QListWidgetItem *val = custom_filters->item(i); + QString name = val->text(); + std::string n = name.toStdString(); + if(n.find(":") == std::string::npos) + v.push_back(filter_map[name.toStdString()]); + else { + std::string namev = name.toStdString(); + std::string left_str = namev.substr(0, namev.find(":")); + std::string right_str = namev.substr(namev.find(":")+1,namev.length()-left_str.length()-1); + int index_val = filter_map[right_str].filter; + FilterValue fv(filter_map[left_str].index, filter_map[left_str].filter, index_val); + v.push_back(fv); + } + } +} + +cv::Mat QImage2Mat(QImage const& src) +{ + cv::Mat tmp(src.height(),src.width(),CV_8UC3,(uchar*)src.bits(),src.bytesPerLine()); + cv::Mat result; + cvtColor(tmp, result,CV_BGR2RGB); + return result; +} + +QImage Mat2QImage(cv::Mat const& src) +{ + cv::Mat temp; + cvtColor(src, temp,CV_BGR2RGB); + QImage dest((const uchar *) temp.data, temp.cols, temp.rows, temp.step, QImage::Format_RGB888); + dest.bits(); + return dest; +} + +void AC_MainWindow::setFrameIndex(int index) { + frame_index = index; +} + +void AC_MainWindow::updateFrame(QImage img) { + if(playback->isStopped() == false) { + disp->displayImage(img); + frame_index++; + QString frame_string; + QTextStream frame_stream(&frame_string); + if(!recording) { + frame_stream << "(Current/Total Frames/Seconds) - (" << frame_index << "/" << video_frames << "/" << (unsigned long)(frame_index/video_fps) << ") "; + } else { + struct stat buf; + stat(video_file_name.toStdString().c_str(), &buf); + frame_stream << "(Current/Total Frames/Seconds/Size) - (" << frame_index << "/" << video_frames << "/" << (unsigned int)(frame_index/video_fps) << "/" << ((buf.st_size/1024)/1024) << " MB) "; + } + if(programMode == MODE_VIDEO) { + + float index = frame_index; + float max_frames = video_frames; + float value = (index/max_frames)*100; + unsigned int val = static_cast(value); + progress_bar->setValue(val); + frame_stream << " - " << val << "%"; + } + statusBar()->showMessage(frame_string); + + if(take_snapshot == true) { + cv::Mat mat = QImage2Mat(img); + static int index = 0; + QString text; + QTextStream stream(&text); + time_t t = time(0); + struct tm *m; + m = localtime(&t); + std::ostringstream time_stream; + time_stream << "-" << (m->tm_year + 1900) << "." << (m->tm_mon + 1) << "." << m->tm_mday << "_" << m->tm_hour << "." << m->tm_min << "." << m->tm_sec << "_"; + stream << output_directory << "/" << "AC2.Snapshot." << time_stream.str().c_str() << "." << ++index << ".png"; + cv::imwrite(text.toStdString(), mat); + QString total; + QTextStream stream_total(&total); + stream_total << "Took Snapshot: " << text << "\n"; + Log(total); + take_snapshot = false; + } + } +} + +void AC_MainWindow::stopRecording() { + controls_Stop(); + frame_index = video_frames; + controls_stop->setEnabled(false); + controls_pause->setEnabled(false); + controls_step->setEnabled(false); + controls_snapshot->setEnabled(false); + progress_bar->hide(); +} + + +void AC_MainWindow::setSubFilter(const QString &filter_num) { + int value_index = filter_map[filter_num.toStdString()].index; + int filter_index = filter_map[filter_num.toStdString()].filter; + int crow = custom_filters->currentRow(); + if(value_index == 0 && crow >= 0) { + std::ostringstream stream; + QListWidgetItem *item = custom_filters->item(crow); + std::string fname = filter_num.toStdString(); + std::string filter_val = item->text().toStdString(); + if(filter_val.find(":") != std::string::npos) + filter_val = filter_val.substr(0, filter_val.find(":")); + + if(!(fname.find("SubFilter") == std::string::npos && filter_val.find("SubFilter") != std::string::npos)) { + stream << filter_val << " does not support a subfilter.\n"; + Log(stream.str().c_str()); + return; + } + stream << "SubFilter set to: " << filter_num.toStdString() << "\n"; + stream << "SubFilter index: " << filter_index << "\n"; + std::ostringstream stream1; + stream1 << filter_val << ":" << fname; + item->setText(stream1.str().c_str()); + std::vector v; + buildVector(v); + playback->setVector(v); + QString l = stream.str().c_str(); + Log(l); + } else { + QString txt; + QTextStream stream(&txt); + stream << "Only Regular Filters can be used as a SubFilter not AF\n"; + Log(txt); + } +} + +void AC_MainWindow::setFade() { + bool fc = fade_on->isChecked(); + playback->setFadeFilter(fc); +} + +void AC_MainWindow::frameInc() { + frame_index++; + QString frame_string; + QTextStream frame_stream(&frame_string); + + if(!recording) { + frame_stream << "(Current/Total Frames/Seconds) - (" << frame_index << "/" << video_frames << "/" << (unsigned int)(frame_index/video_fps) << ") "; + } else { + struct stat buf; + stat(video_file_name.toStdString().c_str(), &buf); + frame_stream << "(Current/Total Frames/Seconds/Size) - (" << frame_index << "/" << video_frames << "/" << (unsigned int)(frame_index/video_fps) << "/" << ((buf.st_size/1024)/1024) << " MB) "; + + } + if(programMode == MODE_VIDEO) { + float index = frame_index; + float max_frames = video_frames; + float value = (index/max_frames)*100; + unsigned int val = static_cast(value); + if(frame_index <= video_frames) + frame_stream << " - " << val << "%"; + progress_bar->setValue(val); + } + statusBar()->showMessage(frame_string); +} + +void AC_MainWindow::help_About() { + QString about_str; + QTextStream stream(&about_str); + stream << tr("Acid Cam Qt version: ") << ac_version << " filters: " << ac::version.c_str() << "

"; + stream << tr("Engineering by Jared Bruni

This software is dedicated to all the people that struggle with mental illness.

My Social Media Accounts

\n\n GitHub
\nYouTube
Instagram
LostSideDead Facebook
My Facebook
Twitter


\n"); + + QMessageBox::information(this, tr("About Acid Cam"), about_str); +} + +void AC_MainWindow::openSearch() { + search_box->show(); +} diff --git a/windows/Acid.Cam.Qt.Windows.Project/main_window.h b/windows/Acid.Cam.Qt.Windows.Project/main_window.h new file mode 100755 index 0000000..f7899d8 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/main_window.h @@ -0,0 +1,131 @@ + +/* + * Acid Cam v2 - Qt/OpenCV Edition + * written by Jared Bruni ( http://lostsidedead.com ) + * (C) 2017 GPL +*/ + +#ifndef __MAIN_WINDOW_H__ +#define __MAIN_WINDOW_H__ + +#include "qtheaders.h" +#include "new_dialog.h" +#include "display_window.h" +#include "playback_thread.h" +#include "search_box.h" +#include "goto_window.h" + +class SearchWindow; + +class AC_MainWindow : public QMainWindow { + Q_OBJECT +public: + AC_MainWindow(QWidget *parent = 0); + ~AC_MainWindow(); + void Log(const QString &s); + bool startCamera(int res, int dev, const QString &outdir, bool record, int type); + bool startVideo(const QString &filename, const QString &outdir, bool record, int type); + QListWidget /**filters,*/ *custom_filters; + QPushButton *btn_add, *btn_remove, *btn_moveup, *btn_movedown, *btn_sub, *btn_clr; + QTextEdit *log_text; + QCheckBox *chk_negate; + QComboBox *combo_rgb; + QSlider *slide_r, *slide_g, *slide_b, *slide_bright, *slide_gamma, *slide_saturation; + QProgressBar *progress_bar; + QComboBox *color_maps, *filters; + QMenu *file_menu, *controls_menu, *help_menu, *options, *movement, *speed_menu; + QAction *file_exit, *file_new_capture, *file_new_video; + QAction *controls_snapshot, *controls_pause, *controls_step, *controls_stop, *controls_setimage,*controls_setkey,*controls_showvideo, *clear_images, *reset_filters; + QAction *help_about; + QAction *open_search; + QAction *in_out_increase; + QAction *in_out; + QAction *out_reset; + QAction *speed_action_items[7]; + QMenu *image_menu; + QAction *flip1, *flip2, *flip3, *noflip; + QAction *clear_sub; + QAction *clear_image; + QAction *repeat_v; + QAction *fade_on; + double speed_actions[7]; + QRadioButton *filter_single, *filter_custom; + void updateList(); + void setSubFilter(const QString &num); + void setFrameIndex(int i); +public slots: + void addClicked(); + void rmvClicked(); + void upClicked(); + void setSub(); + void downClicked(); + void file_Exit(); + void file_NewVideo(); + void file_NewCamera(); + void controls_Stop(); + void controls_Snap(); + void controls_Pause(); + void controls_Step(); + void controls_SetImage(); + void controls_ShowVideo(); + void controls_SetKey(); + void controls_Reset(); + void help_About(); + void updateFrame(QImage img); + void stopRecording(); + void resetIndex(); + void chk_Clicked(); + void cb_SetIndex(int index); + void frameInc(); + void slideChanged(int pos); + void colorChanged(int pos); + void colorMapChanged(int pos); + void comboFilterChanged(int pos); + void setFilterSingle(); + void setFilterCustom(); + void openSearch(); + void movementOption1(); + void movementOption2(); + void movementOption3(); + void speed1(); + void speed2(); + void speed3(); + void speed4(); + void speed5(); + void speed6(); + void speed7(); + void flip1_action(); + void flip2_action(); + void flip3_action(); + void noflip_action(); + void clear_subfilter(); + void clear_img(); + void repeat_vid(); + void setFade(); +private: + void createControls(); + void createMenu(); + DisplayWindow *disp; + CaptureCamera *cap_camera; + CaptureVideo *cap_video; + SearchWindow *search_box; + GotoWindow *goto_window; + cv::VideoCapture capture_camera, capture_video; + cv::VideoWriter writer; + unsigned long video_frames; + double video_fps; + bool paused, recording, step_frame; + QString video_file_name; + QString output_directory; + bool take_snapshot; + unsigned long file_pos, frame_index; + Playback *playback; + VideoMode programMode; + void buildVector(std::vector &v); +}; + +extern const char *filer_names[]; +extern std::unordered_map filter_map; +void generate_map(); + +#endif diff --git a/windows/Acid.Cam.Qt.Windows.Project/new_dialog.cpp b/windows/Acid.Cam.Qt.Windows.Project/new_dialog.cpp new file mode 100755 index 0000000..4064875 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/new_dialog.cpp @@ -0,0 +1,184 @@ + +/* + * Acid Cam v2 - Qt/OpenCV Edition + * written by Jared Bruni ( http://lostsidedead.com ) + * (C) 2017 GPL +*/ + + +#include "new_dialog.h" +#include "main_window.h" + + +CaptureCamera::CaptureCamera(QWidget *parent) : QDialog(parent) { + setGeometry(100, 100, 290, 120); + setFixedSize(290, 120); + setWindowTitle(tr("Capture from Webcam")); + setWindowIcon(QPixmap(":/images/icon.png")); + createControls(); +} + +void CaptureCamera::createControls() { + QLabel *res = new QLabel(tr("Resolution: "), this); + res->setGeometry(10, 10, 75, 20); + combo_res = new QComboBox(this); + combo_res->setGeometry(85, 10, 200, 25); + combo_res->addItem("640x480 (SD)"); + combo_res->addItem("1280x720 (HD)"); + combo_res->addItem("1920x1080 (Full HD)"); + QLabel *dev = new QLabel(tr("Device: "), this); + dev->setGeometry(10, 35, 50, 20); + combo_device = new QComboBox(this); + combo_device->setGeometry(85, 35, 200, 25); + for(int i = 0; i < 10; ++i) { + QString s; + QTextStream stream(&s); + stream << i; + combo_device->addItem(*stream.string()); + } + btn_select = new QPushButton(tr("Save Directory"), this); + btn_select->setGeometry(10, 65, 100, 20); + output_dir = new QLineEdit("", this); + output_dir->setGeometry(110, 65, 175, 20); + output_dir->setReadOnly(true); + chk_record = new QCheckBox(tr("Record"), this); + chk_record->setGeometry(10, 95, 70, 20); + btn_start = new QPushButton(tr("Start"), this); + btn_start->setGeometry(185, 95, 100, 20); + connect(btn_start, SIGNAL(clicked()), this, SLOT(btn_Start())); + connect(btn_select, SIGNAL(clicked()), this, SLOT(btn_Select())); + + video_type = new QComboBox(this); + video_type->setGeometry(80, 90, 90, 25); + video_type->addItem("MOV"); + video_type->addItem("AVI"); +} + +void CaptureCamera::setParent(AC_MainWindow *p) { + win_parent = p; +} + +void CaptureCamera::btn_Select() { + + QString def_path = ""; +#if defined(__linux__) + def_path = "/home"; +#elif defined(__APPLE__) + def_path = "/Users"; +#elif defined(_WIN32) + def_path = "C:\\"; +#endif + + QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),def_path,QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + + if(dir != "") { + output_dir->setText(dir); + } +} + +void CaptureCamera::btn_Start() { + + int vtype; + vtype = video_type->currentIndex(); + + if(output_dir->text().length() > 0) { + if(win_parent->startCamera(combo_res->currentIndex(), combo_device->currentIndex(), output_dir->text(), chk_record->isChecked(), vtype)) { + hide(); + + } else { + QMessageBox::information(this, tr("Could not open Capture device"), tr("Make sure you Webcam is pluged in. If you have more than one Webcam use the proper device index.")); + } + } else { + QMessageBox::information(this, tr("Error please fill out Save Directory"), tr("Could not create Capture device requires Save Directory")); + } +} + +CaptureVideo::CaptureVideo(QWidget *parent) : QDialog(parent) { + setGeometry(100, 100, 330, 100); + setFixedSize(330, 100); + setWindowTitle(tr("Capture from Video")); + setWindowIcon(QPixmap(":/images/icon.png")); + createControls(); +} + +void CaptureVideo::createControls() { + btn_setedit = new QPushButton(tr("Source File"), this); + btn_setedit->setGeometry(10, 10, 110, 20); + edit_src = new QLineEdit(this); + edit_src->setGeometry(120, 10, 200, 20); + edit_src->setReadOnly(true); + btn_setout = new QPushButton(tr("Set Output"), this); + btn_setout->setGeometry(10, 30, 110, 20); + edit_outdir = new QLineEdit(this); + edit_outdir->setGeometry(120, 30, 200, 20); + edit_outdir->setReadOnly(true); + btn_start = new QPushButton(tr("Start"), this); + btn_start->setGeometry(10, 60, 100, 20); + chk_record = new QCheckBox(tr("Record"), this); + chk_record->setGeometry(110, 60, 80, 20); + + video_type = new QComboBox(this); + video_type->setGeometry(180, 55, 120, 25); + video_type->addItem("MOV"); + video_type->addItem("AVI"); + connect(btn_setedit, SIGNAL(clicked()), this, SLOT(btn_SetSourceFile())); + connect(btn_setout, SIGNAL(clicked()), this, SLOT(btn_SetOutputDir())); + connect(btn_start, SIGNAL(clicked()), this, SLOT(btn_Start())); +} + +void CaptureVideo::setParent(AC_MainWindow *p) { + win_parent = p; +} + +void CaptureVideo::btn_SetSourceFile() { + + QString def_path = ""; +#if defined(__linux__) + def_path = "/home"; +#elif defined(__APPLE__) + def_path = "/Users"; +#elif defined(_WIN32) + def_path = "C:\\"; +#endif + QString fileName = QFileDialog::getOpenFileName(this,tr("Open Video"), def_path, tr("Video Files (*.avi *.mov *.mp4 *.mkv)")); + if(fileName != "") + edit_src->setText(fileName); +} + +void CaptureVideo::btn_SetOutputDir() { + + QString def_path = ""; +#if defined(__linux__) + def_path = "/home"; +#elif defined(__APPLE__) + def_path = "/Users"; +#elif defined(_WIN32) + def_path = "C:\\"; +#endif + + QString dir = QFileDialog::getExistingDirectory(this, tr("Set Output Directory"),def_path,QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + if(dir != "") + edit_outdir->setText(dir); +} + +void CaptureVideo::btn_Start() { + if(edit_src->text().length() <= 0) { + QMessageBox::information(this, tr("No Input"), tr("Please Select a Video File")); + return; + } + if(edit_outdir->text().length() <= 0) { + QMessageBox::information(this, tr("No Output"), tr("Please Select Output Directory")); + return; + } + + int num; + num = video_type->currentIndex(); + + if(win_parent->startVideo(edit_src->text(), edit_outdir->text(), chk_record->isChecked(), num)) { + hide(); + } else { + QMessageBox::information(this, tr("Could not open file"), tr("Could not open video file, an error has occured")); + } +} + + diff --git a/windows/Acid.Cam.Qt.Windows.Project/new_dialog.h b/windows/Acid.Cam.Qt.Windows.Project/new_dialog.h new file mode 100755 index 0000000..bda9719 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/new_dialog.h @@ -0,0 +1,56 @@ + +/* + * Acid Cam v2 - Qt/OpenCV Edition + * written by Jared Bruni ( http://lostsidedead.com ) + * (C) 2017 GPL +*/ + +#ifndef _NEW_DIALOG_H_ +#define _NEW_DIALOG_H_ + +#include "qtheaders.h" + +class AC_MainWindow; + +class CaptureCamera : public QDialog { + Q_OBJECT +public: + CaptureCamera(QWidget *parent = 0); + void createControls(); + void setParent(AC_MainWindow *p); + + QComboBox *combo_res, *combo_device; + QLineEdit *output_dir; + QCheckBox *chk_record; + QPushButton *btn_start, *btn_select; + QComboBox *video_type; +public slots: + void btn_Select(); + void btn_Start(); + +private: + AC_MainWindow *win_parent; +}; + +class CaptureVideo : public QDialog { + Q_OBJECT +public: + CaptureVideo(QWidget *parent = 0); + void createControls(); + void setParent(AC_MainWindow *p); + + QLineEdit *edit_src, *edit_outdir; + QPushButton *btn_setedit, *btn_setout, *btn_start; + QCheckBox *chk_record; + QComboBox *video_type; + +public slots: + void btn_SetSourceFile(); + void btn_SetOutputDir(); + void btn_Start(); +private: + AC_MainWindow *win_parent; + +}; + +#endif diff --git a/windows/Acid.Cam.Qt.Windows.Project/playback_thread.cpp b/windows/Acid.Cam.Qt.Windows.Project/playback_thread.cpp new file mode 100755 index 0000000..72de359 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/playback_thread.cpp @@ -0,0 +1,405 @@ +/* + * Acid Cam v2 - Qt/OpenCV Edition + * written by Jared Bruni ( http://lostsidedead.com ) + * (C) 2017 GPL +*/ + + +#include"playback_thread.h" + +Playback::Playback(QObject *parent) : QThread(parent) { + stop = true; + isStep = false; + isPaused = false; + bright_ = gamma_ = saturation_ = 0; + single_mode = true; + alpha = 0; + prev_filter = FilterValue(0, 0, -1); + flip_frame1 = false; + flip_frame2 = false; + repeat_video = false; + fadefilter = true; +} + +void Playback::Play() { + if(!isRunning()) { + if(isStopped()) { + stop = false; + } + } + //start(LowPriority); + start(HighPriority); +} + +void Playback::setVideo(cv::VideoCapture cap, cv::VideoWriter wr, bool record) { + mode = MODE_VIDEO; + mutex.lock(); + capture = cap; + writer = wr; + recording = record; + if(capture.isOpened()) { + frame_rate = capture.get(CV_CAP_PROP_FPS); + if(frame_rate <= 0) frame_rate = 24; + } + mutex.unlock(); +} + +bool Playback::setVideoCamera(int device, int res, cv::VideoWriter wr, bool record) { + mode = MODE_CAMERA; + device_num = device; + mutex.lock(); +#if defined(__linux__) || defined(__APPLE__) + capture.open(device); + if(!capture.isOpened()) { + mutex.unlock(); + return false; + } +#else + if(!capture.isOpened()) { + capture.open(device); + if(!capture.isOpened()) { + mutex.unlock(); + return false; + } + } +#endif + + recording = record; + writer = wr; + int res_w = 0, res_h = 0, ores_w = 640, ores_h = 480; + switch(res) { + case 0: + res_w = 640; + res_h = 480; + break; + case 1: + res_w = 1280; + res_h = 720; + break; + case 2: + res_w = 1920; + res_h = 1080; + break; + } + bool cw = capture.set(CV_CAP_PROP_FRAME_WIDTH, res_w); + bool ch = capture.set(CV_CAP_PROP_FRAME_HEIGHT, res_h); + if(cw == false || ch == false) { + res_w = ores_w; + res_h = ores_h; + capture.set(CV_CAP_PROP_FRAME_WIDTH, res_w); + capture.set(CV_CAP_PROP_FRAME_HEIGHT, res_h); + } + mutex.unlock(); + return true; +} + +void Playback::setVector(std::vector v) { + mutex_add.lock(); + current = v; + mutex_add.unlock(); +} + +void Playback::setOptions(bool n, int c) { + mutex.lock(); + ac::isNegative = n; + negate = n; + reverse = c; + ac::color_order = c; + ac::in_custom = true; + mutex.unlock(); +} + +void Playback::reset_filters() { + mutex.lock(); + if(ac::reset_alpha == false) { + ac::reset_alpha = true; + } + ac::frames_released = true; + mutex.unlock(); +} + +void Playback::SetFlip(bool f1, bool f2) { + mutex.lock(); + flip_frame1 = f1; + flip_frame2 = f2; + mutex.unlock(); +} + +void Playback::setColorOptions(int b, int g, int s) { + mutex.lock(); + bright_ = b; + gamma_ = g; + saturation_ = s; + mutex.unlock(); +} + +void Playback::setIndexChanged(std::string value) { + prev_filter = current_filter; + current_filter = filter_map[value]; + alpha = 1.0; +} + +void Playback::setSubFilter(int index) { + mutex.lock(); + ac::setSubFilter(index); + mutex.unlock(); +} + +void Playback::setSingleMode(bool val) { + single_mode = val; +} + +void Playback::setRGB(int r, int g, int b) { + mutex.lock(); + ac::swapColor_r = r; + ac::swapColor_g = g; + ac::swapColor_b = b; + mutex.unlock(); +} + +void Playback::setColorMap(int c) { + mutex.lock(); + ac::set_color_map = c; + mutex.unlock(); +} + +void Playback::setDisplayed(bool shown) { + video_shown = shown; +} + +void Playback::drawEffects(cv::Mat &frame) { + if(ac::set_color_map > 0) ac::ApplyColorMap(frame); + ac::frames_released = false; + ac::reset_alpha = false; + if(bright_ > 0) { + ac::setBrightness(frame, 1.0, bright_); + } + if(gamma_ > 0) { + cv::Mat gam = frame.clone(); + ac::setGamma(gam, frame, gamma_); + } + if(saturation_ > 0) { + ac::setSaturation(frame, saturation_); + } + if(colorkey_set == true && !color_image.empty()) { + cv::Mat cframe = frame.clone(); + cv::Vec3b well_color(255,0,255); + ac::filterColorKeyed(well_color, ac::orig_frame, cframe, frame); + } +} + +void Playback::drawFilter(cv::Mat &frame, FilterValue &f) { + if(f.index == 0) { + ac::setSubFilter(f.subfilter); + ac::draw_func[f.filter](frame); + ac::setSubFilter(-1); + } else if(current_filter.index == 1) { + current_filterx = f.filter; + ac::alphaFlame(frame); + } else if(f.index == 2) { + draw_plugin(frame, f.filter); + } +} + +void Playback::run() { + + int duration = 1000/ac::fps; + + while(!stop) { + mutex.lock(); + if(!capture.read(frame)) { + if(repeat_video && mode == MODE_VIDEO) { + mutex.unlock(); + setFrameIndex(0); + emit resetIndex(); + continue; + } + stop = true; + mutex.unlock(); + emit stopRecording(); + return; + } + cv::Mat temp_frame; + if(flip_frame1 == true) { + cv::flip(frame, temp_frame, 1); + frame = temp_frame; + } + if(flip_frame2 == true) { + cv::flip(frame, temp_frame, 0); + frame = temp_frame; + } + + mutex.unlock(); + static std::vector cur; + mutex_shown.lock(); + cur = current; + mutex_shown.unlock(); + ac::orig_frame = frame.clone(); + if(single_mode == true && alpha > 0) { + if(fadefilter == true) filterFade(frame, current_filter, prev_filter, alpha); + drawEffects(frame); + alpha -= 0.08; + } else if(single_mode == true) { + mutex.lock(); + ac::in_custom = false; + drawFilter(frame, current_filter); + drawEffects(frame); + msleep(duration/2); + mutex.unlock(); + } else if(cur.size()>0) { + mutex.lock(); + ac::in_custom = true; + for(unsigned int i = 0; i < cur.size(); ++i) { + if(i == cur.size()-1) + ac::in_custom = false; + drawFilter(frame, cur[i]); + msleep(duration/2); + } + drawEffects(frame); + mutex.unlock(); + } else { + msleep(duration); + } + mutex.lock(); + if(recording && writer.isOpened()) { + writer.write(frame); + } + mutex.unlock(); + if(video_shown == true) { + if(frame.channels()==3) { + cv::cvtColor(frame, rgb_frame, CV_BGR2RGB); + img = QImage((const unsigned char*)(rgb_frame.data), rgb_frame.cols, rgb_frame.rows, QImage::Format_RGB888); + } else { + img = QImage((const unsigned char*)(frame.data), frame.cols, frame.rows, QImage::Format_Indexed8); + } + emit procImage(img); + if(isStep == true) { + isStep = false; + return; + } + } else { + emit frameIncrement(); + } + } +} + + +Playback::~Playback() { + mutex.lock(); + stop = true; +#if defined(__linux__) || defined(__APPLE__) + condition.wakeOne(); +#endif + mutex.unlock(); +#if defined(__linux__) || defined(__APPLE__) + wait(); +#endif +} + +void Playback::setFrameIndex(const long &index) { + mutex.lock(); + capture.set(CV_CAP_PROP_POS_FRAMES, index); + mutex.unlock(); +} + +bool Playback::getFrame(QImage &img, const int &index) { + QImage image; + setFrameIndex(index); + mutex.lock(); + cv::Mat frame; + if(mode == MODE_VIDEO && capture.read(frame)) { + cv::cvtColor(frame, rgb_frame, CV_BGR2RGB); + img = QImage((const unsigned char*)(rgb_frame.data), rgb_frame.cols, rgb_frame.rows, QImage::Format_RGB888); + mutex.unlock(); + setFrameIndex(index); + return true; + } + mutex.unlock(); + return false; +} + +void Playback::enableRepeat(bool re) { + mutex.lock(); + repeat_video = re; + mutex.unlock(); +} + + +void Playback::Clear() { + mutex.lock(); + blend_set = false; + colorkey_set = false; + blend_image.release(); + color_image.release(); + mutex.unlock(); +} + +void Playback::Stop() { + stop = true; + alpha = 0; + prev_filter = FilterValue(0, 0, -1); +} + +void Playback::Release() { + mutex.lock(); + stop = true; + if(capture.isOpened() && mode == MODE_VIDEO) capture.release(); + if(writer.isOpened()) writer.release(); + mutex.unlock(); +} + +void Playback::msleep(int ms) { + QThread::msleep(ms); +} + +bool Playback::isStopped() const { + return this->stop; +} + +void Playback::setStep() { + mutex.lock(); + isStep = true; + mutex.unlock(); +} + +void Playback::setImage(const cv::Mat &frame) { + mutex.lock(); + blend_set = true; + blend_image = frame; + mutex.unlock(); +} + +void Playback::setFadeFilter(bool f) { + mutex.lock(); + fadefilter = f; + mutex.unlock(); +} + +void Playback::setColorKey(const cv::Mat &image) { + mutex.lock(); + colorkey_set = true; + color_image = image; + mutex.unlock(); +} + +void Playback::filterFade(cv::Mat &frame, FilterValue &filter1, FilterValue &filter2, double alpha) { + unsigned int h = frame.rows; // frame height + unsigned int w = frame.cols;// framew idth + // make copies of original frame + cv::Mat frame1 = frame.clone(), frame2 = frame.clone(); + // apply filters on two copies of original frame + drawFilter(frame1,filter1); + drawFilter(frame2,filter2); + // loop through image setting each pixel with alphablended pixel + for(unsigned int z = 0; z < h; ++z) { + for(unsigned int i = 0; i < w; ++i) { + cv::Vec3b &pixel = frame.at(z, i); // target pixel + cv::Vec3b frame1_pix = frame1.at(z, i); // frame1 pixel + cv::Vec3b frame2_pix = frame2.at(z, i); // frame2 pixel + // loop through pixel components and set target pixel to alpha blended pixel of two frames + for(unsigned int q = 0; q < 3; ++q) + pixel[q] = frame2_pix[q]+(frame1_pix[q]*alpha); + } + } +} + diff --git a/windows/Acid.Cam.Qt.Windows.Project/playback_thread.h b/windows/Acid.Cam.Qt.Windows.Project/playback_thread.h new file mode 100755 index 0000000..3e01143 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/playback_thread.h @@ -0,0 +1,84 @@ + +/* + * Acid Cam v2 - Qt/OpenCV Edition + * written by Jared Bruni ( http://lostsidedead.com ) + * (C) 2017 GPL +*/ + +#ifndef __PLAYBACK_WINDOW_H__ +#define __PLAYBACK_WINDOW_H__ + +#include "qtheaders.h" +#include + +enum VideoMode { MODE_CAMERA = 0, MODE_VIDEO }; + +class Playback : public QThread { + Q_OBJECT +private: + std::atomic stop; + std::atomic video_shown; + QMutex mutex, mutex_shown, mutex_add; + QWaitCondition condition; + cv::Mat frame; + double frame_rate; + bool recording; + cv::VideoCapture capture; + cv::VideoWriter writer; + cv::Mat rgb_frame; + QImage img; + std::vector current; + bool isPaused, isStep; + VideoMode mode; + int device_num; + unsigned long *frame_index; + unsigned int red, green, blue; + unsigned int bright_, gamma_, saturation_; + bool single_mode; + FilterValue current_filter, prev_filter; + double alpha; + bool flip_frame1, flip_frame2; + bool repeat_video; + bool fadefilter; +public: + Playback(QObject *parent = 0); + ~Playback(); + void setFadeFilter(bool f); + void setFrameIndex(const long &index); + bool getFrame(QImage &img, const int &index); + void setRGB(int r, int g, int b); + void setColorOptions(int b, int g, int s); + void setColorMap(int c); + void Play(); + void Stop(); + void Release(); + void SetFlip(bool f1, bool f2); + void setVideo(cv::VideoCapture cap, cv::VideoWriter writer, bool record); + bool setVideoCamera(int device, int res, cv::VideoWriter writer, bool record); + bool isStopped() const; + void run(); + void Clear(); + void msleep(int ms); + void setVector(std::vector s); + void setOptions(bool n, int c); + void setImage(const cv::Mat &image); + void setColorKey(const cv::Mat &image); + void setStep(); + void setDisplayed(bool shown); + void setIndexChanged(std::string name); + void setSingleMode(bool val); + void drawFilter(cv::Mat &frame, FilterValue &filter); + void drawEffects(cv::Mat &frame); + void filterFade(cv::Mat &frame, FilterValue &filter1, FilterValue &filter2, double alpha); + void reset_filters(); + void setSubFilter(int index); + void enableRepeat(bool re); +signals: + void procImage(const QImage image); + void stopRecording(); + void frameIncrement(); + void resetIndex(); + +}; + +#endif diff --git a/windows/Acid.Cam.Qt.Windows.Project/plugin.cpp b/windows/Acid.Cam.Qt.Windows.Project/plugin.cpp new file mode 100755 index 0000000..3496331 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/plugin.cpp @@ -0,0 +1,128 @@ + +/* + * Acid Cam v2 - Qt/OpenCV Edition + * written by Jared Bruni ( http://lostsidedead.com ) + * (C) 2017 GPL + */ + +#include "plugin.h" + +PluginList plugins; + +void add_directory(QDir &cdir, std::vector &files) { + cdir.setFilter(QDir::Files | QDir::Dirs); + QFileInfoList list = cdir.entryInfoList(); + int pos = 0; + QString platform; +#if defined(__linux__) + platform = ".so"; +#elif defined(__APPLE__) + platform = ".dylib"; +#else + platform = ".dll"; +#endif + while(pos < list.size()) { + QFileInfo info = list.at(pos); + if(info.isDir() && info.fileName() != "." && info.fileName() != "..") { + QDir cdir = info.dir(); + cdir.cd(info.fileName()); + add_directory(cdir, files); + ++pos; + continue; + } + else if(info.isFile() && info.fileName() != "." && info.fileName() != ".." && info.fileName().contains(platform)) { + files.push_back(info.filePath().toStdString()); + } + ++pos; + } +} + +void init_plugins() { + std::vector files; + QDir d("plugins"); + add_directory(d, files); + if(files.size()>0) { + for(unsigned int i = 0; i < files.size(); ++i) { + Plugin *p = new Plugin(); + if(p->loadPlugin(files[i])) + plugins.plugin_list.push_back(p); + } + } +} + +void draw_plugin(cv::Mat &frame, int filter) { + for(int z = 0; z < frame.rows; ++z) { + for(int i = 0; i < frame.cols; ++i) { + unsigned char rgb[3]; + cv::Vec3b &cpixel = frame.at(z, i); + rgb[0] = cpixel[0]; + rgb[1] = cpixel[1]; + rgb[2] = cpixel[2]; + plugins.plugin_list[filter]->call_Pixel(i, z, rgb); + cpixel[0] = rgb[0]; + cpixel[1] = rgb[1]; + cpixel[2] = rgb[2]; + } + } + plugins.plugin_list[filter]->call_Complete(); +} + + +void plugin_callback(cv::Mat &) { + +} + +Plugin::Plugin() { + library = 0; +} + +Plugin::~Plugin() { + if(library) delete library; +} + +bool Plugin::loadPlugin(const std::string &text) { + library = new QLibrary(text.c_str()); + if(!library) { + QMessageBox::information(0, QObject::tr("Could not load Library"), text.c_str()); + return false; + } + + pixel_function = (pixel) library->resolve("pixel"); + if(!pixel_function) { + QMessageBox::information(0, text.c_str(), "Could not find pixel function"); + return false; + } + + complete_function = (complete) library->resolve("complete"); + if(!complete_function) { + QMessageBox::information(0, text.c_str(), "Could not find complete function"); + return false; + } + mod_name = text; + return true; +} + + +void Plugin::call_Pixel(int x, int y, unsigned char *rgb) { + + if(pixel_function) + pixel_function(x, y, rgb); + +} +void Plugin::call_Complete() { + if(complete_function) + complete_function(); +} + +PluginList::PluginList() { + +} + +PluginList::~PluginList() { + if(plugin_list.size() == 0) return; + + for(auto i = plugin_list.begin(); i != plugin_list.end(); ++i) + delete *i; +} + + diff --git a/windows/Acid.Cam.Qt.Windows.Project/plugin.h b/windows/Acid.Cam.Qt.Windows.Project/plugin.h new file mode 100755 index 0000000..e421cd6 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/plugin.h @@ -0,0 +1,39 @@ +/* + * Acid Cam v2 - Qt/OpenCV Edition + * written by Jared Bruni ( http://lostsidedead.com ) + * (C) 2017 GPL + */ + +#ifndef _PLUGIN_H +#define _PLUGIN_H + +#include "qtheaders.h" + + +typedef void (*pixel)(int x, int y, unsigned char *buf); +typedef void (*complete)(); + +class Plugin { +public: + Plugin(); + ~Plugin(); + bool loadPlugin(const std::string &text); + void call_Pixel(int x, int y, unsigned char *rgb); + void call_Complete(); + std::string name() const { return mod_name; } +private: + pixel pixel_function; + complete complete_function; + QLibrary *library; + std::string mod_name; +}; + +class PluginList { +public: + PluginList(); + ~PluginList(); + std::vector plugin_list; +}; + +extern PluginList plugins; +#endif diff --git a/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter.dll b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter.dll new file mode 100755 index 0000000..c681947 Binary files /dev/null and b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter.dll differ diff --git a/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter.opensdf b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter.opensdf new file mode 100755 index 0000000..d1ce2cf Binary files /dev/null and b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter.opensdf differ diff --git a/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter.sdf b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter.sdf new file mode 100755 index 0000000..cc0093d Binary files /dev/null and b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter.sdf differ diff --git a/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter.sln b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter.sln new file mode 100755 index 0000000..bcd5ec6 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BasicFilter", "BasicFilter\BasicFilter.vcxproj", "{9991B5C6-E407-43B6-8F68-08BA8179360C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9991B5C6-E407-43B6-8F68-08BA8179360C}.Debug|Win32.ActiveCfg = Debug|Win32 + {9991B5C6-E407-43B6-8F68-08BA8179360C}.Debug|Win32.Build.0 = Debug|Win32 + {9991B5C6-E407-43B6-8F68-08BA8179360C}.Release|Win32.ActiveCfg = Release|Win32 + {9991B5C6-E407-43B6-8F68-08BA8179360C}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter.v12.suo b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter.v12.suo new file mode 100755 index 0000000..33d7d12 Binary files /dev/null and b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter.v12.suo differ diff --git a/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/BasicFilter.cpp b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/BasicFilter.cpp new file mode 100755 index 0000000..f3797a6 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/BasicFilter.cpp @@ -0,0 +1,12 @@ + +#include "stdafx.h" +#include "BasicFilter.h" + +BASICFILTER_API void pixel(int x, int y, unsigned char *rgb) +{ + rgb[0] = rgb[1] = rgb[2] = 0; +} + +BASICFILTER_API void complete() { + +} \ No newline at end of file diff --git a/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/BasicFilter.h b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/BasicFilter.h new file mode 100755 index 0000000..ee91a51 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/BasicFilter.h @@ -0,0 +1,15 @@ +// The following ifdef block is the standard way of creating macros which make exporting +// from a DLL simpler. All files within this DLL are compiled with the BASICFILTER_EXPORTS +// symbol defined on the command line. This symbol should not be defined on any project +// that uses this DLL. This way any other project whose source files include this file see +// BASICFILTER_API functions as being imported from a DLL, whereas this DLL sees symbols +// defined with this macro as being exported. +#ifdef BASICFILTER_EXPORTS +#define BASICFILTER_API __declspec(dllexport) +#else +#define BASICFILTER_API __declspec(dllimport) +#endif + + +extern "C" BASICFILTER_API void pixel(int x, int y, unsigned char *rgb); +extern "C" BASICFILTER_API void complete(); diff --git a/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/BasicFilter.vcxproj b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/BasicFilter.vcxproj new file mode 100755 index 0000000..794484d --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/BasicFilter.vcxproj @@ -0,0 +1,104 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {9991B5C6-E407-43B6-8F68-08BA8179360C} + Win32Proj + BasicFilter + + + + DynamicLibrary + true + v120 + Unicode + + + DynamicLibrary + false + v120 + true + Unicode + + + + + + + + + + + + + true + + + false + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;BASICFILTER_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;BASICFILTER_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + + + + + + + + + + false + + + false + + + + + Create + Create + + + + + + \ No newline at end of file diff --git a/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/BasicFilter.vcxproj.filters b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/BasicFilter.vcxproj.filters new file mode 100755 index 0000000..7c1926b --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/BasicFilter.vcxproj.filters @@ -0,0 +1,42 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/ReadMe.txt b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/ReadMe.txt new file mode 100755 index 0000000..4b14860 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/ReadMe.txt @@ -0,0 +1,40 @@ +======================================================================== + DYNAMIC LINK LIBRARY : BasicFilter Project Overview +======================================================================== + +AppWizard has created this BasicFilter DLL for you. + +This file contains a summary of what you will find in each of the files that +make up your BasicFilter application. + + +BasicFilter.vcxproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +BasicFilter.vcxproj.filters + This is the filters file for VC++ projects generated using an Application Wizard. + It contains information about the association between the files in your project + and the filters. This association is used in the IDE to show grouping of files with + similar extensions under a specific node (for e.g. ".cpp" files are associated with the + "Source Files" filter). + +BasicFilter.cpp + This is the main DLL source file. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named BasicFilter.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" comments to indicate parts of the source code you +should add to or customize. + +///////////////////////////////////////////////////////////////////////////// diff --git a/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/dllmain.cpp b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/dllmain.cpp new file mode 100755 index 0000000..8a4edd3 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/dllmain.cpp @@ -0,0 +1,19 @@ +// dllmain.cpp : Defines the entry point for the DLL application. +#include "stdafx.h" + +BOOL APIENTRY DllMain( HMODULE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + diff --git a/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/stdafx.cpp b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/stdafx.cpp new file mode 100755 index 0000000..67e03ea --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// BasicFilter.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/stdafx.h b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/stdafx.h new file mode 100755 index 0000000..677e68a --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/stdafx.h @@ -0,0 +1,16 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include "targetver.h" + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +// Windows Header Files: +#include + + + +// TODO: reference additional headers your program requires here diff --git a/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/targetver.h b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/targetver.h new file mode 100755 index 0000000..90e767b --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/BasicFilter/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// Including SDKDDKVer.h defines the highest available Windows platform. + +// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and +// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. + +#include diff --git a/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/ipch/basicfilter-9d3f4ab5/basicfilter-583a8a94.ipch b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/ipch/basicfilter-9d3f4ab5/basicfilter-583a8a94.ipch new file mode 100755 index 0000000..3233c79 Binary files /dev/null and b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/ipch/basicfilter-9d3f4ab5/basicfilter-583a8a94.ipch differ diff --git a/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/ipch/basicfilter-9d3f4ab5/basicfilter-93c2138e.ipch b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/ipch/basicfilter-9d3f4ab5/basicfilter-93c2138e.ipch new file mode 100755 index 0000000..0a0fe71 Binary files /dev/null and b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/BasicFilter/ipch/basicfilter-9d3f4ab5/basicfilter-93c2138e.ipch differ diff --git a/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/Makefile b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/Makefile new file mode 100755 index 0000000..b3b549f --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/Makefile @@ -0,0 +1,9 @@ + +all: basic.so + +basic.so: + g++ -std=c++11 -shared -fPIC basic.cpp -o basic.so + +clean: + rm -f basic.so + diff --git a/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/basic.cpp b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/basic.cpp new file mode 100755 index 0000000..3683066 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/basic.cpp @@ -0,0 +1,19 @@ +#include + +#if defined(__linux__) || defined(__APPLE__) +#define EXPORT_FUNC +#define CDECL +#else +#define EXPORT_FUNC __declspec(dllexport) +#define CDECL __cdecl +#endif + +extern "C" EXPORT_FUNC void CDECL pixel(int x, int y, unsigned char *rgb) { + rgb[0] = rgb[1] = rgb[2] = 0; +} + +extern "C" EXPORT_FUNC void CDECL complete() { + +} + + diff --git a/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/basic.so b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/basic.so new file mode 100755 index 0000000..c865125 Binary files /dev/null and b/windows/Acid.Cam.Qt.Windows.Project/plugins/basic/basic.so differ diff --git a/windows/Acid.Cam.Qt.Windows.Project/qresource.qrc b/windows/Acid.Cam.Qt.Windows.Project/qresource.qrc new file mode 100755 index 0000000..4034009 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/qresource.qrc @@ -0,0 +1,5 @@ + + +images/icon.png + + diff --git a/windows/Acid.Cam.Qt.Windows.Project/qtheaders.h b/windows/Acid.Cam.Qt.Windows.Project/qtheaders.h new file mode 100755 index 0000000..1c5e429 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/qtheaders.h @@ -0,0 +1,62 @@ +/* + * Acid Cam v2 - Qt/OpenCV Edition + * written by Jared Bruni ( http://lostsidedead.com ) + * (C) 2017 GPL +*/ + +#ifndef _QT_HEADERS__ +#define _QT_HEADERS__ +#define ac_version "v1.19.1" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include"ac.h" +#include"fractal.h" +#include +#include +#include +#include + +struct FilterValue { + int index, filter, subfilter; + FilterValue() : index(0), filter(0), subfilter(-1) {} + FilterValue(int i, int f, int s) : index(i), filter(f), subfilter(s) {} + FilterValue &operator=(const FilterValue &v) { + index = v.index; + filter = v.filter; + subfilter = v.subfilter; + return *this; + } +}; +void init_plugins(); +void draw_plugin(cv::Mat &frame, int filter); +extern std::unordered_map filter_map; + +#endif diff --git a/windows/Acid.Cam.Qt.Windows.Project/search_box.cpp b/windows/Acid.Cam.Qt.Windows.Project/search_box.cpp new file mode 100755 index 0000000..7c6400b --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/search_box.cpp @@ -0,0 +1,90 @@ +#include"search_box.h" +#include"tokenize.h" + +std::string lowerString(std::string text) { + std::string new_text; + for(unsigned long i = 0; i < text.length(); ++i) + new_text += tolower(text[i]); + return new_text; +} + +SearchWindow::SearchWindow(QWidget *parent) : QDialog(parent) { + setFixedSize(640, 480); + setWindowTitle(tr("Search Filters")); + setWindowIcon(QPixmap(":/images/icon.png")); + createControls(); +} + + +void SearchWindow::createControls() { + search_list = new QListWidget(this); + search_list->setGeometry(25, 25, 595, 400); + search_list->show(); + search_text = new QLineEdit(this); + search_text->setGeometry(25, 430, 290, 30); + search_text->show(); + search = new QPushButton(this); + search->setGeometry(325, 430, 100, 30); + search->setText(tr("Search")); + subf = new QPushButton(this); + subf->setGeometry(490+25+10,430, 100, 30); + subf->setText(tr("SubFilter")); + add = new QPushButton(this); + add->setText(tr("Add")); + add->setGeometry((490+25+10)-100, 430, 100, 30); + connect(search, SIGNAL(pressed()), this, SLOT(search_filter())); + connect(add, SIGNAL(pressed()), this, SLOT(add_current())); + connect(subf, SIGNAL(pressed()), this, SLOT(set_subf())); +} + +void SearchWindow::search_filter() { + + while(search_list->count() > 0) { + search_list->takeItem(0); + } + + std::string search = lowerString(search_text->text().toStdString()); + std::vector tokens; + token::tokenize(search, std::string(" "), tokens); + + for(int i = 0; i < filters->count(); ++i) { + std::string search_items = lowerString(filters->itemText(i).toStdString()); + for(unsigned q = 0; q < tokens.size(); ++q) { + if(search_items.find(tokens[q]) != std::string::npos) { + search_list->addItem(filters->itemText(i)); + } + } + } +} + +void SearchWindow::add_current() { + int index = search_list->currentRow(); + if(index >= 0) { + QListWidgetItem *in = search_list->item(index); + custom_list->addItem(in->text()); + main_window->updateList(); + std::string text = in->text().toStdString(); + if(blend_set == false && text.find("Image") != std::string::npos) + main_window->Log(tr("Set an Image to use this filter\n")); + else if(text.find("SubFilter") != std::string::npos) + main_window->Log(tr("Set a SubFilter to use this filter\n")); + QString qtext; + QTextStream stream(&qtext); + stream << "Filter set to: " << in->text() << "\n"; + main_window->Log(qtext); + } +} + +void SearchWindow::setFiltersControl(QComboBox *filter_box, QListWidget *custombox) { + filters = filter_box; + custom_list = custombox; +} + +void SearchWindow::set_subf() { + int index = search_list->currentRow(); + if(index >= 0) { + QListWidgetItem *in = search_list->item(index); + main_window->setSubFilter(in->text()); + main_window->updateList(); + } +} diff --git a/windows/Acid.Cam.Qt.Windows.Project/search_box.h b/windows/Acid.Cam.Qt.Windows.Project/search_box.h new file mode 100755 index 0000000..3b0f2c4 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/search_box.h @@ -0,0 +1,27 @@ + +#ifndef __SEARCHBOX__H__ +#define __SEARCHBOX__H__ + +#include "qtheaders.h" +#include "main_window.h" + +class SearchWindow : public QDialog { + Q_OBJECT +public: + AC_MainWindow *main_window; + SearchWindow(QWidget *parent = 0); + void createControls(); + void setFiltersControl(QComboBox *filter_box, QListWidget *custom); +public slots: + void search_filter(); + void add_current(); + void set_subf(); +private: + QListWidget *search_list,*custom_list; + QLineEdit *search_text; + QPushButton *search, *add, *subf; + QComboBox *filters; +}; + +#endif + diff --git a/windows/Acid.Cam.Qt.Windows.Project/select_image.cpp b/windows/Acid.Cam.Qt.Windows.Project/select_image.cpp new file mode 100755 index 0000000..eae9f23 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/select_image.cpp @@ -0,0 +1 @@ +#include "select_image.h" diff --git a/windows/Acid.Cam.Qt.Windows.Project/select_image.h b/windows/Acid.Cam.Qt.Windows.Project/select_image.h new file mode 100755 index 0000000..2bb3b90 --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/select_image.h @@ -0,0 +1,6 @@ +#ifndef __SELECT_IMAGE__ +#define __SELECT_IMAGE__ + +#include "qtheaders.h" + +#endif diff --git a/windows/Acid.Cam.Qt.Windows.Project/tokenize.h b/windows/Acid.Cam.Qt.Windows.Project/tokenize.h new file mode 100755 index 0000000..9758a3c --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/tokenize.h @@ -0,0 +1,111 @@ +/* Acid Cam Functions for OpenCV + * written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute as long + as you do not charge anything for this program. This program is 100% + Free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + +#ifndef __TOKENIZE_H__ +#define __TOKENIZE_H__ + +#include +#include +#include + +namespace token { + + template + type substr(type t, size_t start, size_t stop) { + type temp; + for(size_t i = start; i < stop; i++) + temp += t[i]; + return temp; + } + + template<> char* substr(char *t, size_t start, size_t stop) { + char *temp = new char [ stop-start+1 ]; + size_t pos = 0; + for(size_t i = start; i < stop; i++) + temp[pos++] = t[i]; + temp[pos] = 0; + return temp; + } + + template + size_t len(type &t) { + size_t c = 0; + for(c = 0; t[c] != 0; c++); + return c; + } + + template + size_t find(size_t start, type& source, type& sub) { + for(size_t i = start; source[i] != 0; i++) { + bool add = true; + for(size_t z = 0; sub[z] != 0; z++) { + if(source[i+z] != sub[z]) { + add = false; + break; + } + } + if(add == true) + return i; + } + return 0; + } + + template + size_t tokenize(type source, type delim, std::vector &v) { + size_t i = find(0,source,delim),z=0; + if(i == 0) i = find(i+1, source,delim); + size_t lenz = len(source), dlen = len(delim); + while (i != 0 && i < lenz && z < lenz ) { + type s = substr(source,z,i); + if(len(s) > 0 && s[0] != delim[0]) + v.push_back(s); + z = i+dlen; + i = find(i+1, source, delim); + } + if( z < lenz ) v.push_back( substr(source,z,lenz) ); + return v.size(); + } +} + +#endif + diff --git a/windows/Acid.Cam.Qt.Windows.Project/tokenize.hpp b/windows/Acid.Cam.Qt.Windows.Project/tokenize.hpp new file mode 100755 index 0000000..9758a3c --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/tokenize.hpp @@ -0,0 +1,111 @@ +/* Acid Cam Functions for OpenCV + * written by Jared Bruni https://github.com/lostjared + + This software is dedicated to all the people that struggle with mental illness. + + Website: http://lostsidedead.com + YouTube: http://youtube.com/LostSideDead + Instagram: http://instagram.com/jaredbruni + Twitter: http://twitter.com/jaredbruni + Facebook: http://facebook.com/LostSideDead0x + + You can use this program free of charge and redistrubute as long + as you do not charge anything for this program. This program is 100% + Free. + + BSD 2-Clause License + + Copyright (c) 2018, Jared Bruni + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + +#ifndef __TOKENIZE_H__ +#define __TOKENIZE_H__ + +#include +#include +#include + +namespace token { + + template + type substr(type t, size_t start, size_t stop) { + type temp; + for(size_t i = start; i < stop; i++) + temp += t[i]; + return temp; + } + + template<> char* substr(char *t, size_t start, size_t stop) { + char *temp = new char [ stop-start+1 ]; + size_t pos = 0; + for(size_t i = start; i < stop; i++) + temp[pos++] = t[i]; + temp[pos] = 0; + return temp; + } + + template + size_t len(type &t) { + size_t c = 0; + for(c = 0; t[c] != 0; c++); + return c; + } + + template + size_t find(size_t start, type& source, type& sub) { + for(size_t i = start; source[i] != 0; i++) { + bool add = true; + for(size_t z = 0; sub[z] != 0; z++) { + if(source[i+z] != sub[z]) { + add = false; + break; + } + } + if(add == true) + return i; + } + return 0; + } + + template + size_t tokenize(type source, type delim, std::vector &v) { + size_t i = find(0,source,delim),z=0; + if(i == 0) i = find(i+1, source,delim); + size_t lenz = len(source), dlen = len(delim); + while (i != 0 && i < lenz && z < lenz ) { + type s = substr(source,z,i); + if(len(s) > 0 && s[0] != delim[0]) + v.push_back(s); + z = i+dlen; + i = find(i+1, source, delim); + } + if( z < lenz ) v.push_back( substr(source,z,lenz) ); + return v.size(); + } +} + +#endif + diff --git a/windows/Acid.Cam.Qt.Windows.Project/win-icon.ico b/windows/Acid.Cam.Qt.Windows.Project/win-icon.ico new file mode 100755 index 0000000..ab39b95 Binary files /dev/null and b/windows/Acid.Cam.Qt.Windows.Project/win-icon.ico differ diff --git a/windows/Acid.Cam.Qt.Windows.Project/win-icon.rc b/windows/Acid.Cam.Qt.Windows.Project/win-icon.rc new file mode 100755 index 0000000..c29cbcd --- /dev/null +++ b/windows/Acid.Cam.Qt.Windows.Project/win-icon.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON DISCARDABLE "win-icon.ico" diff --git a/windows/README.md b/windows/README.md index 2895248..fe731f0 100644 --- a/windows/README.md +++ b/windows/README.md @@ -1,15 +1,2 @@ - -# Example pro file for Windows - -# updated @ Sun Jun 3 14:58:17 PDT 2018 - -Replace the hardcoded paths with the ones you have for your current version of OpenCV compiled with Visual Studio. -Copy this pro into a new directory with the source files and qrc file. - -Also copy the source files (.cpp .h) from libacidcam into the directory as well they can be found here: - -https://github.com/lostjared/libacidcam/tree/master/source - -Using Qt Creator call qmake on the file and it will build Makefiles for Visual Studio. - +This folder contains the project files for the Windows version of Acid Cam.It requires you have OpenCV/Qt5 installed and you will need to edit the .pro file with the path to the OpenCV C++ Libraries.