Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update SimpleCapture

  • Loading branch information...
commit 6b53f5e3dcea5713d472b2a97aef51252b8f12ba 1 parent 3d96778
@toshi0328 authored
View
3  .gitignore
@@ -6,9 +6,10 @@
*.tlog
*.log
*.obj
-*.vcxproj*
*.pdb
*.exe
+*vcxproj.filters
+*vcxproj.user
*~
View
86 src/SimpleCapture/SimpleCapture/MainWin.cpp
@@ -2,6 +2,9 @@
#include <cassert>
+#include <pcl/io/openni_grabber.h>
+#include <pcl/visualization/pcl_visualizer.h>
+
#include <vtkSmartPointer.h>
#include <vtkSphereSource.h>
#include <vtkPolyDataMapper.h>
@@ -15,12 +18,22 @@
#include <QtGui/QtGui>
#include <QVTKWidget.h>
-MainWin::MainWin(void)
+MainWin::MainWin(boost::shared_ptr<pcl::OpenNIGrabber> grabber):
+_grabber(grabber)
{
_mainViewWidget = new QVTKWidget();
+ _pclVis.reset (new pcl::visualization::PCLVisualizer ("", false));
+
setCentralWidget(_mainViewWidget);
- SetRenderWindowForTest(_mainViewWidget);
+ // Create a timer and fire it up every 5ms
+ _vis_timer = new QTimer (this);
+ _vis_timer->start (5);
+
+ connect (_vis_timer, SIGNAL (timeout ()), this, SLOT (timeoutSlot()));
+
+ SetRenderWindow();
+ // SetRenderWindowForTest(_mainViewWidget);
CreateActions();
@@ -31,13 +44,33 @@ MainWin::MainWin(void)
MainWin::~MainWin(void)
{
delete _mainViewWidget;
+ delete _vis_timer;
}
-void MainWin::SetRenderWindow(QVTKWidget* mainViewWidget)
+void MainWin::SetRenderWindow()
{
- assert(mainViewWidget);
+ assert(_mainViewWidget);
+
+ _mainViewWidget->SetRenderWindow( _pclVis->getRenderWindow());
+ /*
+ _pclVis->setupInteractor (_mainViewWidget->GetInteractor(), _mainViewWidget->GetRenderWindow());
+ vis_->getInteractorStyle ()->setKeyboardModifier (pcl::visualization::INTERACTOR_KB_MOD_SHIFT);
+ ui_->qvtk_widget->update ();
+ */
+
+ // Start the OpenNI data acquision
+ boost::function<void (const CloudConstPtr&)> f = boost::bind (&MainWin::CloudCallback, this, _1);
+ boost::signals2::connection c = _grabber->registerCallback (f);
+ _grabber->start ();
+
+ _mainViewWidget->update ();
+
+ // Set defaults
+ _pass.setFilterFieldName ("z");
+ _pass.setFilterLimits (0.5, 5.0);
}
+/*
void MainWin::SetRenderWindowForTest(QVTKWidget* mainViewWidget)
{
assert(mainViewWidget);
@@ -49,19 +82,56 @@ void MainWin::SetRenderWindowForTest(QVTKWidget* mainViewWidget)
sphereMapper->SetInputConnection(sphereSource->GetOutputPort());
vtkSmartPointer<vtkActor> sphereActor = vtkSmartPointer<vtkActor>::New();
sphereActor->SetMapper(sphereMapper);
-
+
//setup window
vtkSmartPointer<vtkRenderWindow> renderWindow = vtkSmartPointer<vtkRenderWindow>::New();
-
+
//setup renderer
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
renderWindow->AddRenderer(renderer);
-
+
renderer->AddActor(sphereActor);
renderer->ResetCamera();
-
+
mainViewWidget->SetRenderWindow(renderWindow);
}
+*/
+
+void MainWin::timeoutSlot()
+{
+ if (!_cloud_pass)
+ {
+ boost::this_thread::sleep (boost::posix_time::milliseconds (1));
+ return;
+ }
+
+ CloudPtr temp_cloud;
+ {
+ QMutexLocker locker (&_mtx);
+ temp_cloud.swap (_cloud_pass);
+ }
+ // Add to the 3D viewer
+ if (!_pclVis->updatePointCloud (temp_cloud, "cloud_pass"))
+ {
+ _pclVis->addPointCloud (temp_cloud, "cloud_pass");
+ _pclVis->resetCameraViewpoint ("cloud_pass");
+ }
+ FPS_CALC ("visualization");
+ _mainViewWidget->update ();
+}
+
+
+void MainWin::CloudCallback(const CloudConstPtr& cloud)
+{
+ QMutexLocker locker (&_mtx);
+ FPS_CALC ("computation");
+
+ // Computation goes here
+ _cloud_pass.reset (new Cloud);
+ _pass.setInputCloud (cloud);
+ _pass.filter (*_cloud_pass);
+}
+
void MainWin::CreateActions()
{
View
39 src/SimpleCapture/SimpleCapture/MainWin.h
@@ -1,6 +1,19 @@
#pragma once
+#include "common.h"
+
#include "Qt/QMainWindow.h"
+#include "Qt/QMutex.h"
+
+#include <pcl/filters/passthrough.h>
+
+namespace pcl{
+ class OpenNIGrabber;
+ namespace visualization
+ {
+ class PCLVisualizer;
+ }
+};
class QAction;
class QLabel;
@@ -11,31 +24,39 @@ class MainWin : public QMainWindow
// Q_OBJECT
public:
- MainWin(void);
+ MainWin(boost::shared_ptr<pcl::OpenNIGrabber> grabber);
~MainWin(void);
protected:
// void closeEvent(QCloseEvent *event);
private slots:
- void newFile();
- void open();
- bool save();
- bool saveAs();
- void about();
+ void timeoutSlot();
private:
- void CreateActions();
+ void CloudCallback(const CloudConstPtr& cloud);
- void SetRenderWindow(QVTKWidget* mainViewWidget);
- void SetRenderWindowForTest(QVTKWidget* mainViewWidget);
+ void CreateActions();
+ void SetRenderWindow();
+// void SetRenderWindowForTest(QVTKWidget* mainViewWidget);
private:
QVTKWidget* _mainViewWidget;
+ boost::shared_ptr<pcl::visualization::PCLVisualizer> _pclVis;
+ boost::shared_ptr<pcl::OpenNIGrabber> _grabber;
+
+ CloudPtr _cloud_pass;
+ pcl::PassThrough<pcl::PointXYZRGB> _pass;
+
+ QTimer* _vis_timer;
+ QMutex _mtx;
QAction* _newAct;
QAction* _openAct;
QAction* _aboutQtAction;
+
+
+
};
View
170 src/SimpleCapture/SimpleCapture/SimpleCapture.vcxproj
@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{59658048-3ACB-49ED-ADB4-6F85D2FFB4BB}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>SimpleCapture</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>../../library/Eigen/include;../../library/boost/include;../../library/PCL/include;../../library/Qt/include;../../library/VTK5_8_0/include/vtk-5.8;$(OPEN_NI_INCLUDE)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>../../library/Boost/lib/;$(OPEN_NI_LIB64);../../library/PCL/lib/$(Configuration);../../library/Qt/lib/$(Configuration);../../library/VTK5_8_0/lib/vtk-5.8/$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>ws2_32.lib;comctl32.lib;wsock32.lib;vfw32.lib;opengl32.lib;pcl_apps-gd.lib;pcl_common-gd.lib;pcl_features-gd.lib;pcl_filters-gd.lib;pcl_io-gd.lib;pcl_kdtree-gd.lib;pcl_keypoints-gd.lib;pcl_octree-gd.lib;pcl_range_image-gd.lib;pcl_range_image_border_extractor-gd.lib;pcl_registration-gd.lib;pcl_sample_consensus-gd.lib;pcl_search-gd.lib;pcl_segmentation-gd.lib;pcl_visualization-gd.lib;pcl_surface-gd.lib;QAxContainerd.lib;QAxServerd.lib;Qt3Supportd4.lib;QtCLucened4.lib;QtCored4.lib;QtDeclaratived4.lib;QtDesignerComponentsd4.lib;QtDesignerd4.lib;QtGuid4.lib;QtHelpd4.lib;qtmaind.lib;QtMultimediad4.lib;QtNetworkd4.lib;QtOpenGLd4.lib;QtScriptd4.lib;QtScriptToolsd4.lib;QtSqld4.lib;QtSvgd4.lib;QtTestd4.lib;QtUiToolsd.lib;QtWebKitd4.lib;QtXmld4.lib;QtXmlPatternsd4.lib;QVTK-gd.lib;vtkalglib-gd.lib;vtkCharts-gd.lib;vtkCommon-gd.lib;vtkDICOMParser-gd.lib;vtkexoIIc-gd.lib;vtkexpat-gd.lib;vtkFiltering-gd.lib;vtkfreetype-gd.lib;vtkftgl-gd.lib;vtkGenericFiltering-gd.lib;vtkGeovis-gd.lib;vtkGraphics-gd.lib;vtkhdf5-gd.lib;vtkHybrid-gd.lib;vtkImaging-gd.lib;vtkInfovis-gd.lib;vtkIO-gd.lib;vtkjpeg-gd.lib;vtklibxml2-gd.lib;vtkmetaio-gd.lib;vtkNetCDF_cxx-gd.lib;vtkNetCDF-gd.lib;vtkpng-gd.lib;vtkproj4-gd.lib;vtkRendering-gd.lib;vtksqlite-gd.lib;vtksys-gd.lib;vtktiff-gd.lib;vtkverdict-gd.lib;vtkViews-gd.lib;vtkVolumeRendering-gd.lib;vtkWidgets-gd.lib;vtkzlib-gd.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <PostBuildEvent>
+ <Command>copy /y ..\..\library\PCL\bin\$(Configuration)\pcl_io-gd.dll $(OutDir)
+copy /y ..\..\library\PCL\bin\$(Configuration)\pcl_common-gd.dll $(OutDir)
+copy /y ..\..\library\PCL\bin\$(Configuration)\pcl_visualization-gd.dll $(OutDir)
+copy /y ..\..\library\PCL\bin\$(Configuration)\pcl_kdtree-gd.dll $(OutDir)
+copy /y ..\..\library\PCL\bin\$(Configuration)\pcl_range_image-gd.dll $(OutDir)
+copy /y ..\..\library\PCL\bin\$(Configuration)\pcl_filters-gd.dll $(OutDir)
+copy /y ..\..\library\PCL\bin\$(Configuration)\pcl_sample_consensus-gd.dll $(OutDir)
+copy /y ..\..\library\PCL\bin\$(Configuration)\pcl_search-gd.dll $(OutDir)
+copy /y ..\..\library\PCL\bin\$(Configuration)\pcl_octree-gd.dll $(OutDir)
+copy /y ..\..\library\Qt\bin\$(Configuration)\QtCored4.dll $(OutDir)
+copy /y ..\..\library\Qt\bin\$(Configuration)\QtGuid4.dll $(OutDir)</Command>
+ <Message>DLL を取得</Message>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>../../library/Qt/include;../../library/VTK5_8_0/include/vtk-5.8</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>../../library/Qt/lib/$(Configuration);../../library/VTK5_8_0/lib/vtk-5.8/$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>ws2_32.lib;comctl32.lib;wsock32.lib;vfw32.lib;opengl32.lib;QtWebKitd4.lib;QtXmlPatternsd4.lib;QtNetworkd4.lib;QtGuid4.lib;QtSqld4.lib;QtCored4.lib;QVTK-gd.lib;vtkalglib-gd.lib;vtkCharts-gd.lib;vtkCommon-gd.lib;vtkDICOMParser-gd.lib;vtkexoIIc-gd.lib;vtkexpat-gd.lib;vtkFiltering-gd.lib;vtkfreetype-gd.lib;vtkftgl-gd.lib;vtkGenericFiltering-gd.lib;vtkGeovis-gd.lib;vtkGraphics-gd.lib;vtkhdf5-gd.lib;vtkHybrid-gd.lib;vtkImaging-gd.lib;vtkInfovis-gd.lib;vtkIO-gd.lib;vtkjpeg-gd.lib;vtklibxml2-gd.lib;vtkmetaio-gd.lib;vtkNetCDF_cxx-gd.lib;vtkNetCDF-gd.lib;vtkpng-gd.lib;vtkproj4-gd.lib;vtkRendering-gd.lib;vtksqlite-gd.lib;vtksys-gd.lib;vtktiff-gd.lib;vtkverdict-gd.lib;vtkViews-gd.lib;vtkVolumeRendering-gd.lib;vtkWidgets-gd.lib;vtkzlib-gd.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="main.cpp" />
+ <ClCompile Include="MainWin.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="common.h" />
+ <ClInclude Include="MainWin.h" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
View
24 src/SimpleCapture/SimpleCapture/common.h
@@ -0,0 +1,24 @@
+
+#include <boost/shared_ptr.hpp>
+
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
+
+typedef pcl::PointCloud<pcl::PointXYZRGB> Cloud;
+typedef Cloud::Ptr CloudPtr;
+typedef Cloud::ConstPtr CloudConstPtr;
+
+#define FPS_CALC(_WHAT_) \
+ do \
+{ \
+ static unsigned count = 0;\
+ static double last = pcl::getTime ();\
+ double now = pcl::getTime (); \
+ ++count; \
+ if (now - last >= 1.0) \
+{ \
+ std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(now - last) << " Hz" << std::endl; \
+ count = 0; \
+ last = now; \
+} \
+}while(false)
View
14 src/SimpleCapture/SimpleCapture/main.cpp
@@ -1,11 +1,23 @@
+#include "common.h"
+
+#include <pcl/io/openni_grabber.h>
+
#include <Qt/QApplication.h>
#include "MainWin.h"
int main (int argc, char ** argv)
{
+ // Open the first available camera
+ boost::shared_ptr<pcl::OpenNIGrabber> grabber(new pcl::OpenNIGrabber("#1"));
+ // Check if an RGB stream is provided
+ if (!grabber->providesCallback<pcl::OpenNIGrabber::sig_cb_openni_point_cloud_rgb> ())
+ {
+ return (-1);
+ }
+
QApplication app(argc, argv);
- MainWin mainWin;
+ MainWin mainWin(grabber);
mainWin.show();
return app.exec();
}
Please sign in to comment.
Something went wrong with that request. Please try again.