Error with matchTemplate function in OpenCV - opencv

These are includes which I am using
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc_c.h>
This is namespace
using namespace cv;
But when I am using matchTemplate function, I am catching the following problem
error C3861: 'matchTemplate': identifier not found
Can anyone help me to solve this problem?
Additional information:
I am using OpenCV2.3
thank you for spending time to view and comment my problem
Best Regards
Hayk

You need imgproc.hpp included, the one that you included has the C version only : cvMatchTemplate

Related

opencv imread not working but other functions are

#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <string>
#include <iostream>
#include <stdlib.h>
#include "opencv2\highgui.hpp"
#include "opencv2\imgproc.hpp"
#include "opencv2\features2d.hpp"
#include "opencv2\core.hpp"
using namespace std;
using namespace cv;
int main()
{
Mat img = Mat::zeros(Size(60,60),CV_8UC1);
imwrite("test.bmp", img);
Mat img2 = imread("Screw.png");
namedWindow("image", WINDOW_NORMAL);
imshow("image", img);
imshow("img", img2);
waitKey(0);
return 0;
}
I am using Opencv 3.4.6 with visual studio 2015.
I am unable to read any image from system, have tried png and jpg image format.To make sure that image is in the right location I have also used imwrite function to save an blank image, which is working fine.
I have tried opencv 4.0.1 as well giving the same issue.
I think there might be some issue in configuration part. There are so many tutorials available for the configuration procedure. Try below link for the configuration and also
as #mark suggested replace your header file
https://www.youtube.com/watch?v=M-VHaLHC4XI

‘calibrateCamera’ was not declared in this scope

I tried to get the camera matrix using calibrateCamera() function:
double x= calibrateCamera(objectPoints,imagePoints,imageSize,cameraMatrix,distCoeffs,rvecs,tvecs,0);
and i got
‘calibrateCamera’ was not declared in this scope
i didn't forgot to write
using namespace cv;
what can it be?
thanks in advance.
ok i got it:
i was missing the header:
#include "opencv2/calib3d/calib3d.hpp"
thanks anyway

Accessing the vm areas of a process

I am trying to write a LKM that have to read the vm areas address from a process. I am using pid_task() to get the pointer to the task_struct, but i getting compiling error when i try to use it to get the start address of the vmarea.
struct task_struct *ts;
ts = pid_task(find_vpid(pid_t)pid,PIDTYPE_PID);
printk(KERN_INFO "%lu",ts->mm->mmap->start);
And i am getting the error "error: dereferencing pointer to incomplete type"
I am a linux noob and a completely noob in LKM.
I'd appreciate any help.
Thank you all
I have a test on my kernel source tree(2.6.35) with following codes, the compilation is okey:
struct task_struct *ts;
pid_t pid;
ts = pid_task(find_vpid(pid),PIDTYPE_PID);
printk(KERN_INFO "%lu",ts->mm->mmap->vm_start);
Could you try with the above codes in your kernel source tree? I think maybe you have to include all header files needed, such as:
#include <asm/uaccess.h>
#include <linux/errno.h>
#include <linux/time.h>
#include <linux/proc_fs.h>
#include <linux/stat.h>
#include <linux/init.h>
#include <linux/capability.h>
#include <linux/file.h>
#include <linux/fdtable.h>
#include <linux/string.h>
#include <linux/namei.h>
#include <linux/mnt_namespace.h>
#include <linux/mm.h>
#include <linux/swap.h>
#include <linux/rcupdate.h>
#include <linux/kallsyms.h>
#include <linux/stacktrace.h>
#include <linux/resource.h>
#include <linux/module.h>
#include <linux/mount.h>
#include <linux/security.h>
#include <linux/ptrace.h>
#include <linux/tracehook.h>
#include <linux/cgroup.h>
#include <linux/cpuset.h>
#include <linux/audit.h>
#include <linux/poll.h>
#include <linux/nsproxy.h>
#include <linux/oom.h>
#include <linux/elf.h>
#include <linux/pid_namespace.h>
#include <linux/fs_struct.h>
Another:
After compilation successfully, you should judge the pointers is NULL or not.

Error with OpenCV code - Invalid address specified to RtlFreeHeap

I have the following code, which runs fine:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/features2d/features2d.hpp>
using namespace std;
using namespace cv;
void main() {
bool running = true;
cv::OrbFeatureDetector OrbDetector;
while (running) {
IplImage *newFrame = cvLoadImage("x1.jpg");
IplImage *newFrameBW = cvCreateImage(cvGetSize(newFrame), newFrame->depth, 1);
cvConvertImage(newFrame, newFrameBW);
vector<KeyPoint> KeyPoints;
}
}
However, adding the line:
OrbDetector.detect(newFrameBW, KeyPoints);
to the while loop results in the following error:
HEAP[Example 4.exe]: Invalid address specified to RtlFreeHeap( 006B0000, 02474D20 )
Example 4.exe has triggered a breakpoint.
I am sure there is nothing wrong with the code, as I have just seen it run successfully on someone elses machine. Is there anything non code related that could be causing this?
The problem is that the OpenCV version you are using does not deal OK with MCVS 2012. Is not a problem of code, as I had a similar one that include vectors and didn't work.
Take a look to this tutorial that will show you how to rebuild the OpenCV library and your code will work pretty well ;)
Here is the link:
http://answers.opencv.org/question/6495/visual-studio-2012-and-rtlfreeheap-error/

opencv class "cvKalman" not recognised

I have a problem, in ROS I process a camera feed with openCv.
Now i try to implement the cvKalman, but this type is not recognized, however the opencv example works well.
What am i missing, why is not recognized this type?
here is my include to the ROS node:
#include <ros/ros.h>
#include <math.h>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
// for img processing
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <opencv/cv.h>
Try including with "s not <s such as:
#include "ros/ros.h"
I solves the problem by using the KalmanFilter wrapper class, but still I dont understand why I cant use the simple Kalman class.

Resources