質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.49%
C

C言語は、1972年にAT&Tベル研究所の、デニス・リッチーが主体となって作成したプログラミング言語です。 B言語の後継言語として開発されたことからC言語と命名。そのため、表記法などはB言語やALGOLに近いとされています。 Cの拡張版であるC++言語とともに、現在世界中でもっとも普及されているプログラミング言語です。

C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

Q&A

1回答

513閲覧

GPUのラプラシアン処理

carnage0216

総合スコア194

C

C言語は、1972年にAT&Tベル研究所の、デニス・リッチーが主体となって作成したプログラミング言語です。 B言語の後継言語として開発されたことからC言語と命名。そのため、表記法などはB言語やALGOLに近いとされています。 Cの拡張版であるC++言語とともに、現在世界中でもっとも普及されているプログラミング言語です。

C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

0グッド

0クリップ

投稿2018/02/05 14:00

以下のプログラムをビルドしたいのですが以下のエラーが出てしまいます。
visual studio 2017 community
windows10 64bit
opencv3.4

以下がコードです。

// laplacian by GPU // // (c)Copyright Spacesoft corp., 2013 rights reserved. // Hiro KITAYAMA //-------------------------------------------------------------------------- #include <opencv2/opencv.hpp> #include <opencv2/gpu/gpu.hpp> // <<-- #pragma comment(lib,"opencv_core246.lib") #pragma comment(lib,"opencv_gpu246.lib") // <<-- #pragma comment(lib,"opencv_highgui246.lib") //-------------------------------------------------------------------------- //main int main() { cv::Mat src = cv::imread("lenna.jpg", CV_LOAD_IMAGE_GRAYSCALE); if (src.empty()) exit(1); cv::gpu::GpuMat gpuSrc(src); cv::gpu::GpuMat gpuDst; cv::gpu::Laplacian(gpuSrc, gpuDst, 0); cv::Mat dst(gpuDst); cv::imshow("src", src); cv::imshow("dst", dst); cv::waitKey(0); return 0; } コード

追加したインクルードディレクトリC:\opencv-2.4.6\modules\core\include\opencv2\coreに保存されているファイルにmat.hppが含まれているはずなのですが、エラーで定義がされていないなど出てきます。

2018/02/05

12018/02/05 00:02 7,854 cuda_devptrs.hpp 22018/02/05 00:02 2,198 devmem2d.hpp 32018/02/05 00:02 9,465 eigen.hpp 42018/02/05 00:02 18,705 gpumat.hpp 52018/02/05 00:02 34,724 internal.hpp 62018/02/05 00:02 80,474 mat.hpp 72018/02/05 00:02 9,346 opengl_interop.hpp 82018/02/05 00:02 9,919 opengl_interop_deprecated.hpp 92018/02/05 00:02 129,109 operations.hpp 102018/02/05 00:02 57,409 types_c.h 112018/02/05 00:02 2,928 version.hpp 122018/02/05 00:02 20,743 wimage.hpp 13コード

もう一つのインクルードディレクトリC:\opencv\includeには以下のファイルがあります。

2018/01/31 17:12 <DIR> opencv 2018/02/01 13:59 <DIR> opencv2

ライブラリは

2018/02/05

12018/02/05 00:02 78,488 core_c.h 22018/02/05 00:02 7,854 cuda_devptrs.hpp 32018/02/05 00:02 2,198 devmem2d.hpp 42018/02/05 00:02 9,465 eigen.hpp 52018/02/05 00:02 18,705 gpumat.hpp 62018/02/05 00:02 34,724 internal.hpp 72018/02/05 00:02 80,474 mat.hpp 82018/02/05 00:02 9,346 opengl_interop.hpp 92018/02/05 00:02 9,919 opengl_interop_deprecated.hpp 102018/02/05 00:02 129,109 operations.hpp 112018/02/05 00:02 57,409 types_c.h 122018/02/05 00:02 2,928 version.hpp 132018/02/05 00:02 20,743 wimage.hpp 14 14 個のファイル 647,534 バイト 15 2 個のディレクトリ 1,336,668,160 バイトの空き領域 16 17C:\opencv-2.4.6\modules\core\include\opencv2\core>cd C:\opencv\include 18 19C:\opencv\include>dir 20 ドライブ C のボリューム ラベルは Windows です 21 ボリューム シリアル番号は 6ABE-A14B です 22 23 C:\opencv\include のディレクトリ 24 252018/02/01 04:07 <DIR> . 262018/02/01 04:07 <DIR> .. 272018/01/31 17:12 <DIR> opencv 282018/02/01 13:59 <DIR> opencv2 29 0 個のファイル 0 バイト 30 4 個のディレクトリ 2,519,293,952 バイトの空き領域 31 32C:\opencv\include>cd C:\opencv-3.4.0\build\lib\Release 33 34C:\opencv-3.4.0\build\lib\Release>dir 35 ドライブ C のボリューム ラベルは Windows です 36 ボリューム シリアル番号は 6ABE-A14B です 37 38 C:\opencv-3.4.0\build\lib\Release のディレクトリ 39 402018/02/04 05:23 <DIR> . 412018/02/04 05:23 <DIR> .. 422018/02/04 05:17 465,560 opencv_core340.exp 432018/02/04 05:17 771,684 opencv_core340.lib 442018/02/04 05:17 5,722,112 opencv_core340.pdb 452018/02/04 05:19 125,591 opencv_cudabgsegm340.exp 462018/02/04 05:19 215,414 opencv_cudabgsegm340.lib 472018/02/04 05:19 1,380,352 opencv_cudabgsegm340.pdb 482018/02/04 05:23 130,023 opencv_cudawarping340.exp 492018/02/04 05:23 223,832 opencv_cudawarping340.lib 502018/02/04 05:23 1,527,808 opencv_cudawarping340.pdb 512018/02/04 05:15 729 opencv_cudev340.exp 522018/02/04 05:15 1,962 opencv_cudev340.lib 532018/02/04 05:15 61,440 opencv_cudev340.pdb 542018/02/04 05:17 110,263 opencv_flann340.exp 552018/02/04 05:17 186,628 opencv_flann340.lib 562018/02/04 05:17 4,272,128 opencv_flann340.pdb 572018/02/04 05:18 112,003 opencv_fuzzy340.exp 582018/02/04 05:18 189,338 opencv_fuzzy340.lib 592018/02/04 05:18 3,239,936 opencv_fuzzy340.pdb 602018/02/04 05:17 200,946 opencv_imgproc340.exp 612018/02/04 05:17 341,720 opencv_imgproc340.lib 622018/02/04 05:17 5,582,848 opencv_imgproc340.pdb 632018/02/04 05:18 125,347 opencv_img_hash340.exp 642018/02/04 05:18 213,302 opencv_img_hash340.lib 652018/02/04 05:17 1,495,040 opencv_img_hash340.pdb 662018/02/04 05:17 143,117 opencv_ml340.exp 672018/02/04 05:17 239,206 opencv_ml340.lib 682018/02/04 05:17 3,829,760 opencv_ml340.pdb 692018/02/04 05:18 142,883 opencv_objdetect340.exp 702018/02/04 05:18 243,862 opencv_objdetect340.lib 712018/02/04 05:18 4,116,480 opencv_objdetect340.pdb 722018/02/04 05:17 118,791 opencv_phase_unwrapping340.exp 732018/02/04 05:17 206,530 opencv_phase_unwrapping340.lib 742018/02/04 05:17 3,313,664 opencv_phase_unwrapping340.pdb 752018/02/04 05:17 108,457 opencv_plot340.exp 762018/02/04 05:17 182,692 opencv_plot340.lib 772018/02/04 05:17 1,372,160 opencv_plot340.pdb 782018/02/04 05:18 128,133 opencv_reg340.exp 792018/02/04 05:18 214,596 opencv_reg340.lib 802018/02/04 05:18 1,019,904 opencv_reg340.pdb 812018/02/04 05:18 134,789 opencv_shape340.exp 822018/02/04 05:18 226,648 opencv_shape340.lib 832018/02/04 05:18 3,559,424 opencv_shape340.pdb 842018/02/04 05:17 116,163 opencv_surface_matching340.exp 852018/02/04 05:17 202,796 opencv_surface_matching340.lib 862018/02/04 05:17 2,265,088 opencv_surface_matching340.pdb 872018/02/04 05:18 132,329 opencv_video340.exp 882018/02/04 05:18 223,168 opencv_video340.lib 892018/02/04 05:18 3,518,464 opencv_video340.pdb 902018/02/04 05:18 116,019 opencv_xphoto340.exp 912018/02/04 05:18 196,460 opencv_xphoto340.lib 922018/02/04 05:18 1,568,768 opencv_xphoto340.pdb 932017/08/04 09:28 433 OpenCVConfig-version.cmake 942017/08/04 09:28 11,002 OpenCVConfig.cmake 952017/08/04 09:28 996 OpenCVModules-debug.cmake 962017/08/04 09:28 1,004 OpenCVModules-release.cmake 972017/08/04 09:28 3,224 OpenCVModules.cmake 982017/08/04 09:38 2,229,794 opencv_world330.lib 992017/08/04 09:42 2,302,458 opencv_world330d.lib

以下はエラーメッセージです。

エラー (アクティブ) 識別子 "MatExpr" が定義されていません laplacianGPU c:\opencv\include\opencv2\core\mat.hpp 1103 エラー (アクティブ) 識別子 "MatExpr" が定義されていません laplacianGPU c:\opencv\include\opencv2\core\mat.hpp 1103 エラー (アクティブ) 識別子 "MatExpr" が定義されていません laplacianGPU c:\opencv\include\opencv2\core\mat.hpp 1105 エラー (アクティブ) 識別子 "MatExpr" が定義されていません laplacianGPU c:\opencv\include\opencv2\core\mat.hpp 1105 エラー (アクティブ) 識別子 "MatExpr" が定義されていません laplacianGPU c:\opencv\include\opencv2\core\mat.hpp 1105 エラー (アクティブ) 識別子 "MatExpr" が定義されていません laplacianGPU c:\opencv\include\opencv2\core\mat.hpp 1106 エラー (アクティブ) 識別子 "MatExpr" が定義されていません laplacianGPU c:\opencv\include\opencv2\core\mat.hpp 1106 エラー (アクティブ) 識別子 "MatExpr" が定義されていません laplacianGPU c:\opencv\include\opencv2\core\mat.hpp 1108 エラー (アクティブ) 識別子 "MatExpr" が定義されていません laplacianGPU c:\opencv\include\opencv2\core\mat.hpp 1108 エラー (アクティブ) 識別子 "MatExpr" が定義されていません laplacianGPU c:\opencv\include\opencv2\core\mat.hpp 1108 エラー (アクティブ) 識別子 "MatExpr" が定義されていません laplacianGPU c:\opencv\include\opencv2\core\mat.hpp 1109 エラー (アクティブ) 識別子 "MatExpr" が定義されていません laplacianGPU c:\opencv\include\opencv2\core\mat.hpp 1109 エラー (アクティブ) 識別子 "MatExpr" が定義されていません laplacianGPU c:\opencv\include\opencv2\core\mat.hpp 1111 エラー (アクティブ) 識別子 "MatExpr" が定義されていません laplacianGPU c:\opencv\include\opencv2\core\mat.hpp 1111 c:\opencv\include\opencv2\core\mat.hpp 1379 エラー (アクティブ) 識別子 "Mat" が定義されていません laplacianGPU c:\opencv\include\opencv2\core\mat.hpp 1379 エラー (アクティブ) 識別子 "Mat" が定義されていません laplacianGPU c:\opencv\include\opencv2\core\mat.hpp 1379 エラー (アクティブ) 識別子 "Mat" が定義されていません laplacianGPU c:\opencv\include\opencv2\core\mat.hpp 1385 エラー (アクティブ) 識別子 "Mat" が定義されていません laplacianGPU c:\opencv\include\opencv2\core\mat.hpp 1385 エラー (アクティブ) 識別子 "Mat" が定義されていません laplacianGPU c:\opencv\include\opencv2\core\mat.hpp 1405 エラー (アクティブ) 識別子 "Mat" が定義されていません laplacianGPU c:\opencv\include\opencv2\core\mat.hpp 1405 エラー (アクティブ) 識別子 "Mat" が定義されていません laplacianGPU c:\opencv\include\opencv2\core\mat.hpp 1418

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

iwanote

2018/02/05 15:39

mat.hpp内はどうなっていますか?名前空間などがおかしいように見えます
carnage0216

2018/02/05 16:03

/*M/////////////////////////////////////////////////////////////////////////////////////// // // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. // // By downloading, copying, installing or using the software you agree to this license. // If you do not agree to this license, do not download, install, // copy or use the software. // // // License Agreement // For Open Source Computer Vision Library // // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. // Copyright (C) 2009, Willow Garage Inc., all rights reserved. // Copyright (C) 2013, OpenCV Foundation, all rights reserved. // Third party copyrights are property of their respective owners. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // * Redistribution's of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // * Redistribution's in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // * The name of the copyright holders may not be used to endorse or promote products // derived from this software without specific prior written permission. // // This software is provided by the copyright holders and contributors "as is" and // any express or implied warranties, including, but not limited to, the implied // warranties of merchantability and fitness for a particular purpose are disclaimed. // In no event shall the Intel Corporation or contributors be liable for any direct, // indirect, incidental, special, exemplary, or consequential damages // (including, but not limited to, procurement of substitute goods or services; // loss of use, data, or profits; or business interruption) however caused // and on any theory of liability, whether in contract, strict liability, // or tort (including negligence or otherwise) arising in any way out of // the use of this software, even if advised of the possibility of such damage. // //M*/ #ifndef OPENCV_CORE_MAT_HPP #define OPENCV_CORE_MAT_HPP #ifndef __cplusplus # error mat.hpp header must be compiled as C++ #endif #include "opencv2/core/matx.hpp" #include "opencv2/core/types.hpp" #include "opencv2/core/bufferpool.hpp" namespace cv { //! @addtogroup core_basic //! @{ enum { ACCESS_READ=1<<24, ACCESS_WRITE=1<<25, ACCESS_RW=3<<24, ACCESS_MASK=ACCESS_RW, ACCESS_FAST=1<<26 }; CV__DEBUG_NS_BEGIN class CV_EXPORTS _OutputArray; //////////////////////// Input/Output Array Arguments ///////////////////////////////// /** @brief This is the proxy class for passing read-only input arrays into OpenCV functions. It is defined as: @code typedef const _InputArray& InputArray; @endcode where _InputArray is a class that can be constructed from `Mat`, `Mat_<T>`, `Matx<T, m, n>`, `std::vector<T>`, `std::vector<std::vector<T> >`, `std::vector<Mat>`, `std::vector<Mat_<T> >`, `UMat`, `std::vector<UMat>` or `double`. It can also be constructed from a matrix expression. Since this is mostly implementation-level class, and its interface may change in future versions, we do not describe it in details. There are a few key things, though, that should be kept in mind: - When you see in the reference manual or in OpenCV source code a function that takes InputArray, it means that you can actually pass `Mat`, `Matx`, `vector<T>` etc. (see above the complete list). - Optional input arguments: If some of the input arrays may be empty, pass cv::noArray() (or simply cv::Mat() as you probably did before). - The class is designed solely for passing parameters. That is, normally you *should not* declare class members, local and global variables of this type. - If you want to design your own function or a class method that can operate of arrays of multiple types, you can use InputArray (or OutputArray) for the respective parameters. Inside a function you should use _InputArray::getMat() method to construct a matrix header for the array (without copying data). _InputArray::kind() can be used to distinguish Mat from `vector<>` etc., but normally it is not needed. Here is how you can use a function that takes InputArray : @code std::vector<Point2f> vec; // points or a circle for( int i = 0; i < 30; i++ ) vec.push_back(Point2f((float)(100 + 30*cos(i*CV_PI*2/5)), (float)(100 - 30*sin(i*CV_PI*2/5)))); cv::transform(vec, vec, cv::Matx23f(0.707, -0.707, 10, 0.707, 0.707, 20)); @endcode That is, we form an STL vector containing points, and apply in-place affine transformation to the vector using the 2x3 matrix created inline as `Matx<float, 2, 3>` instance. Here is how such a function can be implemented (for simplicity, we implement a very specific case of it, according to the assertion statement inside) : @code void myAffineTransform(InputArray _src, OutputArray _dst, InputArray _m) { // get Mat headers for input arrays. This is O(1) operation, // unless _src and/or _m are matrix expressions. Mat src = _src.getMat(), m = _m.getMat(); CV_Assert( src.type() == CV_32FC2 && m.type() == CV_32F && m.size() == Size(3, 2) ); // [re]create the output array so that it has the proper size and type. // In case of Mat it calls Mat::create, in case of STL vector it calls vector::resize. _dst.create(src.size(), src.type()); Mat dst = _dst.getMat(); for( int i = 0; i < src.rows; i++ ) for( int j = 0; j < src.cols; j++ ) { Point2f pt = src.at<Point2f>(i, j); dst.at<Point2f>(i, j) = Point2f(m.at<float>(0, 0)*pt.x + m.at<float>(0, 1)*pt.y + m.at<float>(0, 2), m.at<float>(1, 0)*pt.x + m.at<float>(1, 1)*pt.y + m.at<float>(1, 2)); } } @endcode There is another related type, InputArrayOfArrays, which is currently defined as a synonym for InputArray: @code typedef InputArray InputArrayOfArrays; @endcode It denotes function arguments that are either vectors of vectors or vectors of matrices. A separate synonym is needed to generate Python/Java etc. wrappers properly. At the function implementation level their use is similar, but _InputArray::getMat(idx) should be used to get header for the idx-th component of the outer vector and _InputArray::size().area() should be used to find the number of components (vectors/matrices) of the outer vector. */ class CV_EXPORTS _InputArray { public: enum { KIND_SHIFT = 16, FIXED_TYPE = 0x8000 << KIND_SHIFT, FIXED_SIZE = 0x4000 << KIND_SHIFT, KIND_MASK = 31 << KIND_SHIFT, NONE = 0 << KIND_SHIFT, MAT = 1 << KIND_SHIFT, MATX = 2 << KIND_SHIFT, STD_VECTOR = 3 << KIND_SHIFT, STD_VECTOR_VECTOR = 4 << KIND_SHIFT, STD_VECTOR_MAT = 5 << KIND_SHIFT, EXPR = 6 << KIND_SHIFT, OPENGL_BUFFER = 7 << KIND_SHIFT, CUDA_HOST_MEM = 8 << KIND_SHIFT, CUDA_GPU_MAT = 9 << KIND_SHIFT, UMAT =10 << KIND_SHIFT, STD_VECTOR_UMAT =11 << KIND_SHIFT, STD_BOOL_VECTOR =12 << KIND_SHIFT, STD_VECTOR_CUDA_GPU_MAT = 13 << KIND_SHIFT, STD_ARRAY =14 << KIND_SHIFT, STD_ARRAY_MAT =15 << KIND_SHIFT }; _InputArray(); _InputArray(int _flags, void* _obj); _InputArray(const Mat& m); _InputArray(const MatExpr& expr); _InputArray(const std::vector<Mat>& vec); template<typename _Tp> _InputArray(const Mat_<_Tp>& m); template<typename _Tp> _InputArray(const std::vector<_Tp>& vec); _InputArray(const std::vector<bool>& vec); template<typename _Tp> _InputArray(const std::vector<std::vector<_Tp> >& vec); _InputArray(const std::vector<std::vector<bool> >&); template<typename _Tp> _InputArray(const std::vector<Mat_<_Tp> >& vec); template<typename _Tp> _InputArray(const _Tp* vec, int n); template<typename _Tp, int m, int n> _InputArray(const Matx<_Tp, m, n>& matx); _InputArray(const double& val); _InputArray(const cuda::GpuMat& d_mat); _InputArray(const std::vector<cuda::GpuMat>& d_mat_array); _InputArray(const ogl::Buffer& buf); _InputArray(const cuda::HostMem& cuda_mem); template<typename _Tp> _InputArray(const cudev::GpuMat_<_Tp>& m); _InputArray(const UMat& um); _InputArray(const std::vector<UMat>& umv); #ifdef CV_CXX_STD_ARRAY template<typename _Tp, std::size_t _Nm> _InputArray(const std::array<_Tp, _Nm>& arr); template<std::size_t _Nm> _InputArray(const std::array<Mat, _Nm>& arr); #endif Mat getMat(int idx=-1) const; Mat getMat_(int idx=-1) const; UMat getUMat(int idx=-1) const; void getMatVector(std::vector<Mat>& mv) const; void getUMatVector(std::vector<UMat>& umv) const; void getGpuMatVector(std::vector<cuda::GpuMat>& gpumv) const; cuda::GpuMat getGpuMat() const; ogl::Buffer getOGlBuffer() const; int getFlags() const; void* getObj() const; Size getSz() const; int kind() const; int dims(int i=-1) const; int cols(int i=-1) const; int rows(int i=-1) const; Size size(int i=-1) const; int sizend(int* sz, int i=-1) const; bool sameSize(const _InputArray& arr) const; size_t total(int i=-1) const; int type(int i=-1) const; int depth(int i=-1) const; int channels(int i=-1) const; bool isContinuous(int i=-1) const; bool isSubmatrix(int i=-1) const;
carnage0216

2018/02/05 16:03

間違えました。お待ちください
guest

回答1

0

状況が掴めんのですが、OpenCV 2.4.6 と 3.4 が同居してるんですか?
んでもって双方の include-path を通してるんですか?

投稿2018/02/05 22:26

episteme

総合スコア16614

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

carnage0216

2018/02/06 01:06

そうです。 どちらか一方にまとめた方がいいでしょうか? (バージョンなどを気にせずに)
episteme

2018/02/06 01:25 編集

なにが哀しうてわざわざトラブルを呼び込むよなことするですか!?
carnage0216

2018/02/06 02:01

新しいバージョンの方に入っていないlibなどがあったため古いものと一緒に使いました。
episteme

2018/02/06 02:07

んなことしたら正しく動く保証がねぇでしょ。
carnage0216

2018/02/06 02:35

そうです。おっしゃる通りです。しかし、参考書どおりにCmake使っても得られるはずのbinのデバッグとリリースファイルが得られないのです。 本にも詳しく書いていないし、調べてもあたりよい情報が出ないため、ヤブ医者みたいですが、試行錯誤でこれが間違いではないかと色々仮定して実験しているんです。
carnage0216

2018/02/06 02:37

私のようなニワカがやらかす事にepistemeさんの怒りたいのもわかりますが、私なりに試行錯誤しているのです。(私は怒ってないです。むしろ感謝しています。
episteme

2018/02/06 06:01 編集

試行錯誤はたいへん結構なことです。それが"行き当たりばったり"でないことを祈ります。 我々プログラマは「なんかしらんが二つ混ぜたら動いた」を解決策とは認めない。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.49%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問