Ask Your Question

Sowmya Shree's profile - activity

2017-08-30 01:09:11 -0600 edited question C4146 unary minus operator is applied to unsigned type, result still unsigned error encountered in opencv visual studio 2015

C4146 unary minus operator is applied to unsigned type, result still unsigned error encountered in opencv visual studio

2017-08-30 01:08:37 -0600 asked a question C4146 unary minus operator is applied to unsigned type, result still unsigned error encountered in opencv visual studio 2015

C4146 unary minus operator is applied to unsigned type, result still unsigned error encountered in opencv visual studio

2017-08-23 00:06:43 -0600 asked a question Unable to play a video in opencv3

Here is my new code.

int main(void) {

cv::VideoCapture capVideo;

cv::Mat imgFrame;

capVideo.open("C:\Users\sbv\Documents\MyVideo.avi");

if (!capVideo.isOpened()) {
std::cout << "\nerror reading video file" << std::endl << std::endl;
_getch();
return(0); }

if (capVideo.get(CV_CAP_PROP_FRAME_COUNT) < 1) { std::cout << "\nerror: video file must have at least one frame"; _getch(); return(0); }

capVideo.read(imgFrame);

char chCheckForEscKey = 0;

while (capVideo.isOpened() && chCheckForEscKey != 27) {

cv::imshow("imgFrame", imgFrame);

if ((capVideo.get(CV_CAP_PROP_POS_FRAMES) + 1) < capVideo.get(CV_CAP_PROP_FRAME_COUNT)) 
        {
        capVideo.read(imgFrame);                          
}
else 
        {
         std::cout << "end of video\n";
         break;                                              
}

chCheckForEscKey = cv::waitKey(1);      
    }

if (chCheckForEscKey != 27) {
cv::waitKey(0);
} return(0);

}

error is coming as 'Error reading video file'. please solve this issue

2017-08-22 00:35:56 -0600 asked a question How to play a video in opencv using C++?

Please tell me how a video file is played in Opencv. I tried using cvCapture. here is the following code I used. it is displaying 'video not opened'.

int main(int argc, char* argv[]) { CvCapture* capture = cvCreateFileCapture("C:\Users\sbv\Documents\MyVideo.avi");

IplImage* frame = NULL;

if (!capture)
{
    printf("Video Not Opened\n");
    return -1;
}

int width = (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH);
int height = (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT);
double fps = cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
int frame_count = (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_COUNT);

printf("Video Size = %d x %d\n", width, height);
printf("FPS = %f\nTotal Frames = %d\n", fps, frame_count);

while (1)
{
    frame = cvQueryFrame(capture);

    if (!frame)
    {
        printf("Capture Finished\n");
        break;
    }

    cvShowImage("video", frame);
    cvWaitKey(10);
}

cvReleaseCapture(&capture);
return 0;

}

2017-08-18 04:06:15 -0600 asked a question Problem while writing an image and video in a particular location

Image read is working properly. but while writing an image in a particular location such as C or D drive. Error is 'failed to write image'. same issue for video read and write also. please help me to solve this issue.

Image write program

#include<opencv2/highgui/highgui.hpp>
#include<opencv2/core/core.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, const char** argv)
{
    Mat img(650, 600, CV_16UC3, Scalar(0, 50000, 50000)); 

    if (img.empty()) 
    {
        cout << "ERROR : Image cannot be loaded..!!" << endl;
        system("pause"); 
        return -1;
    }


    vector<int> compression_params; 

    compression_params.push_back(CV_IMWRITE_JPEG_QUALITY); 

    compression_params.push_back(98); 

    bool bSuccess = imwrite("C:\\Users\\sbv\\Documnents\\TestImage.jpg", img, compression_params); 

    if (!bSuccess)
    {

        cout << "ERROR : Failed to save the image" << endl;
        system("pause"); 

    }

    namedWindow("MyWindow", CV_WINDOW_AUTOSIZE); 
    imshow("MyWindow", img); 

    waitKey(0);  

    destroyWindow("MyWindow"); 

    return 0;
}


**Video write program**
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char* argv[])
{
    VideoCapture cap(0); 

    //VideoCapture cap("C:\\Users\\sbv\\Documents\\video.mp4");

    if (!cap.isOpened())  
    {
        cout << "ERROR: Cannot open the video file" << endl;
        return -1;
    }

    namedWindow("MyVideo", CV_WINDOW_AUTOSIZE); 

    double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); 
    double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); 

    cout << "Frame Size = " << dWidth << "x" << dHeight << endl;

    Size frameSize(static_cast<int>(dWidth), static_cast<int>(dHeight));

    VideoWriter VideoWriter("C:/MyVideo.avi", CV_FOURCC('P', 'I', 'M', '1'), 20, frameSize, true); 

    if (!VideoWriter.isOpened()) 
    {
        cout << "ERROR: Failed to write the video" << endl;
        return -1;
    }

    while (1)
    {

        Mat frame;

        bool bSuccess = cap.read(frame); 

        if (!bSuccess) 
        {
            cout << "ERROR: Cannot read a frame from video file" << endl;
            break;
        }

        VideoWriter.write(frame); 

        imshow("MyVideo", frame); 

        if (waitKey(10) == 27) 
        {
            cout << "esc key is pressed by user" << endl;
            break;
        }
    }

    return 0;

}
2017-08-17 23:26:55 -0600 received badge  Editor (source)
2017-08-16 22:55:03 -0600 asked a question “Opencv_world330d.dll is missing” message is displaying even after adding "OpenCV-world330d.lib" in Properties => linker => input=>additional dependency?

I am using Opencv for my project and for the first time. While using Opencv I faced problem as “Opencv_world330d.dll is missing” message is displayed as soon as I run the program. I also added "OpenCV-world330d.lib" in Properties => linker => input=>additional dependency. I couldn't able to solve this problem. Please help me to solve this issue.

Opencv_world330d.dll is present in the folder.

It is working. Thanks @Balaji R