iorodeo avatar iorodeo committed 8f7d626

Re-arranged project.

Comments (0)

Files changed (14)

 option(with_qt_gui  "include image acquisition GUI"   ON ) 
 option(with_fc2     "include the FlyCapture2 backend" ON )
 option(with_dc1394  "include the libdc1394 backend"   OFF)
+option(with_demos   "include demos" ON)
+option(with_tests   "include tests" ON)
 
 message(STATUS "Option: with_fc2     = ${with_fc2}")
 message(STATUS "Option: with_dc1394  = ${with_dc1394}")
 message(STATUS "Option: with_qt_gui  = ${with_qt_gui}")
+message(STATUS "Option: with_demos   = ${with_demos}")
+message(STATUS "Option: with_tests   = ${with_tests}") 
 
 if( NOT( with_fc2 OR with_dc1394 ) )
     message(FATAL_ERROR "their must be at least one camera backend")
 else()
     message(STATUS "OpenCv not found")
 endif()
-message(STATUS "OpenCV_INCLUDE_DIRS = ${OpenCV_INCLUDE_DIRS}") 
 
 
 # FlyCapture2 library location - replace this this custom find_package
 endif() 
 
 add_subdirectory("src/facade")
-add_subdirectory("src/test")
 
 if(with_qt_gui)
     add_subdirectory("src/gui")
 endif()
 
+if (with_demos)
+    add_subdirectory("src/demo/blob_finder")
+endif()
+
+if (with_tests)
+    add_subdirectory("src/test")
+endif()
+

src/demo/blob_finder/CMakeLists.txt

+cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
+
+project(blob_finder)
+add_executable(blob_finder blob_finder_main.cpp blob_finder.cpp)
+target_link_libraries(blob_finder ${bias_ext_link_LIBS} bias_camera_facade)
+
+
+

src/demo/blob_finder/blob_finder.cpp

+#include "blob_finder.hpp"
+#include "camera_facade.hpp"
+#include <iostream>
+#include <vector>
+#include <opencv2/core/core.hpp>
+#include <opencv2/highgui/highgui.hpp>
+#include <opencv2/imgproc/imgproc.hpp>
+
+const float BlobFinder::DEFAULT_FRAMERATE = 10.0;
+const float BlobFinder::DEFAULT_DISPLAY_SCALE = 0.5;
+const double BlobFinder::DEFAULT_THRESHOLD = 100.0;
+const double BlobFinder::DEFAULT_MINIMUM_AREA = 50.0;
+const double BlobFinder::DEFAULT_MAXIMUM_AREA = 640.0*480.0;
+const double BlobFinder::THRESHOLD_MAXVAL = 255.0;
+
+
+BlobFinder::BlobFinder()
+{
+    frameRate_ = DEFAULT_FRAMERATE;
+    displayScale_ = DEFAULT_DISPLAY_SCALE;
+    threshold_ = DEFAULT_THRESHOLD;
+    minimumArea_ = DEFAULT_MINIMUM_AREA;
+    maximumArea_ = DEFAULT_MAXIMUM_AREA; 
+}
+
+
+BlobFinder::BlobFinder(float frameRate) : BlobFinder()
+{
+    frameRate_ = frameRate;
+}
+
+
+bool BlobFinder::run()
+{
+    bool success = true;
+
+    std::cout << std::endl;
+    std::cout << "* finding blobs - press 'x' to exit" << std::endl;
+
+    success = startCapture();
+    if (!success)
+    {
+        return false;
+    }
+    std::cout << std::endl;
+
+    cv::namedWindow("Raw Image", CV_WINDOW_AUTOSIZE | CV_WINDOW_KEEPRATIO | CV_GUI_EXPANDED);
+    cv::namedWindow("Threshold Image", CV_WINDOW_AUTOSIZE | CV_WINDOW_KEEPRATIO | CV_GUI_EXPANDED); 
+    cv::namedWindow("Contour Image", CV_WINDOW_AUTOSIZE | CV_WINDOW_KEEPRATIO | CV_GUI_EXPANDED); 
+
+    unsigned long cnt = 0;
+
+    while (true)
+    {
+        cv::Mat image;
+        cv::Mat imageTemp;
+        cv::Mat imageThresh;
+        cv::Mat imageContour;
+        std::vector<std::vector<cv::Point>> contours;
+        std::vector<std::vector<cv::Point>> contoursFiltered;
+
+        // Grab frame from camera
+        std::cout << "  frame: " << cnt;
+        try
+        { 
+            image = cameraPtr_ -> grabImage();
+        }
+        catch (RuntimeError &runtimeError)
+        {
+            std::cout << " - error " << runtimeError.what() << std::endl;
+            continue;
+        }
+        std::cout << std::endl; 
+
+        // Threshold image, invert and find external contours 
+        cv::threshold(image,imageThresh, threshold_, THRESHOLD_MAXVAL, CV_THRESH_BINARY);
+        imageThresh = THRESHOLD_MAXVAL - imageThresh;
+        imageTemp = imageThresh.clone();
+        cv::findContours(imageTemp, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
+
+        // Filter contours by area
+        for (size_t index=0; index < contours.size(); index++)
+        {
+            cv::Moments contourMoments = cv::moments(contours[index]);
+            if ((contourMoments.m00 >= minimumArea_) && (contourMoments.m00 <= maximumArea_))
+            {
+                contoursFiltered.push_back(contours[index]);
+
+                double centroidX = contourMoments.m10/contourMoments.m00;
+                double centroidY = contourMoments.m01/contourMoments.m00;
+                int numBlob = contoursFiltered.size() - 1;
+                std::cout << "    blob: " << numBlob; 
+                std::cout << ", (" << centroidX << ", " << centroidY << ") " << std::endl;
+            }
+        }
+        std::cout << std::endl;
+
+        // Draw contours on image
+        imageContour = cv::Mat(image.size(), CV_8UC3, cv::Scalar(0,0,0));
+        for (size_t index=0; index < contoursFiltered.size(); index++)
+        {
+            cv::drawContours(imageContour, contoursFiltered, index, cv::Scalar(0,0,255));
+        }
+
+        // Display images
+        cv::resize(image,imageTemp, cv::Size(0,0), displayScale_, displayScale_);
+        cv::imshow("Raw Image", imageTemp);
+
+        cv::resize(imageThresh,imageTemp, cv::Size(0,0), displayScale_, displayScale_);
+        cv::imshow("Threshold Image", imageTemp);
+
+        cv::resize(imageContour, imageTemp, cv::Size(0,0), displayScale_, displayScale_); 
+        cv::imshow("Contour Image", imageTemp);
+
+        // Look for 'x' key press as signal to quit
+        int key = cv::waitKey(1);
+        if (key == 120)
+        {
+            break;
+        }
+
+        cnt++;
+    }
+
+    success = stopCapture();
+    if (!success)
+    {
+        return false;
+    }
+
+    return true;
+}
+
+bool BlobFinder::setupCamera()
+{
+    std::cout << std::endl;
+    std::cout << "* setup camera" << std::endl << std::endl;
+
+    std::cout << "  searching for cameras ... ";
+    CameraFinder cameraFinder;
+    CameraPtrList cameraPtrList = cameraFinder.createCameraPtrList();
+    if (cameraPtrList.empty())
+    {
+        std::cout << "no cameras found." << std::endl;
+        return false;
+    }
+
+    std::cout << cameraPtrList.size() << " cameras" << std::endl;
+    for (CameraPtrList::iterator it=cameraPtrList.begin(); it!=cameraPtrList.end(); it++)
+    {
+        CameraPtr cameraPtr_ = *it;
+        std::cout << "  guid: " << cameraPtr_ -> getGuid().toString() << std::endl;
+    }
+
+    std::cout << "  connecting to first camera ... ";
+    cameraPtr_ = cameraPtrList.front();
+
+    if (cameraPtr_ -> isConnected()) 
+    {
+        std::cout << "error: camera already connected" << std::endl;
+        return false;
+    }
+
+    try
+    {
+        cameraPtr_ -> connect();
+    }
+    catch (RuntimeError &runtimeError)
+    {
+        std::cout << "error: " << runtimeError.what() << std::endl;
+        return false;
+    }
+    std::cout << "done" << std::endl;
+
+    std::cout << "  model:  " << cameraPtr_ -> getModelName() << std::endl;
+    std::cout << "  vendor: " << cameraPtr_ -> getVendorName() << std::endl;
+
+    std::cout << "  setting videoMode=Format7, trigger=internal ... ";
+    try
+    {
+        cameraPtr_ -> setVideoMode(VIDEOMODE_FORMAT7);
+        cameraPtr_ -> setTriggerInternal();
+    }
+    catch (RuntimeError &runtimeError)
+    {
+        std::cout << "error: " << runtimeError.what() << std::endl;
+        return false;
+    }
+    std::cout << "done" << std::endl;
+
+    std::cout << "  setting framerate to " << frameRate_ << " fps ... ";
+    try
+    {
+        PropertyInfo  frameRateInfo = cameraPtr_ -> getPropertyInfo(PROPERTY_TYPE_FRAME_RATE);
+        Property frameRateProp = cameraPtr_ -> getProperty(PROPERTY_TYPE_FRAME_RATE);
+        frameRateProp.absoluteControl = true;
+        frameRateProp.absoluteValue = frameRate_;
+        frameRateProp.autoActive = false;
+        cameraPtr_ -> setProperty(frameRateProp);
+        frameRateProp = cameraPtr_ -> getProperty(PROPERTY_TYPE_FRAME_RATE);
+    }
+    catch (RuntimeError &runtimeError)
+    {
+        std::cout << "error: " << runtimeError.what() << std::endl;
+        return false;
+    }
+    std::cout << "done" << std::endl;
+    std::cout << std::endl;
+
+    return true;
+}
+
+
+bool BlobFinder::cleanUp()
+{
+
+    std::cout << std::endl;
+    std::cout << "* clean up" << std::endl << std::endl;
+    std::cout << "  disconnecting camera ... ";
+
+    if (!(cameraPtr_ -> isConnected()))
+    {
+        std::cout << "already disconnected" << std::endl;
+        return false;
+    }
+
+    try
+    {
+        cameraPtr_ -> disconnect();
+    }
+    catch (RuntimeError &runtimeError)
+    {
+        std::cout << "error: " << runtimeError.what() << std::endl;
+        return false;
+    }
+    std::cout << "done" << std::endl;
+    std::cout << std::endl;
+    return true;
+}
+
+
+
+bool BlobFinder::startCapture()
+{
+    std::cout << std::endl;
+    std::cout << "* start capture ... ";
+    try
+    {
+        cameraPtr_ -> startCapture();
+    }
+    catch (RuntimeError &runtimeError)
+    {
+        std::cout << "error: " << runtimeError.what() << std::endl;
+        return false;
+    }
+    std::cout << "done" << std::endl;
+    return true;
+}
+
+
+bool BlobFinder::stopCapture()
+{
+    std::cout << std::endl;
+    std::cout << "* stop capture ... ";
+    try
+    {
+        cameraPtr_ -> stopCapture();
+    }
+    catch (RuntimeError &runtimeError)
+    {
+        std::cout << "error: " << runtimeError.what() << std::endl << std::endl;
+        return false;
+    }
+    std::cout << "done" << std::endl;
+    return true;
+}

src/demo/blob_finder/blob_finder.hpp

+#ifndef BLOB_FINDER_HPP
+#define BLOB_FINDER_HPP
+#include "camera_facade_fwd.hpp"
+
+using namespace bias;
+
+class BlobFinder
+{
+    public:
+
+        static const float DEFAULT_FRAMERATE;
+        static const float DEFAULT_DISPLAY_SCALE;
+        static const double DEFAULT_THRESHOLD;
+        static const double DEFAULT_MINIMUM_AREA;
+        static const double DEFAULT_MAXIMUM_AREA;
+        static const double THRESHOLD_MAXVAL;
+
+        BlobFinder();
+        BlobFinder(float frameRate);
+
+        bool setupCamera();
+        bool cleanUp();
+        bool run();
+
+    private:
+
+        float frameRate_;
+        float displayScale_;
+        double threshold_;
+        double minimumArea_; 
+        double maximumArea_;
+        CameraPtr cameraPtr_;
+
+        bool startCapture();
+        bool stopCapture();
+
+};
+
+#endif // #ifndef BLOB_FINDER_HPP
+
+

src/demo/blob_finder/blob_finder_main.cpp

+#if defined(WIN32) || defined(WIN64)
+#define _CRT_SECURE_NO_WARNINGS		
+#endif
+
+#include <cstdlib>
+#include <iostream>
+#include "blob_finder.hpp"
+
+using namespace bias;
+
+int main(int argc, char** argv)
+{        
+    std::cout << std::endl;
+    std::cout << "--------------------------------------- " << std::endl;
+    std::cout << "  Blob Finder Demo                      " << std::endl;
+    std::cout << "--------------------------------------- " << std::endl;
+
+    bool success = true;
+    const float frameRate = 50.0;
+    BlobFinder blobFinder(frameRate); 
+
+    success = blobFinder.setupCamera();
+    if (!success)
+    {
+        std::cout << "* failed to setup camera" << std::endl;
+        std::exit(EXIT_FAILURE);
+    }
+
+    success = blobFinder.run();
+    if (!success)
+    {
+        std::cout << "* failure during blob detection" << std::endl;
+    }
+
+    success = blobFinder.cleanUp();
+    if (!success)
+    {
+        std::cout << "* failed to clean up camera" << std::endl;
+        std::exit(EXIT_FAILURE);
+    }
+
+	return 0;
+}
+

src/test/CMakeLists.txt

 cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
 
-project(blob_finder)
-add_executable(blob_finder blob_finder_main.cpp blob_finder.cpp)
-target_link_libraries(blob_finder ${bias_ext_link_LIBS} bias_camera_facade)
+if(with_fc2)
+    project(bias_test_fc2)
+    add_executable(test_fc2 test_fc2.cpp)
+    target_link_libraries(test_fc2 ${bias_ext_link_LIBS} bias_camera_facade)
 
+endif()
 
+if(with_dc1394) 
+    project(bias_test_dc1394)
+    add_EXECUTABLE(test_dc1394 test_dc1394.cpp)
+    target_link_libraries(test_dc1394 ${bias_ext_link_LIBS} bias_camera_facade)
+endif()
 
+

src/test/blob_finder.cpp

-#include "blob_finder.hpp"
-#include "camera_facade.hpp"
-#include <iostream>
-#include <vector>
-#include <opencv2/core/core.hpp>
-#include <opencv2/highgui/highgui.hpp>
-#include <opencv2/imgproc/imgproc.hpp>
-
-const float BlobFinder::DEFAULT_FRAMERATE = 10.0;
-const float BlobFinder::DEFAULT_DISPLAY_SCALE = 0.5;
-const double BlobFinder::DEFAULT_THRESHOLD = 100.0;
-const double BlobFinder::DEFAULT_MINIMUM_AREA = 50.0;
-const double BlobFinder::DEFAULT_MAXIMUM_AREA = 640.0*480.0;
-const double BlobFinder::THRESHOLD_MAXVAL = 255.0;
-
-
-BlobFinder::BlobFinder()
-{
-    frameRate_ = DEFAULT_FRAMERATE;
-    displayScale_ = DEFAULT_DISPLAY_SCALE;
-    threshold_ = DEFAULT_THRESHOLD;
-    minimumArea_ = DEFAULT_MINIMUM_AREA;
-    maximumArea_ = DEFAULT_MAXIMUM_AREA; 
-}
-
-
-BlobFinder::BlobFinder(float frameRate) : BlobFinder()
-{
-    frameRate_ = frameRate;
-}
-
-
-bool BlobFinder::run()
-{
-    bool success = true;
-
-    std::cout << std::endl;
-    std::cout << "* finding blobs - press 'x' to exit" << std::endl;
-
-    success = startCapture();
-    if (!success)
-    {
-        return false;
-    }
-    std::cout << std::endl;
-
-    cv::namedWindow("Raw Image", CV_WINDOW_AUTOSIZE | CV_WINDOW_KEEPRATIO | CV_GUI_EXPANDED);
-    cv::namedWindow("Threshold Image", CV_WINDOW_AUTOSIZE | CV_WINDOW_KEEPRATIO | CV_GUI_EXPANDED); 
-    cv::namedWindow("Contour Image", CV_WINDOW_AUTOSIZE | CV_WINDOW_KEEPRATIO | CV_GUI_EXPANDED); 
-
-    unsigned long cnt = 0;
-
-    while (true)
-    {
-        cv::Mat image;
-        cv::Mat imageTemp;
-        cv::Mat imageThresh;
-        cv::Mat imageContour;
-        std::vector<std::vector<cv::Point>> contours;
-        std::vector<std::vector<cv::Point>> contoursFiltered;
-
-        // Grab frame from camera
-        std::cout << "  frame: " << cnt;
-        try
-        { 
-            image = cameraPtr_ -> grabImage();
-        }
-        catch (RuntimeError &runtimeError)
-        {
-            std::cout << " - error " << runtimeError.what() << std::endl;
-            continue;
-        }
-        std::cout << std::endl; 
-
-        // Threshold image, invert and find external contours 
-        cv::threshold(image,imageThresh, threshold_, THRESHOLD_MAXVAL, CV_THRESH_BINARY);
-        imageThresh = THRESHOLD_MAXVAL - imageThresh;
-        imageTemp = imageThresh.clone();
-        cv::findContours(imageTemp, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
-
-        // Filter contours by area
-        for (size_t index=0; index < contours.size(); index++)
-        {
-            cv::Moments contourMoments = cv::moments(contours[index]);
-            if ((contourMoments.m00 >= minimumArea_) && (contourMoments.m00 <= maximumArea_))
-            {
-                contoursFiltered.push_back(contours[index]);
-
-                double centroidX = contourMoments.m10/contourMoments.m00;
-                double centroidY = contourMoments.m01/contourMoments.m00;
-                int numBlob = contoursFiltered.size() - 1;
-                std::cout << "    blob: " << numBlob; 
-                std::cout << ", (" << centroidX << ", " << centroidY << ") " << std::endl;
-            }
-        }
-        std::cout << std::endl;
-
-        // Draw contours on image
-        imageContour = cv::Mat(image.size(), CV_8UC3, cv::Scalar(0,0,0));
-        for (size_t index=0; index < contoursFiltered.size(); index++)
-        {
-            cv::drawContours(imageContour, contoursFiltered, index, cv::Scalar(0,0,255));
-        }
-
-        // Display images
-        cv::resize(image,imageTemp, cv::Size(0,0), displayScale_, displayScale_);
-        cv::imshow("Raw Image", imageTemp);
-
-        cv::resize(imageThresh,imageTemp, cv::Size(0,0), displayScale_, displayScale_);
-        cv::imshow("Threshold Image", imageTemp);
-
-        cv::resize(imageContour, imageTemp, cv::Size(0,0), displayScale_, displayScale_); 
-        cv::imshow("Contour Image", imageTemp);
-
-        // Look for 'x' key press as signal to quit
-        int key = cv::waitKey(1);
-        if (key == 120)
-        {
-            break;
-        }
-
-        cnt++;
-    }
-
-    success = stopCapture();
-    if (!success)
-    {
-        return false;
-    }
-
-    return true;
-}
-
-bool BlobFinder::setupCamera()
-{
-    std::cout << std::endl;
-    std::cout << "* setup camera" << std::endl << std::endl;
-
-    std::cout << "  searching for cameras ... ";
-    CameraFinder cameraFinder;
-    CameraPtrList cameraPtrList = cameraFinder.createCameraPtrList();
-    if (cameraPtrList.empty())
-    {
-        std::cout << "no cameras found." << std::endl;
-        return false;
-    }
-
-    std::cout << cameraPtrList.size() << " cameras" << std::endl;
-    for (CameraPtrList::iterator it=cameraPtrList.begin(); it!=cameraPtrList.end(); it++)
-    {
-        CameraPtr cameraPtr_ = *it;
-        std::cout << "  guid: " << cameraPtr_ -> getGuid().toString() << std::endl;
-    }
-
-    std::cout << "  connecting to first camera ... ";
-    cameraPtr_ = cameraPtrList.front();
-
-    if (cameraPtr_ -> isConnected()) 
-    {
-        std::cout << "error: camera already connected" << std::endl;
-        return false;
-    }
-
-    try
-    {
-        cameraPtr_ -> connect();
-    }
-    catch (RuntimeError &runtimeError)
-    {
-        std::cout << "error: " << runtimeError.what() << std::endl;
-        return false;
-    }
-    std::cout << "done" << std::endl;
-
-    std::cout << "  model:  " << cameraPtr_ -> getModelName() << std::endl;
-    std::cout << "  vendor: " << cameraPtr_ -> getVendorName() << std::endl;
-
-    std::cout << "  setting videoMode=Format7, trigger=internal ... ";
-    try
-    {
-        cameraPtr_ -> setVideoMode(VIDEOMODE_FORMAT7);
-        cameraPtr_ -> setTriggerInternal();
-    }
-    catch (RuntimeError &runtimeError)
-    {
-        std::cout << "error: " << runtimeError.what() << std::endl;
-        return false;
-    }
-    std::cout << "done" << std::endl;
-
-    std::cout << "  setting framerate to " << frameRate_ << " fps ... ";
-    try
-    {
-        PropertyInfo  frameRateInfo = cameraPtr_ -> getPropertyInfo(PROPERTY_TYPE_FRAME_RATE);
-        Property frameRateProp = cameraPtr_ -> getProperty(PROPERTY_TYPE_FRAME_RATE);
-        frameRateProp.absoluteControl = true;
-        frameRateProp.absoluteValue = frameRate_;
-        frameRateProp.autoActive = false;
-        cameraPtr_ -> setProperty(frameRateProp);
-        frameRateProp = cameraPtr_ -> getProperty(PROPERTY_TYPE_FRAME_RATE);
-    }
-    catch (RuntimeError &runtimeError)
-    {
-        std::cout << "error: " << runtimeError.what() << std::endl;
-        return false;
-    }
-    std::cout << "done" << std::endl;
-    std::cout << std::endl;
-
-    return true;
-}
-
-
-bool BlobFinder::cleanUp()
-{
-
-    std::cout << std::endl;
-    std::cout << "* clean up" << std::endl << std::endl;
-    std::cout << "  disconnecting camera ... ";
-
-    if (!(cameraPtr_ -> isConnected()))
-    {
-        std::cout << "already disconnected" << std::endl;
-        return false;
-    }
-
-    try
-    {
-        cameraPtr_ -> disconnect();
-    }
-    catch (RuntimeError &runtimeError)
-    {
-        std::cout << "error: " << runtimeError.what() << std::endl;
-        return false;
-    }
-    std::cout << "done" << std::endl;
-    std::cout << std::endl;
-    return true;
-}
-
-
-
-bool BlobFinder::startCapture()
-{
-    std::cout << std::endl;
-    std::cout << "* start capture ... ";
-    try
-    {
-        cameraPtr_ -> startCapture();
-    }
-    catch (RuntimeError &runtimeError)
-    {
-        std::cout << "error: " << runtimeError.what() << std::endl;
-        return false;
-    }
-    std::cout << "done" << std::endl;
-    return true;
-}
-
-
-bool BlobFinder::stopCapture()
-{
-    std::cout << std::endl;
-    std::cout << "* stop capture ... ";
-    try
-    {
-        cameraPtr_ -> stopCapture();
-    }
-    catch (RuntimeError &runtimeError)
-    {
-        std::cout << "error: " << runtimeError.what() << std::endl << std::endl;
-        return false;
-    }
-    std::cout << "done" << std::endl;
-    return true;
-}

src/test/blob_finder.hpp

-#ifndef BLOB_FINDER_HPP
-#define BLOB_FINDER_HPP
-#include "camera_facade_fwd.hpp"
-
-using namespace bias;
-
-class BlobFinder
-{
-    public:
-
-        static const float DEFAULT_FRAMERATE;
-        static const float DEFAULT_DISPLAY_SCALE;
-        static const double DEFAULT_THRESHOLD;
-        static const double DEFAULT_MINIMUM_AREA;
-        static const double DEFAULT_MAXIMUM_AREA;
-        static const double THRESHOLD_MAXVAL;
-
-        BlobFinder();
-        BlobFinder(float frameRate);
-
-        bool setupCamera();
-        bool cleanUp();
-        bool run();
-
-    private:
-
-        float frameRate_;
-        float displayScale_;
-        double threshold_;
-        double minimumArea_; 
-        double maximumArea_;
-        CameraPtr cameraPtr_;
-
-        bool startCapture();
-        bool stopCapture();
-
-};
-
-#endif // #ifndef BLOB_FINDER_HPP
-
-

src/test/blob_finder_main.cpp

-#if defined(WIN32) || defined(WIN64)
-#define _CRT_SECURE_NO_WARNINGS		
-#endif
-
-#include <cstdlib>
-#include <iostream>
-#include "blob_finder.hpp"
-
-using namespace bias;
-
-int main(int argc, char** argv)
-{        
-    std::cout << std::endl;
-    std::cout << "--------------------------------------- " << std::endl;
-    std::cout << "  Blob Finder Demo                      " << std::endl;
-    std::cout << "--------------------------------------- " << std::endl;
-
-    bool success = true;
-    const float frameRate = 50.0;
-    BlobFinder blobFinder(frameRate); 
-
-    success = blobFinder.setupCamera();
-    if (!success)
-    {
-        std::cout << "* failed to setup camera" << std::endl;
-        std::exit(EXIT_FAILURE);
-    }
-
-    success = blobFinder.run();
-    if (!success)
-    {
-        std::cout << "* failure during blob detection" << std::endl;
-    }
-
-    success = blobFinder.cleanUp();
-    if (!success)
-    {
-        std::cout << "* failed to clean up camera" << std::endl;
-        std::exit(EXIT_FAILURE);
-    }
-
-	return 0;
-}
-

src/test/old/CMakeLists.txt

-cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
-
-if(with_fc2)
-    project(bias_test_fc2)
-    add_executable(test_fc2 test_fc2.cpp)
-    target_link_libraries(test_fc2 ${bias_ext_link_LIBS} bias_camera_facade)
-
-endif()
-
-if(with_dc1394) 
-    project(bias_test_dc1394)
-    add_EXECUTABLE(test_dc1394 test_dc1394.cpp)
-    target_link_libraries(test_dc1394 ${bias_ext_link_LIBS} bias_camera_facade)
-endif()
-
-

src/test/old/test_dc1394.cpp

-#include <iostream>
-#include <vector>
-#include <stdint.h>
-#include <unistd.h>
-#include "guid.hpp"
-#include <opencv2/core/core.hpp>
-#include <opencv2/highgui/highgui.hpp>
-#include <opencv2/imgproc/imgproc.hpp>
-#include "camera.hpp"
-#include "camera_finder.hpp"
-
-using namespace std;
-using namespace bias;
-
-int main(int argc, char *argv[]) 
-{
-    int numImage = 1000;
-    cv::Mat image;
-    cv::Mat imageScaled;
-    CameraFinder cameraFinder;
-    std::vector<std::string> windowNames;
-
-    cout << endl;
-    cout << "number of cameras: " << cameraFinder.numberOfCameras() << endl;
-
-    // Get and print list of camera guids
-
-    GuidList guidList = cameraFinder.getGuidList(); 
-
-    if (guidList.size() == 0) 
-    {
-        cout << "No cameas found" << endl;
-        return -1;
-    }
-
-    {
-        cout << endl;
-        cout << "printing guid list" << endl;
-        int cnt;
-
-        GuidList::iterator it;
-        for (it=guidList.begin(), cnt=0; it!=guidList.end(); it++, cnt++)
-        {
-            Guid guid = *it;
-            cout  << "  [" << cnt << "] guid " << guid << endl;
-        }
-    }
-
-    // Create, connect and add cameras to camera list
-    CameraPtrList cameraPtrList;
-    {
-        cout << endl;
-        cout << "creating & connecting cameras" << endl;
-        int cnt;
-        GuidList::iterator it;
-        for (it=guidList.begin(), cnt=0; it!=guidList.end(); it++, cnt++)
-        {
-            Guid guid = *it;
-            cout  << "  [" << cnt << "] guid " << guid << endl;
-            CameraPtr cameraPtr = std::make_shared<Camera>(guid);
-            cameraPtr -> connect();
-            cameraPtrList.push_back(cameraPtr);
-        }
-    }
-
-    // Create opencv named windows
-    // ------------------------------------------------------------------------
-    windowNames = std::vector<std::string>(cameraPtrList.size());
-    for (int cnt = 0; cnt < cameraPtrList.size(); cnt++)
-    {
-        std::stringstream ssName;
-        ssName << "Camera: " <<  cnt;
-        windowNames[cnt] = ssName.str();
-        cv::namedWindow(
-                windowNames[cnt],
-                CV_WINDOW_AUTOSIZE | CV_WINDOW_KEEPRATIO | CV_GUI_NORMAL
-                );
-    }
-
-    // Print camera information
-    {
-        cout << endl;
-        cout << "printing camera info" << endl;
-        int cnt;
-        CameraPtrList::iterator it;
-        for (it=cameraPtrList.begin(), cnt=0; it!=cameraPtrList.end(); it++, cnt++)
-        {
-            cout << "camera: " << cnt << endl;
-            CameraPtr cameraPtr = *it;
-            cameraPtr -> printInfo();
-        }
-    }
-
-    // Start capture
-    {
-        cout << endl;
-        cout << "starting video capture" << endl;
-        int cnt;
-        CameraPtrList::iterator it;
-        for (it=cameraPtrList.begin(), cnt=0; it!=cameraPtrList.end(); it++, cnt++)
-        {
-            cout << "  camera: " << cnt << endl;
-            CameraPtr cameraPtr = *it;
-            cameraPtr -> startCapture();
-        }
-    }
-
-    // Grab some frames
-    {
-        cout << "grabbing some images" << endl;
-        for (int i=0; i<numImage; i++) 
-        {
-            cout << "  image: " << i << "/" << numImage << endl;
-            int cnt;
-            CameraPtrList::iterator it;
-            for (it=cameraPtrList.begin(), cnt=0; it!=cameraPtrList.end(); it++, cnt++)
-            {
-                cout << "    camera: " << cnt << endl;
-                CameraPtr cameraPtr = *it;
-                image = cameraPtr -> grabImage();
-                if (i%2 == 0) {
-                    cv::resize(image, imageScaled, cv::Size(0,0), 0.8, 0.8);
-                    cv::imshow(windowNames[cnt], imageScaled);
-                    cv::waitKey(10);
-                }
-            }
-        }
-    }
-
-    // Stop capture
-    {
-        cout << endl;
-        cout << "stoping video capture" << endl;
-        int cnt;
-        CameraPtrList::iterator it;
-        for (it=cameraPtrList.begin(), cnt=0; it!=cameraPtrList.end(); it++, cnt++)
-        {
-            cout << "  camera: " << cnt << endl;
-            CameraPtr cameraPtr = *it;
-            cameraPtr -> stopCapture();
-        }
-    }
-    
-
-    return 0;
-}

src/test/old/test_fc2.cpp

-#if defined(WIN32) || defined(WIN64)
-#define _CRT_SECURE_NO_WARNINGS		
-#endif
-#include <windows.h>
-#include <iostream>
-#include <memory>
-#include <sstream>
-#include <vector>
-#include <map>
-#include <opencv2/core/core.hpp>
-#include <opencv2/highgui/highgui.hpp>
-#include <opencv2/imgproc/imgproc.hpp>
-
-#include "utils.hpp"
-#include "guid.hpp"
-#include "property.hpp"
-#include "camera.hpp"
-#include "camera_finder.hpp"
-#include "basic_types.hpp"
-
-using namespace std;
-using namespace bias;
-
-int main(int argc, char** argv)
-{        
-    int cnt;
-    int numGrab = 1;
-    CameraFinder camFinder;
-    cv::Mat image;
-    cv::Mat imageScaled;
-    std::vector<std::string> windowNames;
-
-    cout << endl;
-
-    // Create and Connect cameras - set videomode
-    // ------------------------------------------------------------------------
-    cnt = 0;
-    CameraPtrList camPtrList = camFinder.createCameraPtrList();
-    for (
-            CameraPtrList::iterator it=camPtrList.begin(); 
-            it!=camPtrList.end(); 
-            it++
-        )
-    {
-        CameraPtr camPtr = *it;
-        camPtr -> connect();
-        std::cout << "image mode" << camPtr -> getImageMode();
-        //camPtr -> setVideoMode(VIDEOMODE_FORMAT7);
-        //camPtr -> setTriggerInternal();
-
-        //Property prop = camPtr -> getProperty(PROPERTY_TYPE_FRAME_RATE);
-        //prop.autoActive = false;
-        //prop.value = 465;
-        //camPtr -> setProperty(prop);
-    }
-
-    // Create opencv named windows
-    // ------------------------------------------------------------------------
-    windowNames = std::vector<std::string>(camPtrList.size());
-    for ( cnt = 0; cnt < camPtrList.size(); cnt++)
-    {
-        std::stringstream ssName;
-        ssName << "Camera: " <<  cnt;
-        windowNames[cnt] = ssName.str();
-        cv::namedWindow(
-                windowNames[cnt],
-                CV_WINDOW_AUTOSIZE | CV_WINDOW_KEEPRATIO | CV_GUI_EXPANDED
-                );
-    }
-
-    // Print camera information
-    // ------------------------------------------------------------------------
-    if (false) 
-    {
-        cnt = 0;
-        for (
-                CameraPtrList::iterator it=camPtrList.begin(); 
-                it!=camPtrList.end(); 
-                it++
-            ) 
-        {
-            cout << endl << "Camera " << cnt << endl;
-            CameraPtr camPtr = *it;
-            camPtr -> printInfo();
-            cnt++;
-        }
-    }
-
-    // Print Property information for all cameras
-    // ------------------------------------------------------------------------
-    if (true) 
-    {
-        cnt = 0;
-        for (
-                CameraPtrList::iterator it=camPtrList.begin();
-                it!=camPtrList.end();
-                it++
-            )
-        {
-            cout << endl << "Camera " << cnt << " Property Information" << endl;
-            CameraPtr camPtr = *it;
-            camPtr -> printAllPropertyInfos();
-            cnt++;
-        }
-    }
-
-    // Print property values for all cameras
-    // ------------------------------------------------------------------------
-    if (false)
-    {
-        cnt = 0;
-        for (
-                CameraPtrList::iterator it=camPtrList.begin();
-                it!=camPtrList.end();
-                it++
-            )
-        {
-            cout << endl << "Camera " << cnt << " Property Values" << endl;
-            CameraPtr camPtr = *it;
-            camPtr -> printAllProperties();
-            cnt++;
-        }
-    }
-
-    //// Start capture on cameras
-    //// ------------------------------------------------------------------------
-    //cout << "Starting capture on cameras: ";
-    //cnt = 0;
-    //for (
-    //        CameraPtrList::iterator it=camPtrList.begin(); 
-    //        it!=camPtrList.end(); 
-    //        it++
-    //    ) 
-    //{
-    //    cout << cnt << " ";
-    //    CameraPtr camPtr = *it;
-    //    camPtr -> startCapture();
-    //    cnt++;
-    //}
-    //cout << "done" << endl;
-    //cout << endl;
-   
-
-    //// Grab images
-    //// ------------------------------------------------------------------------
-    //cout << "Grabing images" << endl;
-    //cout << endl;
-    //for (int i=0; i<numGrab; i++) 
-    //{
-    //    cout << "  image: " << (i+1) << "/" << numGrab << " camera: ";
-    //    cnt = 0;
-    //    for (
-    //            CameraPtrList::iterator it=camPtrList.begin();
-    //            it!=camPtrList.end(); 
-    //            it++
-    //        )
-    //    {
-    //        CameraPtr cameraPtr = *it;
-    //        cameraPtr -> grabImage(image);
-
-    //        if (cnt%10 == 0) {
-    //            cv::resize(image,imageScaled, cv::Size(0,0), 0.5, 0.5);
-    //            cv::imshow(windowNames[cnt], imageScaled);
-    //            cv::waitKey(1);
-    //        }
-
-    //        cout << cnt << " ";
-    //        cnt++;
-    //    } 
-    //    cout << endl;
-    //}
-
-
-    //// Stop capture on cameras
-    //// ------------------------------------------------------------------------
-    //cout << endl;
-    //cout << "Stopping capture on cameras: ";
-    //cnt = 0;
-    //for (
-    //        CameraPtrList::iterator it=camPtrList.begin(); 
-    //        it!=camPtrList.end(); 
-    //        it++
-    //    ) 
-    //{
-    //    cout << cnt << " "; 
-    //    CameraPtr cameraPtr = *it;
-    //    cameraPtr -> stopCapture();
-    //    cnt++;
-    //}
-    //cout << "done" << endl << endl;
-
-
-
-	return 0;
-}
-

src/test/test_dc1394.cpp

+#include <iostream>
+#include <vector>
+#include <stdint.h>
+#include <unistd.h>
+#include "guid.hpp"
+#include <opencv2/core/core.hpp>
+#include <opencv2/highgui/highgui.hpp>
+#include <opencv2/imgproc/imgproc.hpp>
+#include "camera.hpp"
+#include "camera_finder.hpp"
+
+using namespace std;
+using namespace bias;
+
+int main(int argc, char *argv[]) 
+{
+    int numImage = 1000;
+    cv::Mat image;
+    cv::Mat imageScaled;
+    CameraFinder cameraFinder;
+    std::vector<std::string> windowNames;
+
+    cout << endl;
+    cout << "number of cameras: " << cameraFinder.numberOfCameras() << endl;
+
+    // Get and print list of camera guids
+
+    GuidList guidList = cameraFinder.getGuidList(); 
+
+    if (guidList.size() == 0) 
+    {
+        cout << "No cameas found" << endl;
+        return -1;
+    }
+
+    {
+        cout << endl;
+        cout << "printing guid list" << endl;
+        int cnt;
+
+        GuidList::iterator it;
+        for (it=guidList.begin(), cnt=0; it!=guidList.end(); it++, cnt++)
+        {
+            Guid guid = *it;
+            cout  << "  [" << cnt << "] guid " << guid << endl;
+        }
+    }
+
+    // Create, connect and add cameras to camera list
+    CameraPtrList cameraPtrList;
+    {
+        cout << endl;
+        cout << "creating & connecting cameras" << endl;
+        int cnt;
+        GuidList::iterator it;
+        for (it=guidList.begin(), cnt=0; it!=guidList.end(); it++, cnt++)
+        {
+            Guid guid = *it;
+            cout  << "  [" << cnt << "] guid " << guid << endl;
+            CameraPtr cameraPtr = std::make_shared<Camera>(guid);
+            cameraPtr -> connect();
+            cameraPtrList.push_back(cameraPtr);
+        }
+    }
+
+    // Create opencv named windows
+    // ------------------------------------------------------------------------
+    windowNames = std::vector<std::string>(cameraPtrList.size());
+    for (int cnt = 0; cnt < cameraPtrList.size(); cnt++)
+    {
+        std::stringstream ssName;
+        ssName << "Camera: " <<  cnt;
+        windowNames[cnt] = ssName.str();
+        cv::namedWindow(
+                windowNames[cnt],
+                CV_WINDOW_AUTOSIZE | CV_WINDOW_KEEPRATIO | CV_GUI_NORMAL
+                );
+    }
+
+    // Print camera information
+    {
+        cout << endl;
+        cout << "printing camera info" << endl;
+        int cnt;
+        CameraPtrList::iterator it;
+        for (it=cameraPtrList.begin(), cnt=0; it!=cameraPtrList.end(); it++, cnt++)
+        {
+            cout << "camera: " << cnt << endl;
+            CameraPtr cameraPtr = *it;
+            cameraPtr -> printInfo();
+        }
+    }
+
+    // Start capture
+    {
+        cout << endl;
+        cout << "starting video capture" << endl;
+        int cnt;
+        CameraPtrList::iterator it;
+        for (it=cameraPtrList.begin(), cnt=0; it!=cameraPtrList.end(); it++, cnt++)
+        {
+            cout << "  camera: " << cnt << endl;
+            CameraPtr cameraPtr = *it;
+            cameraPtr -> startCapture();
+        }
+    }
+
+    // Grab some frames
+    {
+        cout << "grabbing some images" << endl;
+        for (int i=0; i<numImage; i++) 
+        {
+            cout << "  image: " << i << "/" << numImage << endl;
+            int cnt;
+            CameraPtrList::iterator it;
+            for (it=cameraPtrList.begin(), cnt=0; it!=cameraPtrList.end(); it++, cnt++)
+            {
+                cout << "    camera: " << cnt << endl;
+                CameraPtr cameraPtr = *it;
+                image = cameraPtr -> grabImage();
+                if (i%2 == 0) {
+                    cv::resize(image, imageScaled, cv::Size(0,0), 0.8, 0.8);
+                    cv::imshow(windowNames[cnt], imageScaled);
+                    cv::waitKey(10);
+                }
+            }
+        }
+    }
+
+    // Stop capture
+    {
+        cout << endl;
+        cout << "stoping video capture" << endl;
+        int cnt;
+        CameraPtrList::iterator it;
+        for (it=cameraPtrList.begin(), cnt=0; it!=cameraPtrList.end(); it++, cnt++)
+        {
+            cout << "  camera: " << cnt << endl;
+            CameraPtr cameraPtr = *it;
+            cameraPtr -> stopCapture();
+        }
+    }
+    
+
+    return 0;
+}

src/test/test_fc2.cpp

+#if defined(WIN32) || defined(WIN64)
+#define _CRT_SECURE_NO_WARNINGS		
+#endif
+#include <windows.h>
+#include <iostream>
+#include <memory>
+#include <sstream>
+#include <vector>
+#include <map>
+#include <opencv2/core/core.hpp>
+#include <opencv2/highgui/highgui.hpp>
+#include <opencv2/imgproc/imgproc.hpp>
+
+#include "utils.hpp"
+#include "guid.hpp"
+#include "property.hpp"
+#include "camera.hpp"
+#include "camera_finder.hpp"
+#include "basic_types.hpp"
+
+using namespace std;
+using namespace bias;
+
+int main(int argc, char** argv)
+{        
+    int cnt;
+    int numGrab = 1;
+    CameraFinder camFinder;
+    cv::Mat image;
+    cv::Mat imageScaled;
+    std::vector<std::string> windowNames;
+
+    cout << endl;
+
+    // Create and Connect cameras - set videomode
+    // ------------------------------------------------------------------------
+    cnt = 0;
+    CameraPtrList camPtrList = camFinder.createCameraPtrList();
+    for (
+            CameraPtrList::iterator it=camPtrList.begin(); 
+            it!=camPtrList.end(); 
+            it++
+        )
+    {
+        CameraPtr camPtr = *it;
+        camPtr -> connect();
+        std::cout << "image mode" << camPtr -> getImageMode();
+        //camPtr -> setVideoMode(VIDEOMODE_FORMAT7);
+        //camPtr -> setTriggerInternal();
+
+        //Property prop = camPtr -> getProperty(PROPERTY_TYPE_FRAME_RATE);
+        //prop.autoActive = false;
+        //prop.value = 465;
+        //camPtr -> setProperty(prop);
+    }
+
+    // Create opencv named windows
+    // ------------------------------------------------------------------------
+    windowNames = std::vector<std::string>(camPtrList.size());
+    for ( cnt = 0; cnt < camPtrList.size(); cnt++)
+    {
+        std::stringstream ssName;
+        ssName << "Camera: " <<  cnt;
+        windowNames[cnt] = ssName.str();
+        cv::namedWindow(
+                windowNames[cnt],
+                CV_WINDOW_AUTOSIZE | CV_WINDOW_KEEPRATIO | CV_GUI_EXPANDED
+                );
+    }
+
+    // Print camera information
+    // ------------------------------------------------------------------------
+    if (false) 
+    {
+        cnt = 0;
+        for (
+                CameraPtrList::iterator it=camPtrList.begin(); 
+                it!=camPtrList.end(); 
+                it++
+            ) 
+        {
+            cout << endl << "Camera " << cnt << endl;
+            CameraPtr camPtr = *it;
+            camPtr -> printInfo();
+            cnt++;
+        }
+    }
+
+    // Print Property information for all cameras
+    // ------------------------------------------------------------------------
+    if (true) 
+    {
+        cnt = 0;
+        for (
+                CameraPtrList::iterator it=camPtrList.begin();
+                it!=camPtrList.end();
+                it++
+            )
+        {
+            cout << endl << "Camera " << cnt << " Property Information" << endl;
+            CameraPtr camPtr = *it;
+            camPtr -> printAllPropertyInfos();
+            cnt++;
+        }
+    }
+
+    // Print property values for all cameras
+    // ------------------------------------------------------------------------
+    if (false)
+    {
+        cnt = 0;
+        for (
+                CameraPtrList::iterator it=camPtrList.begin();
+                it!=camPtrList.end();
+                it++
+            )
+        {
+            cout << endl << "Camera " << cnt << " Property Values" << endl;
+            CameraPtr camPtr = *it;
+            camPtr -> printAllProperties();
+            cnt++;
+        }
+    }
+
+    //// Start capture on cameras
+    //// ------------------------------------------------------------------------
+    //cout << "Starting capture on cameras: ";
+    //cnt = 0;
+    //for (
+    //        CameraPtrList::iterator it=camPtrList.begin(); 
+    //        it!=camPtrList.end(); 
+    //        it++
+    //    ) 
+    //{
+    //    cout << cnt << " ";
+    //    CameraPtr camPtr = *it;
+    //    camPtr -> startCapture();
+    //    cnt++;
+    //}
+    //cout << "done" << endl;
+    //cout << endl;
+   
+
+    //// Grab images
+    //// ------------------------------------------------------------------------
+    //cout << "Grabing images" << endl;
+    //cout << endl;
+    //for (int i=0; i<numGrab; i++) 
+    //{
+    //    cout << "  image: " << (i+1) << "/" << numGrab << " camera: ";
+    //    cnt = 0;
+    //    for (
+    //            CameraPtrList::iterator it=camPtrList.begin();
+    //            it!=camPtrList.end(); 
+    //            it++
+    //        )
+    //    {
+    //        CameraPtr cameraPtr = *it;
+    //        cameraPtr -> grabImage(image);
+
+    //        if (cnt%10 == 0) {
+    //            cv::resize(image,imageScaled, cv::Size(0,0), 0.5, 0.5);
+    //            cv::imshow(windowNames[cnt], imageScaled);
+    //            cv::waitKey(1);
+    //        }
+
+    //        cout << cnt << " ";
+    //        cnt++;
+    //    } 
+    //    cout << endl;
+    //}
+
+
+    //// Stop capture on cameras
+    //// ------------------------------------------------------------------------
+    //cout << endl;
+    //cout << "Stopping capture on cameras: ";
+    //cnt = 0;
+    //for (
+    //        CameraPtrList::iterator it=camPtrList.begin(); 
+    //        it!=camPtrList.end(); 
+    //        it++
+    //    ) 
+    //{
+    //    cout << cnt << " "; 
+    //    CameraPtr cameraPtr = *it;
+    //    cameraPtr -> stopCapture();
+    //    cnt++;
+    //}
+    //cout << "done" << endl << endl;
+
+
+
+	return 0;
+}
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.