May be a problem with privileges so that you can't write the video-file? If not I'd recommend to ask this question on stackoverflow.com since this seems to be more an OpenCV problem.
Am Mittwoch, 21. Januar 2015 06:36:14 UTC+1 schrieb [email protected]: > > Hi, > > My aim is to record video from Axis camera using bbb. I have done video > streaming in bbb and it worked well. I can watch live video on an output > window. I installed opencv in bbb and programs are written in C++. Now i > need to record video at 25fps and i coded as shown below. > > > > > > > #include <iostream> > #include "cv.h" > #include "highgui.h" > > using namespace std; > int main (int argc, char *argv[]) > { > > cv::VideoCapture vcap; > cv::Mat frame; > cv::VideoWriter video; > > // Open the default camera > const std::string videoStreamAddress = "http://USERNAME:PASSWORD@IP > ADDRESS/mjpg/video.mjpg"; > > // Check if the camera was opened > > if(!vcap.open(videoStreamAddress)) { > std::cout << "Error opening video stream or file" << std::endl; > return -1; > } > > > // Get the properties from the camera > double width = vcap.get(CV_CAP_PROP_FRAME_WIDTH); > double height = vcap.get(CV_CAP_PROP_FRAME_HEIGHT); > > cout << "Camera properties\n"; > cout << "width = " << width << endl <<"height = "<< height << endl; > > > > // Create a window to show the image > cv::namedWindow ("Capture", CV_WINDOW_AUTOSIZE); > > // Create the video writer > video.open("capture.avi",CV_FOURCC('M','J','P','G', 25, > cvSize((int)width,(int)height),true ); > > // Check if the video was opened > if(!video.isOpened()) > { > cerr << "Could not create video."; > return -1; > } > > cout << "Press Esc to stop recording." << endl; > > // Get the next frame until the user presses the escape key > while(true) > { > // Get frame from capture > vcap >> frame; > > // Check if the frame was retrieved > if(!frame.data) > { > cerr << "Could not retrieve frame."; > return -1; > } > > // Save frame to video > video << frame; > > // Show image > cv::imshow("Capture", frame); > > // Exit with escape key > if(cv::waitKey(1) == 27) > break; > } > > // Exit > return 0; > } > > > > This code is working in Eclipse IDE installed in Ubuntu host machine and i > got recorded video in the workspace of Eclipse. When i copied this program > to bbb, it is not working. It can stream the video and sent the frame > properties and the output is "Could not create video.". What is the problem > in this code? Can anyone help me? > > Also i want to store this video to the sd card which act as the extra > storage in bbb. how i can do it? Please help me. > > Thanks in advance. > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
