yumetodo / Scatto_continuo_v3

高速デスクトップ連写プログラム。OpenCV、Win32API使用
MIT License
1 stars 0 forks source link

cv::imwriteで例外発生 #1

Open yumetodo opened 8 years ago

yumetodo commented 8 years ago

エラーメッセージは

0x008F57C0 (opencv_imgcodecs300.dll) で例外がスローされました (Scatto_continuo_v3.exe 内): 0xC0000005: 場所 0x07F52000 の読み取り中にアクセス違反が発生しました

cv::MatコンストラクタにcreateDIBSectionでアロケートしbitbltでキャプチャーしたメモリー領域のポインタをコピーなしに渡してはいけないのだろうか・・・。

MaverickTse commented 8 years ago

バグです: https://github.com/Itseez/opencv/issues/5227

yumetodo commented 8 years ago

あやや・・・

yumetodo commented 8 years ago

自分用参考リンクまとめ

MaverickTse commented 8 years ago

Please check if your filename of the output file contains \ . i.e. change "D:\capture.png" to "D:/capture.png" I can successfully output an PNG using the OpenCV Git repo build with Intel compiler. Also make sure there are no OLD opencv dll folder in your PATH

MaverickTse commented 8 years ago

another way is "D:\capture.png". Going to test VC-compiled lib later

MaverickTse commented 8 years ago

VC-compiled lib is also fine.

MaverickTse commented 8 years ago

Should be fine for an up-to-date OCV build. Confirmed with both 32bit and 64bit, with and without CUDA and OpenEXR.

yumetodo commented 8 years ago

デフォルト設定(case argc==1)では、出力ファイル名は絶対パスではなくファイル名のみをcv::imwriteに渡しています。

・・・もしかしてVS2015のせい・・・?

MaverickTse commented 8 years ago

あ、それな! vs2015_rubbish OpenCVをビルドしようと落ちるなんて(おなじみの0xC0000005) もうVS2015使わないでくれよ…

yumetodo commented 8 years ago

0xC0000005!? こっちは再ビルドしようとしたら Itseez/opencv#5007 と同じ症状が出ました・・・。

MaverickTse commented 8 years ago

もうVS2015やめて、私のビルドを使えば? https://t.co/u2kLwgz9nC

あらかにVS2015はまだProduction qualityではない

yumetodo commented 8 years ago

そう思って、VSをEditorに、msys2 mingwでcompileにしようとしています。

VS2015じゃないとC++11の一部機能がIntelliSenseしてくれないですし。

MaverickTse commented 8 years ago

いっそうVSをゴミ箱にいれて、代わりにCodeBlockやEclipseを使えば?(難しいよね…分かりますw) それに、最新機能に頼り過ぎるとは…初心者にあまりよろしくないと思う。

もしLinux に抵抗がないなら、Linux Virtual Machineをセットし、Clang+CodeBlock/CodeLiteはすごく楽(C++11ほぼ100%対応)

yumetodo commented 8 years ago

Linuxは・・・Virtual Boxはやりたくないし、デュアルブートはめんdだし・・・。

それに、最新機能に頼り過ぎるとは…初心者にあまりよろしくないと思う。

auto returnning type detectionとu8-string lieteralとdefult/delete指定を私から奪わないでw

MaverickTse commented 8 years ago

CodeBlock+TDM-GCC: autoやrange-based forやu8 syntaxもちゃんと分かる cb_tdm_u8

http://forums.codeblocks.org/index.php/board,20.0.html http://wiki.codeblocks.org/index.php/Installing_a_supported_compiler#.28Unofficial.29_TDM_-_.22Twilight_Dragon_Media.22

yumetodo commented 8 years ago

@MaverickTse あれからしばらくたち、 Visual Studio 2015 Update 1 OpenCV 3.1

となって試したら、Debugビルドでは失敗し、Releaseビルドでは成功するという謎事態。archは関係ないっぽい

わけがわからないよ!

default default 1 1

General configuration for OpenCV 3.1.0 =====================================
  Version control:               unknown

  Platform:
    Host:                        Windows 6.1.7601 AMD64
    CMake:                       3.4.1
    CMake generator:             Visual Studio 14 2015
    CMake build tool:            C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild
.exe
    MSVC:                        1900

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                C:/Program Files (x86)/Microsoft Visual Studio
14.0/VC/bin/cl.exe  (ver 19.0.23506.0)
    C++ flags (Release):         /DWIN32 /D_WINDOWS /W4 /GR /EHa  /D _CRT_SECURE
_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigob
j /arch:SSE2 /Oi /fp:fast  /wd4251 /wd4324 /wd4275 /wd4589 /MP4  /MD /O2 /Ob2 /D
 NDEBUG  /Zi
    C++ flags (Debug):           /DWIN32 /D_WINDOWS /W4 /GR /EHa  /D _CRT_SECURE
_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigob
j /arch:SSE2 /Oi /fp:fast  /wd4251 /wd4324 /wd4275 /wd4589 /MP4  /D_DEBUG /MDd /
Zi /Ob0 /Od /RTC1
    C Compiler:                  C:/Program Files (x86)/Microsoft Visual Studio
14.0/VC/bin/cl.exe
    C flags (Release):           /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRE
CATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /arch:S
SE2 /Oi /fp:fast    /MP4  /MD /O2 /Ob2 /D NDEBUG  /Zi
    C flags (Debug):             /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRE
CATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /arch:S
SE2 /Oi /fp:fast    /MP4  /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1
    Linker flags (Release):      /machine:X86  /INCREMENTAL:NO  /debug
    Linker flags (Debug):        /machine:X86  /debug /INCREMENTAL
    Precompiled headers:         YES
    Extra dependencies:          comctl32 gdi32 ole32 setupapi ws2_32 vfw32
    3rdparty dependencies:       zlib libjpeg libwebp libpng libtiff libjasper I
lmImf

  OpenCV modules:
    To be built:                 core flann imgproc ml photo video imgcodecs sha
pe videoio highgui objdetect superres ts features2d calib3d stitching videostab
python3
    Disabled:                    python2 world
    Disabled by dependency:      -
    Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d
cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarp
ing cudev java viz

  Windows RT support:            NO

  GUI:
    QT:                          NO
    Win32 UI:                    YES
    OpenGL support:              NO
    VTK support:                 NO

  Media I/O:
    ZLib:                        build (ver 1.2.8)
    JPEG:                        build (ver 90)
    WEBP:                        build (ver 0.3.1)
    PNG:                         build (ver 1.6.19)
    TIFF:                        build (ver 42 - 4.0.2)
    JPEG 2000:                   build (ver 1.900.1)
    OpenEXR:                     build (ver 1.7.1)
    GDAL:                        NO

  Video I/O:
    Video for Windows:           YES
    DC1394 1.x:                  NO
    DC1394 2.x:                  NO
    FFMPEG:                      YES (prebuilt binaries)
      codec:                     YES (ver 56.41.100)
      format:                    YES (ver 56.36.101)
      util:                      YES (ver 54.27.100)
      swscale:                   YES (ver 3.1.101)
      resample:                  NO
      gentoo-style:              YES
    GStreamer:                   NO
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    OpenNI2:                     NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    DirectShow:                  YES
    Media Foundation:            NO
    XIMEA:                       NO
    Intel PerC:                  NO

  Parallel framework:            TBB (ver 4.4 interface 9002)

  Other third-party libraries:
    Use IPP:                     9.0.1 [9.0.1]
         at:                     C:/lib/opencv-3.1.0/3rdparty/ippicv/unpack/ippi
cv_win
    Use IPP Async:               NO
    Use Eigen:                   YES (ver 3.2.7)
    Use Cuda:                    NO
    Use OpenCL:                  YES
    Use custom HAL:              NO

  OpenCL:
    Version:                     dynamic
    Include path:                C:/lib/opencv-3.1.0/3rdparty/include/opencl/1.2

    Use AMDFFT:                  NO
    Use AMDBLAS:                 NO

  Python 2:
    Interpreter:                 C:/Python34/python.exe (ver 3.4.4)

  Python 3:
    Interpreter:                 C:/Python34/python.exe (ver 3.4.4)
    Libraries:                   C:/Python34/libs/python34.lib (ver 3.4.4)
    numpy:                       C:/Python34/lib/site-packages/numpy/core/includ
e (ver 1.10.2)
    packages path:               C:/Python34/Lib/site-packages

  Python (for build):            C:/Python34/python.exe

  Java:
    ant:                         NO
    JNI:                         NO
    Java wrappers:               NO
    Java tests:                  NO

  Matlab:                        Matlab not found or implicitly disabled

  Documentation:
    Doxygen:                     D:/Program1/doxygen-1.8.10.windows.x64.bin/doxy
gen.exe (ver 1.8.10)
    PlantUML:                    NO

  Tests and samples:
    Tests:                       YES
    Performance tests:           YES
    C/C++ Examples:              NO

  Install path:                  C:/lib/opencv-3.1.0/build/install

  cvconfig.h is in:              C:/lib/opencv-3.1.0/build
-----------------------------------------------------------------
MaverickTse commented 8 years ago

you are linking with the wrong lib. DEBUG build should call the DLL with the name opencv_*310d.dll (note the "d")

yumetodo commented 8 years ago

@MaverickTse opencv_imgcodecs310.libじゃなくてopencv_imgcodecs310d.libか、一個だけ違うとか気が付かなかった・・・

ありがとうございます。

yumetodo commented 8 years ago

ええい https://github.com/yumetodo/Scatto_continuo_v3/commit/d7126e1cddb665d050f4a0c65ae582fa62baa712 このcommitが原因か。

MaverickTse commented 8 years ago

just recall that a few months ago, I encountered a BUG in OpenCV where imgcodec crash when writing certain image formats, but fine when writing BMP. You may wish to test this possibility, by changing the output filename extension to .bmp

yumetodo commented 8 years ago

@MaverickTse

You may wish to test this possibility, by changing the output filename extension to .bmp

2 Itseez/opencv#5227 はpng書き出しがバグる、という話だったような。なぜにbmpの試験が必要なのだろう。

https://github.com/yumetodo/Scatto_continuo_v3/commit/78cd8927c034142db9c7064467f2c32f675e3c78 までの修正及びOpenCV3.1の使用およびVisual Studio 2015 update 1でのコンパイルでは特に問題はなさそうですが、確認をお願いできますか?

Scatto_continuo_v3.exe -o tmp.jpg --no-countdown-timer
Scatto_continuo_v3.exe -o tmp.png --no-countdown-timer
Scatto_continuo_v3.exe -o tmp.bmp --no-countdown-timer