diff --git a/Gtkmm3/gtk134_editor4/src/TextEditor.cc b/Gtkmm3/gtk134_editor4/src/TextEditor.cc index 2ad1386..64bd8e9 100644 --- a/Gtkmm3/gtk134_editor4/src/TextEditor.cc +++ b/Gtkmm3/gtk134_editor4/src/TextEditor.cc @@ -1,6 +1,7 @@ #include "TextEditor.hh" #include "text_types.hh" #include +#include // Only for build in this repository #define text_globs supported_globs @@ -215,12 +216,15 @@ void TextEditor::search_entry_changed() Gtk::TextIter start, end; // If get text to search, select the text and storage the position - if (buffer1->begin().forward_search(text, Gtk::TEXT_SEARCH_CASE_INSENSITIVE, start, end)) + if (text.length() != 0) { - curr_iter_up = start; - curr_iter_down = end; - buffer1->select_range(start, end); - textview1.scroll_to(start); + if (buffer1->begin().forward_search(text, Gtk::TEXT_SEARCH_CASE_INSENSITIVE, start, end)) + { + curr_iter_up = start; + curr_iter_down = end; + buffer1->select_range(start, end); + textview1.scroll_to(start); + } } } @@ -231,12 +235,15 @@ void TextEditor::search_forward() Gtk::TextIter start, end; // Get Text to search, down to the end of text - if (curr_iter_down.forward_search(search_text, Gtk::TEXT_SEARCH_CASE_INSENSITIVE, start, end)) + if (search_text.length() != 0) { - curr_iter_up = start; - curr_iter_down = end; - buffer1->select_range(start, end); - textview1.scroll_to(start); + if (curr_iter_down.forward_search(search_text, Gtk::TEXT_SEARCH_CASE_INSENSITIVE, start, end)) + { + curr_iter_up = start; + curr_iter_down = end; + buffer1->select_range(start, end); + textview1.scroll_to(start); + } } } @@ -247,12 +254,15 @@ void TextEditor::search_backward() Gtk::TextIter start, end; // Get Text to search - if (curr_iter_up.backward_search(search_text, Gtk::TEXT_SEARCH_CASE_INSENSITIVE, start, end)) + if (search_text.length() != 0) { - curr_iter_up = start; - curr_iter_down = end; - buffer1->select_range(start, end); - textview1.scroll_to(start); + if (curr_iter_up.backward_search(search_text, Gtk::TEXT_SEARCH_CASE_INSENSITIVE, start, end)) + { + curr_iter_up = start; + curr_iter_down = end; + buffer1->select_range(start, end); + textview1.scroll_to(start); + } } } @@ -313,7 +323,8 @@ void TextEditor::infobar_response(int response) infobar.hide(); } -void TextEditor::about_activated(){ +void TextEditor::about_activated() +{ char *version, *copyright; // The Gtkmm Version 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, "logo-icon-name", "org.gtk.daleclack", "title", "About Simple text editor", - NULL); + (char *)NULL); // Free memory g_free(version); g_free(copyright); diff --git a/OpenCV_test/test3_imageobject/main.cpp b/OpenCV_test/test3_imageobject/main.cpp index a38a2f5..4f48cf9 100644 --- a/OpenCV_test/test3_imageobject/main.cpp +++ b/OpenCV_test/test3_imageobject/main.cpp @@ -4,33 +4,17 @@ using namespace cv; 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; - std::cout << "Save gray and hsv images? (Y/N)"; - std::cin >> save_images; - - // Open the image - 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); + // Create windows + namedWindow("image1", WINDOW_AUTOSIZE); + namedWindow("image2", WINDOW_AUTOSIZE); + imshow("image1", image); + imshow("image2", image2); waitKey(0); destroyAllWindows(); diff --git a/OpenCV_test/test4_display/.vscode/settings.json b/OpenCV_test/test4_display/.vscode/settings.json new file mode 100644 index 0000000..b4d8c35 --- /dev/null +++ b/OpenCV_test/test4_display/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools" +} \ No newline at end of file diff --git a/OpenCV_test/test4_display/CMakeLists.txt b/OpenCV_test/test4_display/CMakeLists.txt new file mode 100644 index 0000000..7b81e9e --- /dev/null +++ b/OpenCV_test/test4_display/CMakeLists.txt @@ -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}) diff --git a/OpenCV_test/test4_display/main.cpp b/OpenCV_test/test4_display/main.cpp new file mode 100644 index 0000000..fd5f890 --- /dev/null +++ b/OpenCV_test/test4_display/main.cpp @@ -0,0 +1,41 @@ +#include +#include + +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; +}