Ask Your Question

Matiz's profile - activity

2013-12-01 08:57:05 -0600 asked a question opencv2 ios framework error

Hi

I am trying to build the opencv framework for Xcode. I am new to the Mac world as well as opencv. I followed the instructions as given on http://docs.opencv.org/doc/tutorials/introduction/ios_install/ios_install.html I cloned the repository (opencv 2.4.7) and then tried running the python script - as per the instruction on the link

python opencv/platforms/ios/build_framework.py ios

I get the below error, can someone please help? I am using OSX 10.8.5

/Applications/gebos_third_party_apps/opencv/3rdparty/zlib/gzwrite.c:84:15: error: implicit declaration of function 'write' is invalid in C99
  [-Werror,-Wimplicit-function-declaration]
    got = write(state->fd, strm->next_in, strm->avail_in);
          ^

/Applications/gebos_third_party_apps/opencv/3rdparty/zlib/gzwrite.c:84:15: note: did you mean 'fwrite'? got = write(state->fd, strm->next_in, strm->avail_in); ^~~~~ fwrite In file included from /Applications/gebos_third_party_apps/opencv/3rdparty/zlib/gzwrite.c:6: In file included from /Applications/gebos_third_party_apps/opencv/3rdparty/zlib/gzguts.h:21: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/usr/include/stdio.h:252:9: note: 'fwrite' declared here size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict) __DARWIN_ALIAS(fwrite); ^ /Applications/gebos_third_party_apps/opencv/3rdparty/zlib/gzwrite.c:573:9: error: implicit declaration of function 'close' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (close(state->fd) == -1) ^ 2 errors generated.

** INSTALL FAILED **

The following build commands failed: CompileC /Applications/gebos_third_party_apps/ios/build/iPhoneSimulator-x86_64/3rdparty/zlib/OpenCV.build/Release-iphonesimulator/zlib.build/Objects-normal/x86_64/gzwrite.o 3rdparty/zlib/gzwrite.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler CompileC /Applications/gebos_third_party_apps/ios/build/iPhoneSimulator-x86_64/3rdparty/zlib/OpenCV.build/Release-iphonesimulator/zlib.build/Objects-normal/x86_64/gzlib.o 3rdparty/zlib/gzlib.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler CompileC /Applications/gebos_third_party_apps/ios/build/iPhoneSimulator-x86_64/3rdparty/zlib/OpenCV.build/Release-iphonesimulator/zlib.build/Objects-normal/x86_64/gzread.o 3rdparty/zlib/gzread.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler (3 failures) Traceback (most recent call last): File "opencv-lib/opencv/platforms/ios/build_framework.py", line 112, in <module> build_framework(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "../..")), os.path.abspath(sys.argv[1])) File "opencv-lib/opencv/platforms/ios/build_framework.py", line 104, in build_framework put_framework_together(srcroot, dstroot) File "opencv-lib/opencv/platforms/ios/build_framework.py", line 80, in put_framework_together shutil.copytree(tdir0 + "/install/include/opencv2", dstdir + "/Headers") File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 168, in copytree names = os.listdir(src) OSError: [Errno 2] No such file or directory: '../build/iPhoneOS-arm64/install/include/opencv2'

2013-08-19 11:53:44 -0600 received badge  Student (source)
2013-08-19 10:43:52 -0600 asked a question cascade classification object detection

Hello,

I have been trying to experiment with opencv functions for object detection using cascade classification. However I have not been able to get it working correctly. I have taken a simple example of cupboard door handle, which I would like to detect in images. Please find the zip of my data as attached (link - link text). This contains negative files (55 files) and positive files (66 files). The commands which I have used for the experiment are as below (I am using Ubuntu 12.10 version, along with QT Creator and Opencv libraries (2.3))

  1. find ./negatives -name '*.jpg' > negatives.dat

  2. find ./positives -name '*.jpg' > positives.dat

  3. perl createtrainsamples_my.pl positives.dat negatives.dat output (please note that I have modified the command within the perl script to use w as 10 and h as 70 (most of the positive images are apprxmt. with this ratio) (essentially the script uses the below command - opencv_traincascade -data traincascade -vec samples.vec -bg negatives.dat -numPos 66 -numNeg 55 -numStages 16 -featureType LBP -w 10 -h 70 -bt GAB -minHitRate 0.995 -maxFalseAlarmRate 0.3 -weightTrimRate 0.95 -maxDepth 1 -maxWeakCount 100 -maxCatCount 256 -featSize 1)

  4. find ./output -name '*.vec' > samples.dat

  5. mergevec samples.dat samples.vec w 10 h 70 (this i did it from windows as there were errors on Ubuntu)

  6. opencv_traincascade -data traincascade -vec samples.vec -bg negatives.dat -numPos 66 -numNeg 55 -numStages 16 -featureType LBP -w 10 -h 70 -bt GAB -minHitRate 0.995 -maxFalseAlarmRate 0.3 -weightTrimRate 0.95 -maxDepth 1 -maxWeakCount 100 -maxCatCount 256 -featSize 1

I have then renamed traincascade\cascade.xml to cascadetest2.xml in the source code as below

 #include "windowclassifier.h"
 #include "opencv2/objdetect/objdetect.hpp"
 #include "opencv2/highgui/highgui.hpp"
 #include "opencv2/imgproc/imgproc.hpp"

 #include <iostream>
 #include <stdio.h>

WindowClassifier::WindowClassifier()
{
}



 using namespace std;
 using namespace cv;

 /** Function Headers */
 void detectAndDisplay1( Mat frame );


 /** Global variables */
 String window_cascade_name = "cascadetest2.xml";
 CascadeClassifier window_cascade;
  string window_name1 = "Capture - Window detection";

 /** @function main */
 int main( int argc, const char** argv )
 {
   CvCapture* capture;
   //Mat frame(240,320, CV_8UC4);
   Mat frame;
   //-- 1. Load the cascades

   if( !window_cascade.load(window_cascade_name ) ){ printf("--(!)Error loading\n"); return -1; };
   frame = imread("/tmp/test.jpg");

   detectAndDisplay1( frame );
   return 0;
 }

/** @function detectAndDisplay */
void detectAndDisplay1( Mat frame )
{
  std::vector<Rect> faces;
  window_cascade.detectMultiScale( frame, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30) );
  for( int i = 0; i < faces.size(); i++ )
  {
    Point center( faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5 );
    ellipse( frame, center, Size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 );


  }
  //-- Show what you got

  imshow( window_name1, frame );
  waitKey(0);


 }

I am also attaching the test data and results in this link - link text. If you see in the results, result test detected 2 handles instead of 1 and the location is offset. result test 1 did not detect anything. result test 2 detected 2 handles and the location is offset ... (more)