#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <stdlib.h>
#include <stdio.h>
using namespace cv;
/// Global Variables
Mat frame, dst;
int top, bottom, left, right;
Scalar value;
RNG rng(0xfffffff);
/** @function main */
int main(int argc, char** argv)
{
int c;
VideoCapture cap(0);
while (1)
{
cap >> frame;
/// Create window
namedWindow("original picture", CV_WINDOW_AUTOSIZE);
imshow("original picture", frame);
/// Initialize arguments for the filter
top = (int)( 0.1 * frame.cols); //(int)(0.1*image.rows);
bottom = (int)(0.1*frame.cols);
left = (int)(0.1*frame.cols);
right = (int)(0.1*frame.cols);
dst = frame;
//random color
value = Scalar(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));
copyMakeBorder(frame, dst, top, bottom, left, right, BORDER_CONSTANT, value);
namedWindow("copyMakeBorder Demo", CV_WINDOW_AUTOSIZE);
imshow("copyMakeBorder Demo", dst);
if (waitKey(30) == 27)
break;
}
return 0;
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น