Skip to content
Snippets Groups Projects
Commit 034329f3 authored by faber's avatar faber
Browse files

Updates for OpenCL2, OpenCV3/4

Introduced cl2.hpp; corrected OpenCV libraries (for OpenCV3); corrected
waitkey() for int->char->-1 peculiarities
parent db58abfd
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// Author : // Author :
// Version : // Version :
// Copyright : Your copyright notice // Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================ //============================================================================
...@@ -11,7 +10,7 @@ ...@@ -11,7 +10,7 @@
#include <sstream> #include <sstream>
#include <stdlib.h> #include <stdlib.h>
#include "cl.hpp" #include "cl2.hpp"
/* /*
* VECTOR_CLASS and STRING_CLASS are defined by OpenCL so that * VECTOR_CLASS and STRING_CLASS are defined by OpenCL so that
...@@ -20,10 +19,12 @@ ...@@ -20,10 +19,12 @@
* all these definitions available * all these definitions available
*/ */
#ifndef STRING_CLASS #ifndef STRING_CLASS
#define STRING_CLASS cl::STRING_CLASS #define STRING_CLASS ::std::string
//cl::STRING_CLASS
#endif #endif
#ifndef VECTOR_CLASS #ifndef VECTOR_CLASS
#define VECTOR_CLASS cl::VECTOR_CLASS #define VECTOR_CLASS ::std::vector
//cl::VECTOR_CLASS
#endif #endif
/* /*
......
...@@ -73,10 +73,16 @@ ...@@ -73,10 +73,16 @@
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.207526064" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug"> <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.207526064" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug">
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.link.option.libs.982738935" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs"> <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.link.option.libs.982738935" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" useByScannerDiscovery="false" valueType="libs">
<listOptionValue builtIn="false" value="opencv_highgui"/> <listOptionValue builtIn="false" value="opencv_highgui"/>
<listOptionValue builtIn="false" value="opencv_videoio"/>
<listOptionValue builtIn="false" value="opencv_imgcodecs"/>
<listOptionValue builtIn="false" value="opencv_imgproc"/>
<listOptionValue builtIn="false" value="opencv_core"/> <listOptionValue builtIn="false" value="opencv_core"/>
<listOptionValue builtIn="false" value="OpenCL"/> <listOptionValue builtIn="false" value="OpenCL"/>
......
cmake_minimum_required( VERSION 3.1 ) cmake_minimum_required( VERSION 3.1 )
project( parallel_worlds_1 ) project( parallel_worlds_1 )
set( EXECUTABLE parallel_worlds_1 ) set( EXECUTABLE ${PROJECT_NAME} )
if( MSVC ) if( MSVC )
message( "MSVC: adding compiler flags" ) message( "MSVC: adding compiler flags" )
......
...@@ -6,19 +6,22 @@ ...@@ -6,19 +6,22 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "cl.hpp" #include <string>
#include <vector>
#include "cl2.hpp"
/* /*
* VECTOR_CLASS and STRING_CLASS are defined by OpenCL so that * VECTOR_CLASS and STRING_CLASS are defined by OpenCL 1.x BUT NOT 2.x(!)
* the user may use her own implementation of these classes, if she * so that the user may use her own implementation of these classes, if she
* wants to avoid the STL; the defines below are only safeguards to have * wants to avoid the STL; the defines below are only safeguards to have
* all these definitions available * all these definitions available
*/ */
#ifndef STRING_CLASS #ifndef STRING_CLASS
#define STRING_CLASS cl::STRING_CLASS #define STRING_CLASS ::std::string
#endif #endif
#ifndef VECTOR_CLASS #ifndef VECTOR_CLASS
#define VECTOR_CLASS cl::VECTOR_CLASS #define VECTOR_CLASS ::std::vector
#endif #endif
/* /*
......
...@@ -27,7 +27,7 @@ int main(int argc, const char** argv) { ...@@ -27,7 +27,7 @@ int main(int argc, const char** argv) {
cv::namedWindow("preview", 0); cv::namedWindow("preview", 0);
cv::namedWindow("converted", 0); cv::namedWindow("converted", 0);
while (cv::waitKey(10) < 0) { while (((char)cv::waitKey(10)) <= -1) {
if (cameraOn && !capture.read(frame)) if (cameraOn && !capture.read(frame))
exit(3); exit(3);
......
...@@ -73,10 +73,16 @@ ...@@ -73,10 +73,16 @@
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.207526064" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug"> <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.207526064" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug">
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.link.option.libs.982738935" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs"> <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.link.option.libs.982738935" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" useByScannerDiscovery="false" valueType="libs">
<listOptionValue builtIn="false" value="opencv_highgui"/> <listOptionValue builtIn="false" value="opencv_highgui"/>
<listOptionValue builtIn="false" value="opencv_videoio"/>
<listOptionValue builtIn="false" value="opencv_imgcodecs"/>
<listOptionValue builtIn="false" value="opencv_imgproc"/>
<listOptionValue builtIn="false" value="opencv_core"/> <listOptionValue builtIn="false" value="opencv_core"/>
<listOptionValue builtIn="false" value="OpenCL"/> <listOptionValue builtIn="false" value="OpenCL"/>
......
cmake_minimum_required( VERSION 3.1 ) cmake_minimum_required( VERSION 3.1 )
project( parallel_worlds_2 ) project( parallel_worlds_2 )
set( EXECUTABLE parallelwelten_2 ) set( EXECUTABLE ${PROJECT_NAME} )
if( MSVC ) if( MSVC )
message( "MSVC: adding compiler flags" ) message( "MSVC: adding compiler flags" )
......
...@@ -6,19 +6,22 @@ ...@@ -6,19 +6,22 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "cl.hpp" #include <string>
#include <vector>
#include "cl2.hpp"
/* /*
* VECTOR_CLASS and STRING_CLASS are defined by OpenCL so that * VECTOR_CLASS and STRING_CLASS are defined by OpenCL 1.x BUT NOT 2.x(!)
* the user may use her own implementation of these classes, if she * so that the user may use her own implementation of these classes, if she
* wants to avoid the STL; the defines below are only safeguards to have * wants to avoid the STL; the defines below are only safeguards to have
* all these definitions available * all these definitions available
*/ */
#ifndef STRING_CLASS #ifndef STRING_CLASS
#define STRING_CLASS cl::STRING_CLASS #define STRING_CLASS ::std::string
#endif #endif
#ifndef VECTOR_CLASS #ifndef VECTOR_CLASS
#define VECTOR_CLASS cl::VECTOR_CLASS #define VECTOR_CLASS ::std::vector
#endif #endif
/* /*
......
...@@ -27,7 +27,7 @@ int main(int argc, const char** argv) { ...@@ -27,7 +27,7 @@ int main(int argc, const char** argv) {
cv::namedWindow("preview", 0); cv::namedWindow("preview", 0);
cv::namedWindow("converted", 0); cv::namedWindow("converted", 0);
while (cv::waitKey(10) < 0) { while (((char)cv::waitKey(10)) <= -1) {
if (cameraOn && !capture.read(frame)) if (cameraOn && !capture.read(frame))
exit(3); exit(3);
......
...@@ -73,10 +73,16 @@ ...@@ -73,10 +73,16 @@
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.207526064" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug"> <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.207526064" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug">
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.link.option.libs.982738935" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs"> <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.link.option.libs.982738935" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" useByScannerDiscovery="false" valueType="libs">
<listOptionValue builtIn="false" value="opencv_highgui"/> <listOptionValue builtIn="false" value="opencv_highgui"/>
<listOptionValue builtIn="false" value="opencv_videoio"/>
<listOptionValue builtIn="false" value="opencv_imgcodecs"/>
<listOptionValue builtIn="false" value="opencv_imgproc"/>
<listOptionValue builtIn="false" value="opencv_core"/> <listOptionValue builtIn="false" value="opencv_core"/>
<listOptionValue builtIn="false" value="OpenCL"/> <listOptionValue builtIn="false" value="OpenCL"/>
...@@ -248,5 +254,7 @@ ...@@ -248,5 +254,7 @@
<storageModule moduleId="refreshScope"/> <storageModule moduleId="refreshScope"/>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject> </cproject>
cmake_minimum_required( VERSION 3.1 ) cmake_minimum_required( VERSION 3.1 )
project( parallel_worlds_3 ) project( parallel_worlds_3 )
set( EXECUTABLE parallelwelten_3 ) set( EXECUTABLE ${PROJECT_NAME} )
if( MSVC ) if( MSVC )
message( "MSVC: adding compiler flags" ) message( "MSVC: adding compiler flags" )
......
...@@ -44,7 +44,7 @@ private: ...@@ -44,7 +44,7 @@ private:
for (VECTOR_CLASS<cl::Platform>::iterator pit = platforms.begin(); for (VECTOR_CLASS<cl::Platform>::iterator pit = platforms.begin();
platforms.end() != pit; ++pit) { platforms.end() != pit; ++pit) {
// try to find a device of type devType // try to find a device of type devType
CHECK_ERROR(pit->getDevices(devType, &deviceVector)); pit->getDevices(devType, &deviceVector);
/* the C-way: /* the C-way:
* cl_int clGetDeviceIDs (cl_platform_id platform, * cl_int clGetDeviceIDs (cl_platform_id platform,
* cl_device_type device_type, * cl_device_type device_type,
......
...@@ -6,19 +6,22 @@ ...@@ -6,19 +6,22 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "cl.hpp" #include <string>
#include <vector>
#include "cl2.hpp"
/* /*
* VECTOR_CLASS and STRING_CLASS are defined by OpenCL so that * VECTOR_CLASS and STRING_CLASS are defined by OpenCL 1.x BUT NOT 2.x(!)
* the user may use her own implementation of these classes, if she * so that the user may use her own implementation of these classes, if she
* wants to avoid the STL; the defines below are only safeguards to have * wants to avoid the STL; the defines below are only safeguards to have
* all these definitions available * all these definitions available
*/ */
#ifndef STRING_CLASS #ifndef STRING_CLASS
#define STRING_CLASS cl::STRING_CLASS #define STRING_CLASS ::std::string
#endif #endif
#ifndef VECTOR_CLASS #ifndef VECTOR_CLASS
#define VECTOR_CLASS cl::VECTOR_CLASS #define VECTOR_CLASS ::std::vector
#endif #endif
/* /*
......
...@@ -36,7 +36,7 @@ int main(int argc, const char** argv) { ...@@ -36,7 +36,7 @@ int main(int argc, const char** argv) {
cv::namedWindow("edge", 0); cv::namedWindow("edge", 0);
cv::namedWindow("effect", 0); cv::namedWindow("effect", 0);
while (cv::waitKey(10) < 0) { while (((char)cv::waitKey(10)) <= -1) {
if (cameraOn && !capture.read(frame)) if (cameraOn && !capture.read(frame))
exit(3); exit(3);
greyFilter(frame.data, convertedFrame.data, w, h); greyFilter(frame.data, convertedFrame.data, w, h);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment