Skip to content

Commit

Permalink
updated added colormap to ac.h/ac.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
lostjared committed Mar 5, 2018
1 parent 7f935af commit 70307c1
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 17 deletions.
Binary file not shown.
1 change: 1 addition & 0 deletions Acid.Cam.v2.OSX/AC_Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ extern bool resize_value;
- (IBAction) changeVideoPos: (id) sender;
- (NSRect) getScreenSize;
- (IBAction) setStretch: (id) sender;
- (IBAction) setColorMap: (id) sender;
@end

// global variables / functions
Expand Down
27 changes: 10 additions & 17 deletions Acid.Cam.v2.OSX/AC_Controller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -623,10 +623,11 @@ - (void) camThread: (id) sender {
ac::color_order = (int) [corder indexOfSelectedItem];
}
});

if(disableFilter == false) ac::draw_func[ac::draw_offset](frame);
ac::ApplyColorMap(frame);

dispatch_sync(dispatch_get_main_queue(), ^{
NSInteger cmap_index = 0;
if([corder indexOfSelectedItem] == 5) {
cv::Mat change;
cv::cvtColor(frame, change, cv::COLOR_BGR2GRAY);
Expand All @@ -646,11 +647,6 @@ - (void) camThread: (id) sender {
rc = [main_w frame];
}
}
cmap_index = [color_map indexOfSelectedItem];
if(cmap_index > 0 && cmap_index < 13) {
cv::Mat output_f1 = frame.clone();
cv::applyColorMap(output_f1, frame, (int)cmap_index-1);
}
if([stretch_scr state] == NSOnState) {
cv::Mat dst;
dst = resizeKeepAspectRatio(frame, cv::Size(rc.size.width, rc.size.height), cv::Scalar(0,0,0));
Expand Down Expand Up @@ -777,9 +773,8 @@ - (void) cvProc: (id) sender {
else ac::isNegative = true;
ac::color_order = (int) [corder indexOfSelectedItem];
}
if(disableFilter == false) ac::draw_func[ac::draw_offset](frame);


if(disableFilter == false) ac::draw_func[ac::draw_offset](frame);
if([menu_freeze state] == NSOffState) {
++frame_cnt;
++frame_proc;
Expand All @@ -792,15 +787,8 @@ - (void) cvProc: (id) sender {
cv::cvtColor(change, frame, cv::COLOR_GRAY2BGR);
}

NSInteger cmap_index = [color_map indexOfSelectedItem];
if(cmap_index > 0 && cmap_index < 13) {
cv::Mat output;
//cv::applyColorMap(frame, output, cv::COLORMAP_JET);
cv::applyColorMap(frame, output, (int)cmap_index-1);
frame = output;
}


ac::ApplyColorMap(frame);

NSInteger mask = [[NSApp mainWindow] styleMask];
NSString *main_window = [[NSApp mainWindow] title];
NSWindow *main_w = [NSApp mainWindow];
Expand Down Expand Up @@ -1206,6 +1194,11 @@ - (IBAction) setStretch: (id) sender {
}
}

- (IBAction) setColorMap: (id) sender {
NSInteger index = [color_map indexOfSelectedItem];
ac::set_color_map = (int) index;
}

@end

void custom_filter(cv::Mat &frame) {
Expand Down
25 changes: 25 additions & 0 deletions Acid.Cam.v2.OSX/ac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
#include "ac.h"
#include "fractal.h"



// Acid Cam namespace
namespace ac {
const std::string version="2.3.3";
Expand All @@ -55,6 +57,7 @@ namespace ac {
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];
Expand Down Expand Up @@ -5263,6 +5266,21 @@ void ac::IncreaseBlendHorizontal(cv::Mat &frame) {
Pass2Blend(frame);
}

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);

unsigned int w = frame.cols;
unsigned int h = frame.rows;
for(unsigned int z = 0; z < h; ++z) {
for(unsigned int i = 0; i < w; ++i) {
ac::swapColors(frame, z, i);
if(isNegative) ac::invert(frame, z, i);
}
}
}
}
// No Filter
void ac::NoFilter(cv::Mat &) {}

Expand All @@ -5274,4 +5292,11 @@ void ac::BlendWithSource(cv::Mat &frame) {
// call custom fitler defined elsewhere
void ac::custom(cv::Mat &frame) {
custom_filter(frame);

}






4 changes: 4 additions & 0 deletions Acid.Cam.v2.OSX/ac.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ namespace ac {
extern int snapshot_Type;
extern bool in_custom;
extern unsigned int swapColor_r, swapColor_g, swapColor_b;
extern int set_color_map;
inline int GetFX(cv::Mat &frame, int x, int nw);
inline int GetFY(cv::Mat &frame, int y, int nh);
inline void invert(cv::Mat &frame, int x, int y);
Expand Down Expand Up @@ -283,6 +284,9 @@ namespace ac {
void NoFilter(cv::Mat &frame);
void BlendWithSource(cv::Mat &frame);
void plugin(cv::Mat &frame);

// color maps
void ApplyColorMap(cv::Mat &frame);
// draw functions / strings
extern std::string draw_strings[];
extern DrawFunction draw_func[];
Expand Down
3 changes: 3 additions & 0 deletions Acid.Cam.v2.OSX/en.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,9 @@
</items>
</menu>
</popUpButtonCell>
<connections>
<action selector="setColorMap:" target="630" id="kSl-ba-oXY"/>
</connections>
</popUpButton>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6cT-Lh-fql">
<rect key="frame" x="481" y="12" width="67" height="17"/>
Expand Down

0 comments on commit 70307c1

Please sign in to comment.