Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/Users/yuanhuaan/desktop/src/torch-opencv/src/Common.cpp:177:24: error: implicit instantiation of undefined template 'std::__1::array<int, 3>' #122

Open
anthonyyuan opened this issue May 9, 2016 · 13 comments

Comments

@anthonyyuan
Copy link

/Users/yuanhuaan/desktop/src/torch-opencv/src/Common.cpp:177:24: error: implicit instantiation
of undefined template 'std::__1::array<int, 3>'
std::array<int, 3> size;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__tuple:116:65: note:
template is declared here
template <class _Tp, size_t _Size> struct _LIBCPP_TYPE_VIS_ONLY array;
^
/Users/yuanhuaan/desktop/src/torch-opencv/src/Common.cpp:181:27: error: implicit instantiation
of undefined template 'std::__1::array<unsigned long, 3>'
std::array<size_t, 3> stride;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__tuple:116:65: note:
template is declared here
template <class _Tp, size_t _Size> struct _LIBCPP_TYPE_VIS_ONLY array;

@shrubb
Copy link
Contributor

shrubb commented May 9, 2016

@anthonyyuan
I don't understand. What is your OS? Platform? Toolchain?

@anthonyyuan
Copy link
Author

yes ,I use mac 10.11

@anthonyyuan
Copy link
Author

yuanhuaandeMacBook-Pro:cv yuanhuaan$ luarocks install cv
Installing https://raw.githubusercontent.com/torch/rocks/master/cv-scm-1.rockspec...
Using https://raw.githubusercontent.com/torch/rocks/master/cv-scm-1.rockspec... switching to 'build' mode
Cloning into 'torch-opencv'...
remote: Counting objects: 198, done.
remote: Compressing objects: 100% (176/176), done.
remote: Total 198 (delta 40), reused 77 (delta 19), pack-reused 0
Receiving objects: 100% (198/198), 1.46 MiB | 68.00 KiB/s, done.
Resolving deltas: 100% (40/40), done.
Checking connectivity... done.
cmake -E make_directory build;
cd build;
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="/Users/yuanhuaan/torch/install/bin/.." -DCMAKE_INSTALL_PREFIX="/Users/yuanhuaan/torch/install/lib/luarocks/rocks/cv/scm-1";
make

-- The C compiler identification is AppleClang 7.3.0.7030029
-- The CXX compiler identification is AppleClang 7.3.0.7030029
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Found CUDA: /usr/local/cuda (found suitable exact version "7.5")
-- Found Torch7 in /Users/yuanhuaan/torch/install
-- Found CUDA: /usr/local/cuda (found version "7.5")
-- Modules to wrap: cudaobjdetect, cudastereo, cudaimgproc, cudafeatures2d, cudabgsegm, cudaoptflow, cudafilters, cudawarping, cudaarithm, stitching, calib3d, objdetect, video, videoio, superres, photo, ml, imgproc, flann, features2d, highgui, imgcodecs,
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/luarocks_cv-scm-1-3929/torch-opencv/build
Scanning dependencies of target Common
[ 2%] Building CXX object CMakeFiles/Common.dir/src/Common.cpp.o
/tmp/luarocks_cv-scm-1-3929/torch-opencv/src/Common.cpp:175:24: error: implicit instantiation of undefined
template 'std::__1::array<int, 3>'
std::array<int, 3> size;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__tuple:117:65: note:
template is declared here
template <class _Tp, size_t _Size> struct _LIBCPP_TYPE_VIS_ONLY array;
^
/tmp/luarocks_cv-scm-1-3929/torch-opencv/src/Common.cpp:179:27: error: implicit instantiation of undefined
template 'std::__1::array<unsigned long, 3>'
std::array<size_t, 3> stride;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__tuple:117:65: note:
template is declared here
template <class _Tp, size_t _Size> struct _LIBCPP_TYPE_VIS_ONLY array;
^
2 errors generated.
make[2]: *** [CMakeFiles/Common.dir/src/Common.cpp.o] Error 1
make[1]: *** [CMakeFiles/Common.dir/all] Error 2
make: *** [all] Error 2

Error: Build error: Failed building.
yuanhuaandeMacBook-Pro:cv yuanhuaan$

@anthonyyuan
Copy link
Author

Mac 10.11.4 EI


发件人: Egor Burkov [email protected]
发送时间: 2016年5月9日 19:11
收件人: VisionLabs/torch-opencv
抄送: anthonyyuan; Mention
主题: Re: [VisionLabs/torch-opencv] /Users/yuanhuaan/desktop/src/torch-opencv/src/Common.cpp:177:24: error: implicit instantiation of undefined template 'std::__1::array<int, 3>' (#122)

@anthonyyuanhttps://github.com/anthonyyuan
I don't understand. What is your OS? Platform? Toolchain?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHubhttps://github.com//issues/122#issuecomment-217837239

shrubb added a commit that referenced this issue May 9, 2016
@shrubb
Copy link
Contributor

shrubb commented May 9, 2016

@anthonyyuan
Does it work now?

@anthonyyuan
Copy link
Author

no ,it do not work by require cv !!!!

@anthonyyuan
Copy link
Author

anthonyyuan commented May 9, 2016

I know that the reason ,but i have no solution! When i add #include "array" in command.cpp ,but it is not useful .
when i do vi Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__tuple ,and add #include "array" ,many error come up.

@shrubb
Copy link
Contributor

shrubb commented May 9, 2016

Don't edit system files.

Sorry, I have no Mac to test on. Maybe later sometime.

@anthonyyuan
Copy link
Author

when i modify that TensorWrapper::operator cv::Mat() {

if (this->tensorPtr == nullptr or this->tensorPtr->nDimension == 0) {
    return cv::Mat();
}

int numberOfDims = tensorPtr->nDimension;
// THTensor stores its dimensions sizes under long *.
// In a constructor for cv::Mat, we need const int *.
// We can't guarantee int and long to be equal.
// So we somehow need to static_cast THTensor sizes.
// TODO: get rid of array allocation

// std::array<int, 3> stride;
// std::copy(tensorPtr->size, tensorPtr->size + tensorPtr->nDimension, size.begin());

// Same thing for stride values.

// std::array<size_t, 3> stride;
// std::copy(tensorPtr->stride, tensorPtr->stride + tensorPtr->nDimension, stride.begin());

int depth = this->typeCode;

// Determine the number of channels.
int numChannels;
// cv::Mat() takes stride values in bytes, so we have to multiply by the element size:
size_t sizeMultiplier = cv::getElemSize(depth);

if (tensorPtr->nDimension <= 2) {
    // If such tensor is passed, assume that it is single-channel:
    numChannels = 1;
} else {
    // Otherwise depend on the 3rd dimension:
    numChannels = tensorPtr->size[2];
    numberOfDims = 2;
}


return  cv::Mat();

}
it can been compiled,

@anthonyyuan
Copy link
Author

yuanhuaandeMacBook-Pro:build yuanhuaan$ cmake ./
-- Found Torch7 in /Users/yuanhuaan/torch/install
-- Modules to wrap: stitching, calib3d, objdetect, video, videoio, superres, photo, ml, imgproc, flann, features2d, highgui, imgcodecs,
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/yuanhuaan/desktop/src/torch-opencv/build
yuanhuaandeMacBook-Pro:build yuanhuaan$ make
[ 6%] Built target Common
[ 13%] Built target stitching
[ 20%] Built target calib3d
[ 26%] Built target objdetect
[ 33%] Built target video
[ 40%] Built target videoio
[ 46%] Built target highgui
[ 53%] Built target imgcodecs
[ 60%] Built target photo
[ 66%] Built target imgproc
[ 73%] Built target features2d
[ 80%] Built target superres
[ 86%] Built target flann
[ 93%] Built target Classes
[100%] Built target ml
yuanhuaandeMacBook-Pro:build yuanhuaan$

@anthonyyuan
Copy link
Author

When I make install it my computer ,yuanhuaandeMacBook-Pro:build yuanhuaan$ make install
[ 6%] Built target Common
[ 13%] Built target stitching
[ 20%] Built target calib3d
[ 26%] Built target objdetect
[ 33%] Built target video
[ 40%] Built target videoio
[ 46%] Built target highgui
[ 53%] Built target imgcodecs
[ 60%] Built target photo
[ 66%] Built target imgproc
[ 73%] Built target features2d
[ 80%] Built target superres
[ 86%] Built target flann
[ 93%] Built target Classes
[100%] Built target ml
Install the project...
-- Install configuration: ""
-- Up-to-date: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/_env.lua
-- Up-to-date: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/init.lua
-- Up-to-date: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/_env_cuda.lua
-- Up-to-date: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/Classes.lua
-- Up-to-date: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/constants.lua
-- Up-to-date: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/lib
-- Installing: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/lib/libcalib3d.dylib
-- Installing: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/lib/libClasses.dylib
-- Installing: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/lib/libCommon.dylib
-- Installing: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/lib/libfeatures2d.dylib
-- Installing: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/lib/libflann.dylib
-- Installing: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/lib/libhighgui.dylib
-- Installing: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/lib/libimgcodecs.dylib
-- Installing: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/lib/libimgproc.dylib
-- Installing: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/lib/libml.dylib
-- Installing: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/lib/libobjdetect.dylib
-- Installing: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/lib/libphoto.dylib
-- Installing: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/lib/libstitching.dylib
-- Installing: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/lib/libsuperres.dylib
-- Installing: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/lib/libvideo.dylib
-- Installing: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/lib/libvideoio.dylib
-- Up-to-date: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/imgcodecs/init.lua
-- Up-to-date: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/highgui/init.lua
-- Up-to-date: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/features2d/init.lua
-- Up-to-date: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/flann/init.lua
-- Up-to-date: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/imgproc/init.lua
-- Up-to-date: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/ml/init.lua
-- Up-to-date: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/photo/init.lua
-- Up-to-date: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/superres/init.lua
-- Up-to-date: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/videoio/init.lua
-- Up-to-date: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/video/init.lua
-- Up-to-date: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/objdetect/init.lua
-- Up-to-date: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/calib3d/init.lua
-- Up-to-date: /Users/yuanhuaan/torch/install/../../../../usr/local/lua/cv/stitching/init.lua
yuanhuaandeMacBook-Pro:build yuanhuaan$

@anthonyyuan
Copy link
Author

uanhuaandeMacBook-Pro:tests yuanhuaan$ th functions.lua
/Users/yuanhuaan/torch/install/bin/luajit: /Users/yuanhuaan/torch/install/share/lua/5.1/trepl/init.lua:384: module 'cv' not found:No LuaRocks module found for cv
no field package.preload['cv']
no file '/Users/yuanhuaan/.luarocks/share/lua/5.1/cv.lua'
no file '/Users/yuanhuaan/.luarocks/share/lua/5.1/cv/init.lua'
no file '/Users/yuanhuaan/torch/install/share/lua/5.1/cv.lua'
no file '/Users/yuanhuaan/torch/install/share/lua/5.1/cv/init.lua'
no file './cv.lua'
no file '/Users/yuanhuaan/torch/install/share/luajit-2.1.0-beta1/cv.lua'
no file '/usr/local/share/lua/5.1/cv.lua'
no file '/usr/local/share/lua/5.1/cv/init.lua'
no file '/Users/yuanhuaan/.luarocks/lib/lua/5.1/cv.so'
no file '/Users/yuanhuaan/torch/install/lib/lua/5.1/cv.so'
no file './cv.so'
no file '/usr/local/lib/lua/5.1/cv.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
[C]: in function 'error'
/Users/yuanhuaan/torch/install/share/lua/5.1/trepl/init.lua:384: in function 'require'
functions.lua:1: in main chunk
[C]: in function 'dofile'
...uaan/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
[C]: at 0x0103cb7d00
yuanhuaandeMacBook-Pro:tests yuanhuaan$

@victoriastuart
Copy link

victoriastuart commented Dec 1, 2016

@anthonyyuan: I was having that same error, pretty much identically (per my system)! :-(

I'm on Arch Linux x86_64 operating (tis work) in an Anaconda Python 2.7 virtual environment, with a previous install of Torch7 (for use with OpenFace), that I wanted to use for this project,

https://github.com/szagoruyko/torch-opencv-demos

I had previously cloned and installed Torch7:

git clone https://github.com/torch/distro.git torch7 --recursive
cd torch7
bash install-deps       ## ignore warnings
./install.sh            ## takes a few minutes
## Added to ~/.bashrc: /mnt/Vancouver/apps/torch7/install/bin/torch-activate
which th
    /mnt/Vancouver/apps/torch7/install/bin/th
source ~/.bashrc
th
      ______             __   |  Torch7
     /_  __/__  ________/ /   |  Scientific computing for Lua.
      / / / _ \/ __/ __/ _ \  |  Type ? for help
     /_/  \___/_/  \__/_//_/  |  https://github.com/torch
                              |  http://torch.ch
    th>

HOWEVER, when trying to run the "demo.lua" in my current work,

/mnt/Vancouver/apps/torch-opencv-demos/imagenet_classification/demo.lua

I was getting the error, above.

So, I installed (Arch Linux) luarocks,

sudo pacman -S luarocks

... even though I presumed it was installed previously.

pacman -Ss luarocks | grep -i installed
    community/luarocks 2.4.1-1 [installed]

which luarocks
    /mnt/Vancouver/apps/torch7/install/bin/luarocks

I THEN "re-installed" cv [I also had previously installed OpenCV 3, i.e. cv2 in Python (I could import cv2 in Python, etc.)], BUT here I then needed to do this last thing (again in my terminal),

luarocks install cv

NOW, when I ran that script,

th demo.lua

it ran (see lossy, animated GIF / video screen capture, below)! :-D

[ That's my first webcam capture with that repo / demo! Not bad - CPU only no GPU! :-) ]

byzanz capture 2016-11-30 17 22 03

Update:

Also had to do

luarocks install loadcaffe

for the second (age_gender) demo, and run as

th demo.lua camera    ## webcam

not

th demo.lua `locate haarcascade_frontalface_default.xml`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants