2013-07-23 06:15:49 -0600
| received badge | ● Student
(source)
|
2013-07-09 17:52:02 -0600
| asked a question | Counting Pixels I am trying to read each row's number of black pixel. So I set up the for loop, but I am getting an errors. error C2064: term does not evaluate to a function taking 1 arguments error What am I doing wrong? PS I'm sorry I'm using C instead of C++ because I only have the old edition book :( #include <highgui.h>
#include <cv.h>
int main()
{
int total,
zero,
width,
black_pixel;
IplImage* in = cvLoadImage("Wallet.jpg", CV_LOAD_IMAGE_GRAYSCALE);
IplImage* gsmooth = cvCreateImage(cvGetSize(in), IPL_DEPTH_8U, 1);
IplImage* erode = cvCreateImage(cvGetSize(in), IPL_DEPTH_8U, 1);
IplImage* Iat = cvCreateImage(cvGetSize(in), IPL_DEPTH_8U, 1);
IplImage* bpixel = cvCreateImage(cvGetSize(in), IPL_DEPTH_8U, 1);
cvSmooth(in, gsmooth, CV_GAUSSIAN, 3, 0, 0, 0);
cvErode(gsmooth, erode, NULL, 2);
cvThreshold(erode, Iat, 100, 255, CV_THRESH_BINARY);
total = (Iat->height)*(Iat->width);
zero = total - cvCountNonZero(Iat);
printf("Total pixels: %d\nWhite pixels: %d\nBlack pixels: %d", total, cvCountNonZero(Iat), zero);
for(int x = 0; x < Iat->width; x++)
{
black_pixel = (Iat->width) - cvCountNonZero(Iat->width(x));
printf("%d", black_pixel);
}
cvNamedWindow("Original", 1);
cvNamedWindow("Gaussian Smoothing", 1);
cvNamedWindow("Erode", 1);
cvNamedWindow("Adaptive Threshold", 1);
cvShowImage("Original", in);
cvShowImage("Gaussian Smoothing", gsmooth);
cvShowImage("Erode", erode);
cvShowImage("Adaptive Threshold", Iat);
cvWaitKey(0);
cvReleaseImage(&in);
cvReleaseImage(&gsmooth);
cvReleaseImage(&erode);
cvReleaseImage(&Iat);
cvDestroyWindow("Original");
cvDestroyWindow("Gaussian Smoothing");
cvDestroyWindow("Erode");
cvDestroyWindow("Adaptive Threshold");
}
|
2013-07-09 07:54:40 -0600
| asked a question | Tracking in Image I just started OpenCV, and before I start real time video tracking, I would like to do a simple tracking in image. The algorithm would be to convert the image into thresholding. Then if the color intensity (which will be black) exceeds certain count, a rectangle will be drawn around it. Is there any example code that you know of that uses this type of tracking or do you know which function to use? Thank you |
2013-07-06 12:21:31 -0600
| commented answer | Recording Live Stream resulting movie only has 2 frames per second. I changed fps to 9 manually in cvCreateVideoWriter and it seems to work fine. But I want to use fps variable to retrieve an accurate number. |
2013-07-05 15:00:58 -0600
| received badge | ● Editor
(source)
|
2013-07-05 14:43:32 -0600
| asked a question | Live Stream FPS problem Hello,
I wrote a code that records a live stream into avi file.
It does output it, but for some reason, it plays really really slowly.
Each frame takes about 1 ~ 2 seconds.
I believe I have acquired the fps information by using cvGetCaptureProperty, so I am wondering why it is playing slowly.
Would you help me please?
Thank you.
Sorry this is in C :( #include "cv.h"
#include "highgui.h"
#include "cxcore.h"
int main(double fps, CvSize size, CvVideoWriter *writer, char c)
{
CvCapture* capture = cvCreateCameraCapture(-1);
cvNamedWindow("Live Stream", CV_WINDOW_AUTOSIZE);
size = cvSize(
(int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH),
(int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT)
);
fps = cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
writer = cvCreateVideoWriter(
"C:\\Recorded.avi",
-1,
fps,
size,
1
);
while(1)
{
IplImage* frame = cvQueryFrame(capture);
if(!frame)
break;
cvWriteFrame(writer, frame);
cvShowImage("Live Stream", frame);
c = cvWaitKey(33);
if(c == 27)
{
cvReleaseVideoWriter(&writer);
break;
}
}
cvReleaseCapture(&capture);
cvDestroyWindow("Live Stream");
}
update: so I manually replaced 'fps' variable with a value in cvCreateVideoWriter and that seems to solve the fps problem. However, I still would like to obtain the exact fps of the webcam I am using. |
2013-07-05 14:23:42 -0600
| received badge | ● Scholar
(source)
|
2013-07-05 13:40:50 -0600
| received badge | ● Supporter
(source)
|
2013-07-05 13:36:00 -0600
| commented answer | Recording Live Stream I got it. Thank you so much. I do have a question though. When I open the file, the video is playing really slowly. Each frame takes about 1 - 2 second to play. Do you know how I can make it go faster? |
2013-07-03 12:30:42 -0600
| asked a question | Recording Live Stream I am trying to record a live feed and save from the beginning of it until I hit 'ESC'. I tried writing it, but obviously there is some gaps in the code that prevent me from doing so. There is no error/warning, but live stream is not recorded and converted to avi file. The window does show the live stream though. Would you help me and point out what is wrong/missing? Thank you. #include "cv.h"
#include "highgui.h"
#include "cxcore.h"
int main(double fps, CvSize size, CvVideoWriter *writer, char c)
{
CvCapture* capture = cvCreateCameraCapture(-1);
cvNamedWindow("Live Stream", CV_WINDOW_AUTOSIZE);
/*fps = cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
size = cvSize(
(int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH),
(int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT)
);*/
while(1)
{
IplImage* frame = cvQueryFrame(capture);
if(!frame)
break;
cvShowImage("Live Stream", frame);
fps = cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
size = cvSize(
(int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH),
(int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT)
);
writer = cvCreateVideoWriter(
"Live Stream",
CV_FOURCC('M', 'J', 'P', 'G'),
fps,
size,
1
);
c = cvWaitKey(33);
if(c == 27)
{
cvReleaseVideoWriter(&writer);
break;
}
}
cvReleaseCapture(&capture);
cvDestroyWindow("Live Stream");
}
|