本网页所有文字内容由 imapbox邮箱云存储,邮箱网盘, iurlBox网页地址收藏管理器 下载并得到。
ImapBox 邮箱网盘 工具地址: https://www.imapbox.com/download/ImapBox.5.5.1_Build20141205_CHS_Bit32.exe
PC6下载站地址:PC6下载站分流下载
本网页所有视频内容由 imoviebox边看边下-网页视频下载, iurlBox网页地址收藏管理器 下载并得到。
ImovieBox 网页视频 工具地址: https://www.imapbox.com/download/ImovieBox4.7.0_Build20141115_CHS.exe
本文章由: imapbox邮箱云存储,邮箱网盘,ImageBox 图片批量下载器,网页图片批量下载专家,网页图片批量下载器,获取到文章图片,imoviebox网页视频批量下载器,下载视频内容,为您提供.
代码为转载,出处找不到了,不贴了 工具条进度条: 效果: 图像裁切代码: 裁切效果: // ConvertColor.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #pragma comment(lib,"opencv_core2410d.lib") #pragma comment(lib,"opencv_highgui2410d.lib") #pragma comment(lib,"opencv_imgproc2410d.lib") using namespace std; using namespace cv; // Global variables const int slider_max = 100; int slider; Mat img; // Callback function for trackbar event void on_trackbar(int pos, void *) { Mat img_converted; if(pos > 0) cvtColor(img, img_converted, CV_RGB2GRAY); else img_converted = img; imshow("Trackbar app", img_converted); } int main() { img = imread("swan.jpg"); namedWindow("Trackbar app"); imshow("Trackbar app", img); slider = 0; createTrackbar("RGB <-> Grayscale", "Trackbar app", &slider, slider_max, on_trackbar); while(char(waitKey(1)) != 'q') {} return 0; }
// ConvertColor.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #pragma comment(lib,"opencv_core2410d.lib") #pragma comment(lib,"opencv_highgui2410d.lib") #pragma comment(lib,"opencv_imgproc2410d.lib") using namespace std; using namespace cv; // Global variables // Flags updated according to left mouse button activity bool ldown = false, lup = false; // Original image Mat img; // Starting and ending points of the user's selection Point corner1, corner2; // ROI Rect box; // Callback function for mouse events static void mouse_callback(int event, int x, int y, int, void *) { // When the left mouse button is pressed, record its position and save it in corner1 if(event == EVENT_LBUTTONDOWN) { ldown = true; corner1.x = x; corner1.y = y; cout << "Corner 1 recorded at " << corner1 << endl; } // When the left mouse button is released, record its position and save it in corner2 if(event == EVENT_LBUTTONUP) { // Also check if user selection is bigger than 20 pixels (jut for fun!) if(abs(x - corner1.x) > 20 && abs(y - corner1.y) > 20) { lup = true; corner2.x = x; corner2.y = y; cout << "Corner 2 recorded at " << corner2 << endl << endl; } else { cout << "Please select a bigger region" << endl; ldown = false; } } // Update the box showing the selected region as the user drags the mouse if(ldown == true && lup == false) { Point pt; pt.x = x; pt.y = y; Mat local_img = img.clone(); rectangle(local_img, corner1, pt, Scalar(0, 0, 255)); imshow("Cropping app", local_img); } // Define ROI and crop it out when both corners have been selected if(ldown == true && lup == true) { box.width = abs(corner1.x - corner2.x); box.height = abs(corner1.y - corner2.y); box.x = min(corner1.x, corner2.x); box.y = min(corner1.y, corner2.y); // Make an image out of just the selected ROI and display it in a new window Mat crop(img, box); namedWindow("Crop"); imshow("Crop", crop); ldown = false; lup = false; } } int main() { img = imread("swan.jpg"); namedWindow("Cropping app"); imshow("Cropping app", img); // Set the mouse event callback function setMouseCallback("Cropping app", mouse_callback); // Exit by pressing 'q' while(char(waitKey(1)) != 'q') {} return 0; }
阅读和此文章类似的: 程序员专区