Ask Your Question

busrakkk's profile - activity

2021-03-31 13:56:42 -0600 received badge  Popular Question (source)
2019-10-04 14:18:53 -0600 received badge  Famous Question (source)
2018-04-11 08:22:12 -0600 received badge  Notable Question (source)
2017-06-05 00:38:02 -0600 received badge  Popular Question (source)
2016-03-02 07:58:29 -0600 commented question SelectROI unhandled exception:Access violation reading location

I tried but it still crashes:(

2016-03-02 07:22:08 -0600 commented question SelectROI unhandled exception:Access violation reading location

thanx but as you said, unrelated. I didn't copy&paste the code so there may be syntax mistakes

2016-03-02 06:51:44 -0600 commented question SelectROI unhandled exception:Access violation reading location

yes it does, throws same exceptions at selectROI()

2016-03-02 06:09:11 -0600 asked a question SelectROI unhandled exception:Access violation reading location

I am using opencv 3.1.0 and VS 2013 I am trying to track objects from video file but whenever I selected my ROI I got the following errors.

Debug Assertin Failed! Expression: invalid null pointer

Unhandled exception:Access violation reading location

When I debugging the exceptions were thrown from inside of selectROI method.(while assinging to vectors)

Here are my codes;

myCpp.hpp

#pragma once
#include "windows.h"
#include <stdint.h>
#include <opencv2/core/utility.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
#include <tracking\include\opencv2\tracking\tracker.hpp>

using namespace cv;
using namespace std;
namespace ns{
   class myCpp {

   protected:
      vector<Rect2d> object;

   public:
      int run (char* file, char* alg);

   };
}

myCpp.cpp

#include <iostream>
#include <cstring>
#include <ctime>
#include "Tracker.hpp"
#include <opencv2/flann.hpp>

using namespace std;
using namespace cv;

static bool paused;
ns::myCpp obj;
Ptr<Tracker> tracker;

namespace ns{

   int myCpp::run(char* file,char* alg){
      paused=false;
      MultiTracker trackers(alg);

      VideoCapture cap(file);

      if (!cap.isOpened()){
         cout<<"cannot read video"<< endl;
         return -1;
      }

      Mat frame;

      namedWindow("window",WINDOW_NORMAL);
      cap>>frame;
      selectROI("tracker",frame,object);
      if(object.size()==0)
         return 0;
      trackers.add(frame,object);
      while(1){
         if(!paused){
            cap>>frame;
            if(frame.rows==0 || frame.cols==0){
               destroyWindow("window");
               break;
            }
            trackers.update(frame);
            for (unsigned i =0; i< trackers.objects.size(); i++)
            rectangle (frame,trackers.objects[i],Scalar(0,255,0),2,1);
            imshow("window",frame);
         }
         if(waitKey(1) == 27) break;
         if(waitKey(1) == 'p') paused = !paused;
      }
      return 0;
  }

   extern "C"{
      __declspec(dllexport) int start_(char*f,char*a){
         return obj.run(f,a);
      }
    }
 }

myClass.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;

namespace ns
{
   [StructLayout(LayoutKind.Sequential,Pack=1)]
   struct player_exxception_t
   {
      public int b_raised;
      public int i_code;
      [MarshalAs(UnmanagedType.LPStr)]
      public string pzs_message;
   }

   public class Player
   {
      Player()
      {
      }
      [DllImport(@"myCpp.dll",CallingConvention=CallingConvention.Cdecl)]
      public static extern void start_([MarshalAs(UnmanagedType.LPStr)] string file, [MarshalAs(UnmanagedType.LPStr)] string alg);
   }
}

main.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ns
{
   public partial class MainPage:Form
   { 
      public MainPage()
      {
         InitializeComponent();
      }

      private void MainPage_Load(object sender, EventArgs e)
      {
      }

      private void startButton_Click(object sender, EventArgs e)
      {
          Player.start_("video.avi", "KCF");
      }
   }
}

Any help will be appreciated. Thank you!

2016-02-12 07:56:29 -0600 commented question <Unkown/Unsupported array type>

thanx for your efford anyway:(

2016-02-11 08:14:17 -0600 asked a question <Unkown/Unsupported array type>

I recently switch opencv 2.4 to 3.1.0 version after since I am getting so many errors. So far I handled many of them but still there are so many. Now, my code does not work when I try to run with opencv 3.1.0 but when I try debug it shows so many

First-chanace exception at 0x000007FEFD4CB16D in myProject.exe: Microsoft C++ exception: cv::Exception at memory location 0x.....
Unandled exception at 0x000007FEFD4CB16D in myProject.exe: Microsoft C++ exception: cv::Exception at memory location 0x.....

Some of this kind of errors disappeared by changing wrong includes to right ones but as i said still there are so many.

Here is the code which is related to exception;

Main.cpp

//class takes a video file and process it since i've checked i/o and the code is too long i've just skipped that part
//you can consider `frame` as a valid input.
#include <windows.h>
#include <iostream>
#include "opencv2\opencv.hpp"
#include "cuda_runtime.h"
#include "MyClass.hpp"

using namespace std;
using namespace cv;
using namespace cv::cuda;

MyClass myobj;
cudaStream_t *stream;

int main(int argc, char** argv){
   myobj = MyClass::MyClass();
   Mat frame(720, 1280, CV_8UC3);
   stream = new cudaStream_t[myObj.cnt];
   for(int i = 0; i< myobj.cnt; i++){
      cudaStreamCreate(&stream[i]);
   }
   myobj.func(frame);
   while(1){
      .
      .
      .
      if((char)(waitKey(30)) == 27){
         break;
      }
   }
   for(int i = 0; i< myobj.cnt; i++){
      cudaStreamDestroy(&stream[i]);
   }
   return 1;
}

MyClass.cpp

#include "MyClass.hpp"

using namespace cv;

MyClass::MyClass(){
   gft_gpu = GFTTDetector::create(2000, 0.05, 5);
   cnt = 2;
}
void MyClass::func1(){
   (*gft_gpu).detect(cur_gray, keyp); 
}

uint8_t *MyClass::func(Mat frame){
    current.upload(frame);
    func1();
}

Myclass.hpp

#include <iostream>
#include <windows.h>
#include <stdint.h>
#include <math.h>
#include <vector>

#include "opencv2\cudafeatures2d.hpp"
#include "opencv2\cudaimgproc.hpp"

using namespace cv;
using namespace std;
using namespace cv::cuda;

class MyClass{
public:
   MyClass();
   uint8_t *MyClass::func(Mat frame);
   void MyClass::func1();

protected:
   int cnt;
   GpuMat current, cur_gray;
   vector<vector<KeyPoint>> keyp;
   Ptr<GFTTDetector> gft_gpu;
}

I am not allowed to copy to whole code also it includes so many unrelated classes therefore I wrote the related part. When debugging at the main class myobj.func(); program throws the exceptions and specifically it arises from _images.getMatVector(images) inside the (*gft_gpu).detect(cur_gray, keyp); at feature2d.hpp (according to call stack)

p.s. I am curious about one more issue i used to reference myclass object's variables by usingthis-> at MyClass.cpp when using opencv 2.4 and it worked fine but now they caused some problems and I had to delete all of them then the problem thet they caused disappeared. Is it inappropriate using this-> at opencv 3.1.0 ?

EDIT: I get following error too;

OpenCV Error: The function/feature is not implemented <Unkown/unsupported array type > in cv::_InputArray::getMatVector, file C:\.....core\src\matrix.cpp, line 1367

any advice? thanks.

2016-02-11 06:52:44 -0600 commented answer unable to read memory

Thanx, I fixed the cuda headers and it seems working right now at least number of errors decreased:)

2016-02-10 23:56:22 -0600 commented answer unable to read memory

To use GpuMat I have to add cuda.hpp,am i right?

2016-02-10 09:04:26 -0600 commented answer unable to read memory

It is end of the shift now, i'll start with try and give feedback tomorrow :)

2016-02-10 08:18:17 -0600 commented answer unable to read memory

Thank you for your reply :) Your suggestion worked for the code but when I modify it as you can see from above the issue still accurs for new function. Inside the Modifier.cpp it says "unable to read memory" for all values of all global variables of the object.

2016-02-10 05:59:07 -0600 commented question unable to read memory

initialize() method is for initializing another features of the object and runs some different algorithms, i've just name it as initialize. Sorry for the mess, i'm editing the code, writing a sample that i get the same error.

2016-02-10 02:52:29 -0600 commented question unable to read memory

sorry, i missed out. current is one of the global variables of myClass, its type is GpuMat. If you need more info i can provide as much as i am able to

2016-02-10 02:03:30 -0600 commented question unable to read memory

I am not allowed to copy the code but i can say that the error occurs at the beggining of the function; first line is "vidSize = current_frame.size();" and cannot even execute this line.

2016-02-10 01:35:14 -0600 asked a question unable to read memory

I use opencv 3.1.0 and have a function at myClass.cpp below;

void initialize(Mat frame);

and i call the function from main like;

myClass temp  = myClass::myClass();
temp.initialize(current_frame);

constructer works and assigns correct values to temp also current_frame is initialized and its values are correct at main class but when i call the function the program breaks and when i debugged i saw at myClass.cpp the function cannot read the values of frame as i give the parameter to the function. At the inside of initialize(Mat frame) it says "unable to read memory" for all parameters of frame(e.g size, coloumns, rows ...).

any help or suggestion?

Edit: I added a sample code that i get the same error below;

Main.cpp

#include "Modifier.hpp"

using namespace cv;
using namespace std;

Mat image;

int main(int argc, char* argc){
   string imageName("../image.png");
   if (argc > 1) {
      imageName = argv[1];
   }
   image = imread(imageName.c_str(), IMREAD_COLOR);
   if(image.empty()){
      cout << "image is empty" << endl;
      return -1;
   }
   Modify mdf(image);
   if(mdf.getImage().empty()){
      cout << "image is empty" << endl;
      return -1;
   }

   // recently added line
   mdf.myFunc();
}

Modifier.cpp

#include "Modifier.hpp"

using namespace cv;

Modify::Modify(Mat img){
   this->image.upload(img);
}

GpuMat Modify::getImage(){
   return this->image;
}

//recently added line
void Modify::myFunc(){
}

Modifier.hpp

#include <opencv2\core.hpp>
#include <opencv2\highgui.hpp>
#include <opencv\imgcodecs.hpp>
#include <opencv2\imgproc.hpp>
#include <opencv2\core\cuda.hpp>

using namespace cv;
using namespace cv::cuda;

class Modify
{
public:
   Modify(Mat img);
   GpuMat getImage();
   //recently added line
   void myFunc();

protected:
   GpuMat image;

since it is unable to read the frame's values cannot assign values to parameters. hope it helps.

2016-02-02 00:52:07 -0600 commented question Error LNK2019: unresolved external symbol

I downloaded opencv_contrib from github and tried to build it with Cmake and yes I enabled the with_cuda but it doesnt work.

2016-02-01 05:33:08 -0600 asked a question Error LNK2019: unresolved external symbol

I am using opencv 3.1.0, cuda 6.5 and visual studio 2013 on 64 bit machine. I am getting the following error and I searched for a solution like 3-4 days and I tried every solution that I found. I am not able t copy my codes so here is my error:

error LNK2019: unresolved external symbol "public: void _cdecl cv::cuda::SURF_CUDA::operator()class cv::cuda::GpuMat const&, class cv::cuda::GpuMat const&,class std::vector<class cv::KeyPoint, class std::allocator<class cv::KeyPoint> > &,class cv::cuda::GpuMat &,bool)"(?? RSURF_CUDA@cuda@cv@@QEAAXAEBV GpuMat@12@0AEAV?$vector@VKeyPoint@cv@@@std@@@std@@AEAV312@_N@Z) referenced in functin "protected: void _cdecl Detector::findFenceDescriptrs(int)"(?findFenceDescriptors@Detector@@IEAAXH@Z)
  • I am building the project x64 (so it is correct becasue my computer is 64 bit).
  • I added the all the lib directories to additinal directories and all libs to additional dependencies at the project (both opencv 3.1.0 and cuda 6.5 libs).
  • My environmental paths are also correct I checked from the solutions that I found

Editing.. While compiling opencv_contrib I'm getting lots of syntax errors from some modules(xfeatures2d,tracking..etc) Also i did the debug/release all built and than I did it for the install to but it still doesnt work for me. any help or suggestion? Thanx

2016-01-21 05:59:06 -0600 received badge  Student (source)