This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ImageOperator::flip_h(const unsigned char* input, | |
const int width, | |
const int height, | |
const int channel, | |
unsigned char*& output){ | |
for (int row = 0; row < height; ++row) { | |
for (int col = 0; col < width * channel; col += 1) { | |
output[row*width+col]=input[(height-row)*width+col]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ImageOperator::rotate(const unsigned char* input, | |
const int width, | |
const int height, | |
const int channel, | |
unsigned char*& output){ | |
unsigned char* tmp = new unsigned char[width*height*channel]; | |
int step = channel*width; | |
for (int row = 0; row < height; ++row) { | |
for (int col = 0; col < width*channel; col+=channel) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ImageOperator::rotate(const unsigned char* input, | |
const int width, | |
const int height, | |
const int channel, | |
unsigned char*& output){ | |
unsigned char* tmp = new unsigned char[width*height*channel]; | |
for (int row = 0; row < height; ++row) { | |
for (int col = 0; col < width; col+=1) { | |
tmp[col*width+width-1-row] = input[row*width+col]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() { | |
cv::VideoCapture cam(0); | |
if (!cam.isOpened()) { | |
throw std::runtime_error("Error"); | |
} | |
cv::namedWindow("Window"); | |
while(true){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ImageOperator::rotate(const unsigned char* input, | |
const int width, | |
const int height, | |
const int channel, | |
unsigned char* output){ | |
for (int row = 0; row < height; ++row) { | |
for (int col = 0; col < width; col+=1) { | |
output[col*width+width-1-row] = input[row*width+col]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include "opencv2/opencv.hpp" | |
int main() { | |
cv::VideoCapture cam(0); | |
if (!cam.isOpened()) { | |
throw std::runtime_error("Error"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ImageOperator::to_gray(const unsigned char* bgr_input, | |
const int width, | |
const int height, | |
const int channel, | |
unsigned char* gray_output){ | |
int index = 0; | |
int step = channel*width; | |
for (int row = 0; row < height; ++row) { | |
for (int col = 0; col < width*channel; col+=channel) { | |
gray_output[index] = 0.11*bgr_input[row*step+col]+ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ImageOperator::to_gray_m3(const cv::Mat &input, cv::Mat &output) { | |
unsigned char *data_in = (unsigned char*)(input.data); | |
unsigned char *data_out = (unsigned char*)(output.data); | |
int index = 0; | |
for (int row = 0; row < input.rows; ++row) { | |
for (int col = 0; col < input.cols*input.channels(); col+=input.channels()) { | |
data_out[index]= 0.11*data_in[row*input.step+col]+ | |
0.59*data_in[row*input.step+col+1]+ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ImageOperator::to_gray_m2(const cv::Mat &input, cv::Mat &output) { | |
unsigned char *data_in = (unsigned char*)(input.data); | |
unsigned char *data_out = (unsigned char*)(output.data); | |
int index = 0; | |
int byte_size = input.channels()*input.rows*input.cols; | |
while(index!=byte_size){ | |
data_out[index/input.channels()] = unsigned(0.11*data_in[index]+0.59*data_in[index+1]+0.3*data_in[index+2]); | |
index+=3; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ImageOperator::to_gray_m1(const cv::Mat &input, cv::Mat &output) { | |
unsigned char *data_out = (unsigned char*)(output.data); | |
int ind = 0; | |
auto end = input.end<cv::Vec3b>(); | |
cv::MatConstIterator_<cv::Vec3b> it = input.begin<cv::Vec3b>(); | |
for (; it != end; ++it) { | |
const unsigned char &r = (*it)[2]; | |
const unsigned char &g = (*it)[1]; | |
const unsigned char &b = (*it)[0]; |
NewerOlder