Add OpenCV again and test command
This commit is contained in:
parent
e16f8a5b45
commit
4d19ec20fb
|
@ -295,7 +295,46 @@ set(SOQT_FOUND TRUE)
|
|||
|
||||
# OpenCV
|
||||
set(OPENCV_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/opencv)
|
||||
set(OPENCV_LIBRARIES cv.lib cvaux.lib cxcore.lib cxts.lib highgui.lib)
|
||||
set(OPENCV_LIBRARIES
|
||||
optimized opencv_calib3d249.lib
|
||||
debug opencv_calib3d249d.lib
|
||||
optimized opencv_contrib249.lib
|
||||
debug opencv_contrib249d.lib
|
||||
optimized opencv_core249.lib
|
||||
debug opencv_core249d.lib
|
||||
optimized opencv_features2d249.lib
|
||||
debug opencv_features2d249d.lib
|
||||
optimized opencv_flann249.lib
|
||||
debug opencv_flann249d.lib
|
||||
optimized opencv_gpu249.lib
|
||||
debug opencv_gpu249d.lib
|
||||
optimized opencv_highgui249.lib
|
||||
debug opencv_highgui249d.lib
|
||||
optimized opencv_imgproc249.lib
|
||||
debug opencv_imgproc249d.lib
|
||||
optimized opencv_legacy249.lib
|
||||
debug opencv_legacy249d.lib
|
||||
optimized opencv_ml249.lib
|
||||
debug opencv_ml249d.lib
|
||||
optimized opencv_nonfree249.lib
|
||||
debug opencv_nonfree249d.lib
|
||||
optimized opencv_objdetect249.lib
|
||||
debug opencv_objdetect249d.lib
|
||||
optimized opencv_ocl249.lib
|
||||
debug opencv_ocl249d.lib
|
||||
optimized opencv_photo249.lib
|
||||
debug opencv_photo249d.lib
|
||||
optimized opencv_stitching249.lib
|
||||
debug opencv_stitching249d.lib
|
||||
optimized opencv_superres249.lib
|
||||
debug opencv_superres249d.lib
|
||||
optimized opencv_ts249.lib
|
||||
debug opencv_ts249d.lib
|
||||
optimized opencv_video249.lib
|
||||
debug opencv_video249d.lib
|
||||
optimized opencv_videostab249.lib
|
||||
debug opencv_videostab249d.lib
|
||||
)
|
||||
set(OPENCV_FOUND TRUE)
|
||||
|
||||
# NGLIB (NetGen)
|
||||
|
|
|
@ -2,8 +2,12 @@ if(WIN32)
|
|||
add_definitions(-DFCAppImage)
|
||||
endif(WIN32)
|
||||
|
||||
if(OPENCV_FOUND)
|
||||
add_definitions(-DHAVE_OPENCV)
|
||||
endif(OPENCV_FOUND)
|
||||
|
||||
include_directories(
|
||||
#${OPENCV_INCLUDE_DIR}
|
||||
${OPENCV_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
|
@ -12,13 +16,11 @@ include_directories(
|
|||
)
|
||||
|
||||
set(Image_LIBS
|
||||
#${OPENCV_LIBRARIES}
|
||||
${OPENCV_LIBRARIES}
|
||||
FreeCADApp
|
||||
)
|
||||
|
||||
set(Image_SRCS
|
||||
#CaptureClass.cpp
|
||||
#CaptureClass.h
|
||||
ImageBase.cpp
|
||||
ImageBase.h
|
||||
ImagePlane.cpp
|
||||
|
|
|
@ -1,147 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2007 *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "CaptureClass.h"
|
||||
|
||||
#ifdef _MSC_VER // this file is not available on Linux
|
||||
//# include <cvcam.h>
|
||||
#endif
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
/// Constructor with an Capture number, 0 will ask for one
|
||||
Capturerer::Capturerer(int num)
|
||||
: capture(NULL),captureImage(0),_bIsWinOn(false)
|
||||
{
|
||||
capture = cvCaptureFromCAM( num );
|
||||
|
||||
if( !capture )
|
||||
throw "Cant create capture device";
|
||||
|
||||
hScale=0.5;
|
||||
vScale=0.5;
|
||||
lineWidth=1;
|
||||
useLabel=true;
|
||||
|
||||
// Init font
|
||||
cvInitFont(&font,CV_FONT_HERSHEY_SIMPLEX/*|CV_FONT_ITALIC*/, hScale,vScale,0,lineWidth);
|
||||
|
||||
|
||||
}
|
||||
/// Constructor with an File name. Object will capture from that Video file
|
||||
Capturerer::Capturerer(const char* fileName)
|
||||
: capture(NULL), captureImage(0),_bIsWinOn(false)
|
||||
{
|
||||
capture = cvCaptureFromAVI( fileName );
|
||||
|
||||
if( !capture )
|
||||
throw "Cant create capture device";
|
||||
|
||||
}
|
||||
|
||||
int Capturerer::chooseCamNum(void)
|
||||
{
|
||||
#if 0
|
||||
int ncams = cvcamGetCamerasCount( );//returns the number of available cameras in the system
|
||||
//printf("Number of Cams: %d\n",ncams);
|
||||
int* out;
|
||||
if(ncams >1){
|
||||
int nselected = cvcamSelectCamera(&out);
|
||||
if(nselected>0)
|
||||
printf("the 1-st selected camera is camera number %d", out[0]);
|
||||
if(nselected == 2)
|
||||
printf("the 2-nd selected camera is camera number %d", out[1]);
|
||||
}else if (ncams < 1){
|
||||
printf("No camara in system! Terminating.\n");
|
||||
return -1;
|
||||
}else
|
||||
out = new int(0);
|
||||
|
||||
return *out;
|
||||
#else
|
||||
//FIXME: cvcamGetCamerasCount is not available on Linux
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
Capturerer::~Capturerer()
|
||||
{
|
||||
if(_bIsWinOn)
|
||||
cvDestroyWindow("Capture");
|
||||
if(capture)
|
||||
cvReleaseCapture(&capture);
|
||||
}
|
||||
|
||||
|
||||
void Capturerer::setCaptureWindows(bool On)
|
||||
{
|
||||
if(!_bIsWinOn && On)
|
||||
{
|
||||
cvNamedWindow( "Capture", 0 );
|
||||
_bIsWinOn = true;
|
||||
}
|
||||
if(_bIsWinOn && !On)
|
||||
{
|
||||
cvDestroyWindow("Capture");
|
||||
_bIsWinOn = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char Capturerer::getOneCapture(const char *text)
|
||||
{
|
||||
//static int i = 0;
|
||||
// Get frame
|
||||
IplImage* frame = NULL;
|
||||
frame = cvQueryFrame( capture );
|
||||
|
||||
if( !frame )
|
||||
throw "Cannot get frame";
|
||||
|
||||
if(! captureImage)
|
||||
size = cvGetSize(frame);
|
||||
captureImage = cvCreateImage( size, 8, 3 );
|
||||
|
||||
// copy memory frame to image
|
||||
cvCopy( frame, captureImage, 0 );
|
||||
|
||||
// Flip
|
||||
cvFlip(captureImage, captureImage);
|
||||
|
||||
// label
|
||||
if (text)
|
||||
cvPutText (captureImage,text, cvPoint(0,size.height - 5) , &font, cvScalar(0,255,0));
|
||||
|
||||
|
||||
if(_bIsWinOn)
|
||||
cvShowImage( "Capture", captureImage );
|
||||
|
||||
return cvWaitKey(1);
|
||||
|
||||
}
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2007 *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef CaptureClassH
|
||||
#define CaptureClassH
|
||||
|
||||
|
||||
#include <cv.h>
|
||||
#include <highgui.h>
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class ImageAppExport Capturerer
|
||||
{
|
||||
public:
|
||||
/// Constructor with an Capture number, 0 will ask for one
|
||||
Capturerer(int num = 0);
|
||||
/// Constructor with an File name. Object will capture from that Video file
|
||||
Capturerer(const char* fileName);
|
||||
|
||||
~Capturerer();
|
||||
|
||||
static int chooseCamNum(void);
|
||||
|
||||
void setCaptureWindows(bool On);
|
||||
|
||||
char getOneCapture(const char *text=0);
|
||||
|
||||
private:
|
||||
CvCapture* capture;
|
||||
IplImage *captureImage;
|
||||
bool _bIsWinOn;
|
||||
|
||||
CvSize size;
|
||||
|
||||
// font stuff
|
||||
CvFont font;
|
||||
double hScale;
|
||||
double vScale;
|
||||
int lineWidth;
|
||||
bool useLabel;
|
||||
char buff[100];
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -1,8 +1,14 @@
|
|||
|
||||
if(OPENCV_FOUND)
|
||||
add_definitions(-DHAVE_OPENCV)
|
||||
endif(OPENCV_FOUND)
|
||||
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${COIN3D_INCLUDE_DIR}
|
||||
#${OPENCV_INCLUDE_DIR}
|
||||
${OPENCV_INCLUDE_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${SOQT_INCLUDE_DIR}
|
||||
|
@ -13,7 +19,7 @@ include_directories(
|
|||
set(ImageGui_LIBS
|
||||
Image
|
||||
FreeCADGui
|
||||
#${OpenCV_LIBRARIES}
|
||||
${OpenCV_LIBRARIES}
|
||||
${OPENGL_glu_LIBRARY}
|
||||
)
|
||||
|
||||
|
|
|
@ -31,10 +31,9 @@
|
|||
#include <Gui/BitmapFactory.h>
|
||||
#include "ImageOrientationDialog.h"
|
||||
|
||||
//#include <Mod/Image/App/CaptureClass.h>
|
||||
|
||||
//#include <cv.h>
|
||||
//#include <highgui.h>
|
||||
#if HAVE_OPENCV
|
||||
# include "opencv2/opencv.hpp"
|
||||
#endif
|
||||
|
||||
|
||||
#include "ImageView.h"
|
||||
|
@ -148,7 +147,7 @@ bool CmdCreateImagePlane::isActive()
|
|||
}
|
||||
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
#if 0
|
||||
#if HAVE_OPENCV
|
||||
DEF_STD_CMD(CmdImageCapturerTest);
|
||||
|
||||
CmdImageCapturerTest::CmdImageCapturerTest()
|
||||
|
@ -165,69 +164,26 @@ CmdImageCapturerTest::CmdImageCapturerTest()
|
|||
|
||||
void CmdImageCapturerTest::activated(int iMsg)
|
||||
{
|
||||
#if 0
|
||||
// Reading an image
|
||||
QString s = QFileDialog::getOpenFileName(Gui::getMainWindow(), QObject::tr("Choose an image file to open"), QString::null,
|
||||
QObject::tr("Images (*.png *.xpm *.jpg *.bmp)"));
|
||||
if (s.isEmpty()) return;
|
||||
using namespace cv;
|
||||
|
||||
IplImage* image = cvLoadImage(
|
||||
(const char*)s.toLatin1(),
|
||||
CV_LOAD_IMAGE_GRAYSCALE
|
||||
);
|
||||
IplImage* src = cvLoadImage( (const char*)s.toLatin1() ); //Changed for prettier show in color
|
||||
CvMemStorage* storage = cvCreateMemStorage(0);
|
||||
cvSmooth(image, image, CV_GAUSSIAN, 5, 5 );
|
||||
CvSeq* results = cvHoughCircles(
|
||||
image,
|
||||
storage,
|
||||
CV_HOUGH_GRADIENT,
|
||||
2,
|
||||
image->width/10
|
||||
);
|
||||
for( int i = 0; i < results->total; i++ ) {
|
||||
float* p = (float*) cvGetSeqElem( results, i );
|
||||
CvPoint pt = cvPoint( cvRound( p[0] ), cvRound( p[1] ) );
|
||||
cvCircle(
|
||||
src,
|
||||
pt,
|
||||
cvRound( p[2] ),
|
||||
CV_RGB(0xff,0,0)
|
||||
);
|
||||
}
|
||||
cvNamedWindow( "cvHoughCircles", 1 );
|
||||
cvShowImage( "cvHoughCircles", src);
|
||||
cvWaitKey(0);
|
||||
#else
|
||||
struct tm *newtime;
|
||||
#if defined (_MSC_VER)
|
||||
struct _timeb tstruct;
|
||||
__int64 ltime;
|
||||
#elif defined(__GNUC__)
|
||||
struct timeb tstruct;
|
||||
time_t ltime;
|
||||
#endif
|
||||
VideoCapture cap(0); // open the default camera
|
||||
if(!cap.isOpened()) // check if we succeeded
|
||||
return;
|
||||
|
||||
char buff[100];
|
||||
Capturerer cap(Capturerer::chooseCamNum());
|
||||
cap.setCaptureWindows(true);
|
||||
for(int i = 0; i< 200;i++){
|
||||
#if defined (_MSC_VER)
|
||||
_ftime( &tstruct );
|
||||
_time64( <ime );
|
||||
// Obtain coordinated universal time:
|
||||
newtime = _gmtime64( <ime ); // C4996
|
||||
#elif defined(__GNUC__)
|
||||
ftime( &tstruct );
|
||||
time( <ime );
|
||||
// Obtain coordinated universal time:
|
||||
newtime = gmtime( <ime ); // C4996
|
||||
#endif
|
||||
sprintf(buff,"%2d:%2d:%2d:%3d - %4d",newtime->tm_hour,newtime->tm_min,newtime->tm_sec,tstruct.millitm,i );
|
||||
if (cap.getOneCapture(buff)==27)
|
||||
break;
|
||||
Mat edges;
|
||||
namedWindow("edges",1);
|
||||
for(;;)
|
||||
{
|
||||
Mat frame;
|
||||
cap >> frame; // get a new frame from camera
|
||||
cvtColor(frame, edges, CV_BGR2GRAY);
|
||||
GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
|
||||
Canny(edges, edges, 0, 30, 3);
|
||||
imshow("edges", edges);
|
||||
if(waitKey(30) >= 0) break;
|
||||
}
|
||||
#endif
|
||||
// the camera will be deinitialized automatically in VideoCapture destructor
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -237,5 +193,7 @@ void CreateImageCommands(void)
|
|||
|
||||
rcCmdMgr.addCommand(new CmdImageOpen());
|
||||
rcCmdMgr.addCommand(new CmdCreateImagePlane());
|
||||
//rcCmdMgr.addCommand(new CmdImageCapturerTest());
|
||||
#if HAVE_OPENCV
|
||||
rcCmdMgr.addCommand(new CmdImageCapturerTest());
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
|||
Gui::ToolBarItem* root = StdWorkbench::setupToolBars();
|
||||
Gui::ToolBarItem* part = new Gui::ToolBarItem(root);
|
||||
part->setCommand("Image");
|
||||
*part << "Image_Open" << "Image_CreateImagePlane";
|
||||
*part << "Image_Open" << "Image_CreateImagePlane"<< "Image_CapturerTest";
|
||||
return root;
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
|
|||
Gui::ToolBarItem* root = new Gui::ToolBarItem;
|
||||
Gui::ToolBarItem* img = new Gui::ToolBarItem(root);
|
||||
img->setCommand("Image");
|
||||
*img << "Image_Open"/* << "Image_CapturerTest"*/;
|
||||
*img << "Image_Open" << "Image_CapturerTest";
|
||||
return root;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user