Hey i have searched every where about this issue and i still cant find my answers. Here's the deal, I'm a beginner and for my semester project i need to use the OpenCV. During its installation I'm getting two problems:
1.) the property pages that I'm supposed to make and save for further
use,i cant save them. The option is grayed out, i did everything
written here:
http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html#windows-installation
2.) the headers im including i.e
#include <opencv2/imgproc/imgproc.hpp> // Gaussian Blur
#include <opencv2/core/core.hpp> // Basic OpenCV structures (cv::Mat, Scalar)
#include <opencv2/highgui/highgui.hpp>
give errors, fatal error C1083: Cannot open include file: 'opencv2/imgproc/imgproc.hpp': No such file or directory what am i doing wrong??
you probably need to adjust your "Additional Include Dirs", so that it points to
opencv/build/include
Related
I use Singluritygs and Breakpoints (with the included respond-to) and I want my global gutter width to change according to those breakpoints.
I thought this would work, but it doesn't:
$breakpoints: add-breakpoint('small', 768px);
#include add-grid(12);
#include add-gutter(1);
#include respond-to('small') {
#include add-gutter(1/2);
}
Am I approaching this the wrong way?
Note that adding a grid does work using this technique:
#include respond-to('small') {
#include grid-span(9, 4);
}
Problem and solution
Singularity is not compatible with Respond-To. Or, to be more precise, Respond-To does not provide functionality required by Singularity.
The correct way of defining responsive gutters is described here and looks like this:
#include add-gutter(.25 at 900px);.
Responsive grids and gutters should be defined on top of your Sass, alongside mobile-first grids and gutters.
Example:
$bp-small: 768px;
#include add-grid(12);
#include add-gutter(1);
#include add-gutter(1/2 at $bp-small);
.foo {
#include float-span(1);
#include breakpoint($bp-small) {
#include float-span(1);
}
}
Demo:
http://sassmeister.com/gist/b49bd305f029afe9cd68
Update 1
davidpauljunior
I thought Singlurity was compatible with respond-to, I'm using it to successfully add new grids - see my added note in the question. The docs say that for reponsive grids use Breakpoint, and Breakpoint includes Repond-to in it (github.com/Team-Sass/breakpoint/wiki/Respond-To).
You were doing it wrong.
Singularity maintains a list of grid definitions for various breakpoints (and another list for gutter definitions). When spanning, Singularity asks Breakpoint for the context (current breakpoint) and retrieves corresponding grid and gutter definitions from lists.
When used with Respond-To, Singularity is unable to retrieve the context and considers that it spans item in the mobile-first context.
Instead populating the grid/gutter definition lists with defintions for each breakpoint, you had only one entry in the list -- the mobile first one.
By reapplying add-gutter() inside a media query, you thought that you were setting the gutter definition for that media query. But instead you were overwriting the mobile-first grid definition globally. And due to Respond-To not reporting context to Singularity, it was using the mobile first definition inside the media query.
This is a valid approach per se. In fact, i've being actively using it with Singularity 1.0. But it has an obvious downside: due to the fact that grid/gutter definitions are overridden globally, you end up needing to reapply add-grid() and add-gutter() before every usage of spanning mixins, otherwise there's a change that Singularity will be using definitions that you don't expect. This is especially the case if you organize your Sass code in a large number of small files.
I suggest that you investigate two extensions that i wrote:
Breakpoint Slicer -- a very quick and efficient syntax for Breakpoint. It's better than Respond-To, and has full support for Singularity.
Singularity Quick Spanner -- a tool with a number of shortcut mixins for Singularity. One of them is designed to ease the approach of reapplying grid/gutter definitions every time.
Update 2
davidpauljunior
I still don't see why if grids can be redefined globally within Respond-to media queries, why gutters can't. Also, you said I only have 1 entry 'the mobile first one', but that entry was the screen size after mobile first (768px).
You have to understand that #include add-gutter(1/2); overwrites the mobile-first gutter definition regardless of whether you execute it inside a media query or not.
Above i have already explained (and provided a link to documentation) how media query-aware grids and gutters should be defined. Repeating:
lolmaus
The correct way of defining responsive gutters is described here and looks like this:
`#include add-gutter(.25 at 900px);`.
This is how your initial attempt actually works: http://sassmeister.com/gist/c530dfe7c249fad254e9 Please study this example and its output, i hope you will understand now.
davidpauljunior
The idea was that for no media query (mobile first) it would take the global gutter, for my first media query (768 and up) I would reset the global gutter and so on. I've set them all using variables now. Perhaps I'm just missing something about Respond-To.
Again, i have already said that this is a valid approach. My last SassMeister link proves that it is already working for your initial attempt.
And Respond-To is suitable for this situation: it doesn't report the media query context to Singularity, but you're not having Singularity take the media query context into account, you're having it use only the mobile-first definition all the time.
Just don't forget to reapply grids and gutters every time you span a new element, just to make sure that you're doing it in the desired context.
You can make the job of resetting the grid/gutter definitions easier with my reset-grid() helper.
There's an article describing how to do this here, that seems to have worked for other people but it does not compile for me.
Here's a copy of the .h file that was used:
//
// NSImage+OpenCV.h
//
#import <AppKit/AppKit.h>
#interface NSImage (NSImage_OpenCV) {
}
+(NSImage*)imageWithCVMat:(const cv::Mat&)cvMat;
-(id)initWithCVMat:(const cv::Mat&)cvMat;
#property(nonatomic, readonly) cv::Mat CVMat;
#property(nonatomic, readonly) cv::Mat CVGrayscaleMat;
#end
I'm on Xcode 4.4, using openCV 2.4.2. The compiler errors I'm getting for the header file are 4x of the following:
Semantic issue: Use of undeclared identifier 'cv'
This error seems rather obvious...the header file does not define what a cv::Mat is.
So I took a guess from looking at the OpenCV 2.4 tutorial, that I needed to add
#include <opencv2/core/core.hpp>
This generated 20 other errors, where the compiler was complaining about the core.hpp file.
The first of which says:
Semantic issue: Non-const static data member must be initialized out of line
So my question is what am I doing wrong? How do I get this code to work?
Another stackoverflow Q&A (link: How to include OpenCV in Cocoa Application?) had the missing piece on the undefined symbols.
To summarize:
The OpenCV headers have to be included before the Cocoa headers, due to a macro conflict.
Xcode automatically includes the cocoa headers at the top of every objective-C file (*.m, *.mm), which prevents you from adding the OpenCV headers first, as stated in point 1.
Xcode has a "-Prefix.pch" file that defines any code which is automatically prepended to any code.
Normally, it looks like:
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif
Instead, the file should be changed to look like:
#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#endif
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif
So in the case of any *.cpp file, the opencv header gets added automatically. In the case of any *.m file, the Cocoa headers are added. And in the special case of *.mm files, they BOTH get added, and in the correct order.
Kudos to Ian Charnas and user671435 for figuring this out.
That is C++ syntax. You have to give your source file the .mm suffix to make it Objective-C++.
I have recently setup openCV 2.3.1 in Visual Studio 2010. I set it up using cmake and managed to run simple 'hello world' code as follows:
#include "stdafx.h"
#include <opencv2/opencv.hpp>
#include <cxcore.h>
#include <highgui.h>
int _tmain(int argc, _TCHAR* argv[])
{
IplImage *img = cvLoadImage("funny-pictures-cat-goes-pew.jpg");
cvNamedWindow("Image:",1);
cvShowImage("Image:",img);
cvWaitKey();
cvDestroyWindow("Image:");
cvReleaseImage(&img);
return 0;
}
This code was able to run for the first time, though it was displaying a grey image instead of the cat. As I was trying to see whts wrong, it started giving the following error; Unhandled Exception at a certain memory location...:![enter image description here][1](can't upload image because of low reputation points. But I hope you understood my problem description...
Regards,
Ruzzar
Can you please recheck that the *img is being properly filled out?
I just tested this, with the single change that my path to the image is absolute (IplImage *img = cvLoadImage("D:\\Development\\TestProjects\\OpenCVTest\\funny-pictures-cat-goes-pew.jpg");), aside from that its the same. It worked perfectly fine on my system here.
OpenCV 2.4.2 used, image from
http://i288.photobucket.com/albums/ll169/critterclaw101/funny/funny-pictures-cat-goes-pew.jpg
Edit: when testing with a wrongly set path, I get a grey image, thus I am sure that your code cannot find the image.
I just want to display this "img1.jpg" image in a c++ project with using opencv libs for future processes, but it only displays an empty gray window. What is the reason of this. Is there a mistake in this code? please help!
Here is the code;
Mat img1;
char imagePath[256] = "img1.jpg";
img1 = imread(imagePath, CV_LOAD_IMAGE_GRAYSCALE);
namedWindow("result", 1);
imshow("result", img1);
Thanks...
I had the same problem and solved putting waitKey(1); after imshow(). The OpenCV documentation explains why:
This function is the only method in HighGUI that can fetch and handle
events, so it needs to be called periodically for normal event
processing, unless HighGUI is used within some environment that takes
care of event processing.
Thanks #b_froz.
For more detials about this issue,you can refer to: http://docs.opencv.org/2.4/modules/highgui/doc/user_interface.html#imshow
Note This function should be followed by waitKey function which displays the image for specified milliseconds. Otherwise, it won’t display the image. For example, waitKey(0) will display the window infinitely until any keypress (it is suitable for image display). waitKey(25) will display a frame for 25 ms, after which display will be automatically closed. (If you put it in a loop to read videos, it will display the video frame-by-frame)
So,not only waitkey(1)could be put after imshow(),but also waitkey(0) or waitkey(other integers).Here is the explanation of the function waitkey() : http://docs.opencv.org/2.4/modules/highgui/doc/user_interface.html#waitkey
Are you importing the correct library ?
This is other very easy way to load one image:
#define CV_NO_BACKWARD_COMPATIBILITY
#include <cv.h>
#include <highgui.h>
#include <math.h>
main(){
IplImage* img = cvLoadImage("yourPicture.jpg");
cvNamedWindow("Original", 1);
cvShowImage("Original", img);
}
I think you have openCV correctly installed, so yo can type this (Ubuntu):
g++ NameOfYourProgram.cpp -o Sample -I/usr/local/include/opencv/ -L/usr/local/lib -lcv -lhighgui ./sample
The problem you are having is due to the type of your Mat img1. When you load your image with the flag CV_LOAD_IMAGE_GRAYSCALE, the type of your Mat is 0 (CV_8UC1), and the function imshow() is not able to show the image correctly.
You can solve this, converting your Mat to type 16 (CV_8UC3):
img1.convertTo(img1,CV_8UC3);
and then show it with imshow():
imshow("result", img1);
I hope this help.
I am working on a program using the OpenCV library (though I am quite a noob on it). One of the things I need to do is to draw on the image. I looked at the OpenCV drawing functions and they all seem pretty simple (Circle, Line, etc), however the program won't compile! It says this to be exact: error C3861: 'Line': identifier not found.
Is there something I haven't installed? I used the tutorial on http://opencv.willowgarage.com/wiki/VisualC%2B%2B_VS2008 to install OpenCV on Visual Studio 2008 and so far this is the only real problem I have.
Please help me! I need this program working as soon as possible!
The function to draw a line in the OpenCV C API is named cvLine, not Line.
I think you have fallen victim of the following common mistake:
C includes are in #include <opencv/core.h> etc, whereas
C++ includes are:
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <oppencv2/highgui/highgui.hpp>
Include these for drawing and showing the image. Use using namespace cv; then
you don't have to write cv::line just line and everything will be working fine.
I had to battle with the very same problem when I began. ;)
(And btw use cv::Mat for c++.)
You can now easily paint on OpenCV images. For this you need to call the setMouseCallback(‘window_name’,image_name) function on opencv. After that you can easily handle the Mouse Callback Function upon your images. Then you need to detect the cv2.EVENT_LBUTTONDOWN, cv2.EVENT_MOUSEMOVE and cv2.EVENT_LBUTTONUP events. By checking the proper boolean condition you need to decide how you like to interact with the OpenCV images.
def paint_draw(event,former_x,former_y,flags,param):
global current_former_x,current_former_y,drawing, mode
if event==cv2.EVENT_LBUTTONDOWN:
drawing=True
current_former_x,current_former_y=former_x,former_y
elif event==cv2.EVENT_MOUSEMOVE:
if drawing==True:
if mode==True:
cv2.line(image,(current_former_x,current_former_y),(former_x,former_y),(0,0,255),5)
current_former_x = former_x
current_former_y = former_y
elif event==cv2.EVENT_LBUTTONUP:
drawing=False
if mode==True:
cv2.line(image,(current_former_x,current_former_y),(former_x,former_y),(0,0,255),5)
current_former_x = former_x
current_former_y = former_y
return former_x,former_y
For details you can see link: How to Paint on OpenCV Images and Save the Image
Output: