Add OpenCV test3 and test4
This commit is contained in:
parent
f8516efeab
commit
52d4c85dc9
|
@ -1,6 +1,7 @@
|
||||||
#include "TextEditor.hh"
|
#include "TextEditor.hh"
|
||||||
#include "text_types.hh"
|
#include "text_types.hh"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
// Only for build in this repository
|
// Only for build in this repository
|
||||||
#define text_globs supported_globs
|
#define text_globs supported_globs
|
||||||
|
@ -215,6 +216,8 @@ void TextEditor::search_entry_changed()
|
||||||
|
|
||||||
Gtk::TextIter start, end;
|
Gtk::TextIter start, end;
|
||||||
// If get text to search, select the text and storage the position
|
// If get text to search, select the text and storage the position
|
||||||
|
if (text.length() != 0)
|
||||||
|
{
|
||||||
if (buffer1->begin().forward_search(text, Gtk::TEXT_SEARCH_CASE_INSENSITIVE, start, end))
|
if (buffer1->begin().forward_search(text, Gtk::TEXT_SEARCH_CASE_INSENSITIVE, start, end))
|
||||||
{
|
{
|
||||||
curr_iter_up = start;
|
curr_iter_up = start;
|
||||||
|
@ -223,6 +226,7 @@ void TextEditor::search_entry_changed()
|
||||||
textview1.scroll_to(start);
|
textview1.scroll_to(start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TextEditor::search_forward()
|
void TextEditor::search_forward()
|
||||||
{
|
{
|
||||||
|
@ -231,6 +235,8 @@ void TextEditor::search_forward()
|
||||||
|
|
||||||
Gtk::TextIter start, end;
|
Gtk::TextIter start, end;
|
||||||
// Get Text to search, down to the end of text
|
// Get Text to search, down to the end of text
|
||||||
|
if (search_text.length() != 0)
|
||||||
|
{
|
||||||
if (curr_iter_down.forward_search(search_text, Gtk::TEXT_SEARCH_CASE_INSENSITIVE, start, end))
|
if (curr_iter_down.forward_search(search_text, Gtk::TEXT_SEARCH_CASE_INSENSITIVE, start, end))
|
||||||
{
|
{
|
||||||
curr_iter_up = start;
|
curr_iter_up = start;
|
||||||
|
@ -239,6 +245,7 @@ void TextEditor::search_forward()
|
||||||
textview1.scroll_to(start);
|
textview1.scroll_to(start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TextEditor::search_backward()
|
void TextEditor::search_backward()
|
||||||
{
|
{
|
||||||
|
@ -247,6 +254,8 @@ void TextEditor::search_backward()
|
||||||
|
|
||||||
Gtk::TextIter start, end;
|
Gtk::TextIter start, end;
|
||||||
// Get Text to search
|
// Get Text to search
|
||||||
|
if (search_text.length() != 0)
|
||||||
|
{
|
||||||
if (curr_iter_up.backward_search(search_text, Gtk::TEXT_SEARCH_CASE_INSENSITIVE, start, end))
|
if (curr_iter_up.backward_search(search_text, Gtk::TEXT_SEARCH_CASE_INSENSITIVE, start, end))
|
||||||
{
|
{
|
||||||
curr_iter_up = start;
|
curr_iter_up = start;
|
||||||
|
@ -255,6 +264,7 @@ void TextEditor::search_backward()
|
||||||
textview1.scroll_to(start);
|
textview1.scroll_to(start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TextEditor::btncopy_clicked()
|
void TextEditor::btncopy_clicked()
|
||||||
{
|
{
|
||||||
|
@ -313,7 +323,8 @@ void TextEditor::infobar_response(int response)
|
||||||
infobar.hide();
|
infobar.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditor::about_activated(){
|
void TextEditor::about_activated()
|
||||||
|
{
|
||||||
char *version, *copyright;
|
char *version, *copyright;
|
||||||
// The Gtkmm Version
|
// The Gtkmm Version
|
||||||
version = g_strdup_printf("1.0\nRunning Against Gtkmm %d.%d.%d",
|
version = g_strdup_printf("1.0\nRunning Against Gtkmm %d.%d.%d",
|
||||||
|
@ -333,7 +344,7 @@ void TextEditor::about_activated(){
|
||||||
"license-type", GTK_LICENSE_GPL_3_0,
|
"license-type", GTK_LICENSE_GPL_3_0,
|
||||||
"logo-icon-name", "org.gtk.daleclack",
|
"logo-icon-name", "org.gtk.daleclack",
|
||||||
"title", "About Simple text editor",
|
"title", "About Simple text editor",
|
||||||
NULL);
|
(char *)NULL);
|
||||||
// Free memory
|
// Free memory
|
||||||
g_free(version);
|
g_free(version);
|
||||||
g_free(copyright);
|
g_free(copyright);
|
||||||
|
|
|
@ -4,33 +4,17 @@
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
|
||||||
int main(int argc, char ** argv){
|
int main(int argc, char ** argv){
|
||||||
std::string filename, save_images;
|
// Create image objects
|
||||||
|
Mat image = Mat::zeros(Size(400,400), CV_8UC3);
|
||||||
|
image = Scalar(255, 0, 0);
|
||||||
|
Mat image2 = image.clone();
|
||||||
|
image2 = Scalar(0, 225, 0);
|
||||||
|
|
||||||
std::cin >> filename;
|
// Create windows
|
||||||
std::cout << "Save gray and hsv images? (Y/N)";
|
namedWindow("image1", WINDOW_AUTOSIZE);
|
||||||
std::cin >> save_images;
|
namedWindow("image2", WINDOW_AUTOSIZE);
|
||||||
|
imshow("image1", image);
|
||||||
// Open the image
|
imshow("image2", image2);
|
||||||
Mat image, image_hsv, image_gray;
|
|
||||||
image = imread(filename, IMREAD_COLOR);
|
|
||||||
if(image.empty()){
|
|
||||||
std::cout << "failed to open the image";
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
cvtColor(image, image_hsv, COLOR_BGR2HSV);
|
|
||||||
cvtColor(image, image_gray, COLOR_BGR2GRAY);
|
|
||||||
|
|
||||||
// Show the converted images
|
|
||||||
namedWindow("Original Image", WINDOW_FREERATIO);
|
|
||||||
imshow("Original Image", image);
|
|
||||||
namedWindow("HSV Image", WINDOW_FREERATIO);
|
|
||||||
imshow("HSV Image", image_hsv);
|
|
||||||
namedWindow("Gray Image", WINDOW_FREERATIO);
|
|
||||||
imshow("Gray Image", image_gray);
|
|
||||||
|
|
||||||
// Write the images
|
|
||||||
imwrite("image_gray.png", image_gray);
|
|
||||||
imwrite("image_hsv.png", image_hsv);
|
|
||||||
|
|
||||||
waitKey(0);
|
waitKey(0);
|
||||||
destroyAllWindows();
|
destroyAllWindows();
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
cmake_minimum_required(VERSION 3.0.0)
|
||||||
|
project(OpenCV_test3 VERSION 1.0.0)
|
||||||
|
|
||||||
|
#Find the opencv package
|
||||||
|
find_package(OpenCV REQUIRED)
|
||||||
|
|
||||||
|
#include directories for opencv
|
||||||
|
include_directories(${OpenCV_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
add_executable(${PROJECT_NAME} main.cpp)
|
||||||
|
|
||||||
|
#Add command to generate .gitignore
|
||||||
|
add_custom_command(TARGET ${PROJECT_NAME}
|
||||||
|
COMMAND echo \"*\" > ${CMAKE_BINARY_DIR}/.gitignore
|
||||||
|
COMMAND echo \"**/*\" > ${CMAKE_BINARY_DIR}/.hgignore)
|
||||||
|
|
||||||
|
#Add OpenCV Libraries
|
||||||
|
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
|
|
@ -0,0 +1,41 @@
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace cv;
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
// Create capture object to capture video
|
||||||
|
VideoCapture capture(0);
|
||||||
|
if (!capture.isOpened())
|
||||||
|
{
|
||||||
|
std::cout << "Can't open video device!" << std::endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// properties
|
||||||
|
double rate = capture.get(CAP_PROP_FPS);
|
||||||
|
double width = capture.get(CAP_PROP_FRAME_WIDTH);
|
||||||
|
double height = capture.get(CAP_PROP_FRAME_HEIGHT);
|
||||||
|
|
||||||
|
// Information about the camera
|
||||||
|
std::cout << "Frame Rate = " << rate << "width = " << width << "height = " << height << std::endl;
|
||||||
|
|
||||||
|
namedWindow("Video Capture", WINDOW_NORMAL);
|
||||||
|
|
||||||
|
Mat frame;
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
if (!capture.read(frame))
|
||||||
|
{
|
||||||
|
std::cout << "no video frame" << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
imshow("Video Capture", frame);
|
||||||
|
waitKey(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
capture.release();
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue