Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

Commit

Permalink
Added hpp file, minor style fixes, deleted output files
Browse files Browse the repository at this point in the history
  • Loading branch information
CihanBosnali committed Jan 10, 2024
1 parent 91ce49c commit ca4b3d4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 20 deletions.
9 changes: 9 additions & 0 deletions include/webcamPlantDetection.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef WEBCAMPLANTDETECTION_HPP
#define WEBCAMPLANTDETECTION_HPP

#include <opencv2/opencv.hpp>
using namespace cv;

Mat isGreen(const Mat& image);

#endif
Binary file removed src/WebcamPlantDetection/my_program
Binary file not shown.
Binary file removed src/WebcamPlantDetection/output
Binary file not shown.
9 changes: 9 additions & 0 deletions src/WebcamPlantDetection/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
GENERATED_OBJS := webcamPlantDetection.o

include submodule.general.mk

build_$(DIR):
$(call build,webcamPlantDetection.cpp)
clean_$(DIR):
test_$(DIR):
@echo testing the module $(DIR)!
29 changes: 9 additions & 20 deletions src/WebcamPlantDetection/webcamPlantDetection.cpp
Original file line number Diff line number Diff line change
@@ -1,44 +1,33 @@
#include<opencv2/opencv.hpp>
#include<iostream>
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
using namespace cv;

Mat isGreen(const Mat& image) {
Mat hsvImage;
cvtColor(image, hsvImage, COLOR_RGB2HSV);

Mat mask;
Scalar lower(35, 60, 60);
Scalar upper(80, 255, 255);

Mat mask;
cvtColor(image, hsvImage, COLOR_RGB2HSV);
inRange(hsvImage, lower, upper, mask);
return mask;
}

int main() {
int test_isGreen() {
Mat myImage;
namedWindow("Video Player");
VideoCapture cap(0);

if (!cap.isOpened()) {
cout << "No video stream detected" << endl;
system("pause");
return-1;
}
if (!cap.isOpened())
return 5; // IO Error Code on Linux, Access Denied Error Code on Windows

while (true) {
cap >> myImage;
if (myImage.empty()) {
if (myImage.empty())
break;
}

Mat greenMask = isGreen(myImage);

imshow("Video Player", greenMask);
char c = (char)waitKey(25);
if (c == 27) {
if (c == 27)
break;
}
}
cap.release();
return 0;
Expand Down

0 comments on commit ca4b3d4

Please sign in to comment.