c1083 :Cannot open include file: 'stdafx.h': No such file or directory [closed]

asked 2019-04-04 02:36:45 -0600

turiya gravatar image

Hi everyone, i tried running a code on Visual Studio using OpenCV and faced a few errors. These are common ones and i spent hours finding them online and troubleshooting, but couldnt find the right fix. I hope you guys could help me out with some insights for me to get going. Thanks guys!

below are the errors

Error C1083 Cannot open include file: 'stdafx.h': No such file or directory Error (active) E1696 cannot open source file "stdafx.h"

and these are the codes. Thank you everyone!

     #include "stdafx.h"

    #include <opencv2\highgui.hpp>
    #include <opencv2\videoio.hpp>
    #include <opencv2\imgcodecs.hpp>
    #include "opencv2/imgproc/imgproc.hpp"
    #include <opencv2/opencv.hpp>
    #include <stdlib.h>
    #include <stdio.h>
    #include <iostream>
    #include <math.h>
    #include <ctime>
    #include <opencv2\core\ocl.hpp>
    #include <fstream>
    #include <direct.h>
    #include <shlobj.h>
    #include <stdarg.h>
    #include <ctype.h>



    //ADD this to disable OpenCL explicitly
    using namespace cv;
    using namespace std;
    void Detector(Mat Img, int x_, int y_)
    {
        circle(Img, Point(x_, y_), 2, Scalar(0, 255, 0), 2, 8, 0);
    }
    void AvgDetector(Mat Img, int x_, int y_)
    {
        circle(Img, Point(x_, y_), 2, Scalar(0, 0, 255), 2, 8, 0);
    }
    void Alert(Mat Img) {
        putText(Img, "Detected", Point(20, 20), FONT_HERSHEY_PLAIN, 1, Scalar::all(255), 2, 8);
    }
    const string currentDateTime() {
        time_t     now = time(0);
        struct tm  tstruct;
        char       buf[80];
        tstruct = *localtime(&now);
        strftime(buf, sizeof(buf), "%Y-%m-%d.%X", &tstruct);

        return buf;
    }
    void GetDesktopResolution(int& horizontal, int& vertical)
    {
        RECT desktop;
        // Get a handle to the desktop window
        const HWND hDesktop = 

GetDesktopWindow();
    // Get the size of screen to the variable desktop
    GetWindowRect(hDesktop, &desktop);
    // The top left corner will have coordinates (0,0)
    // and the bottom right corner will have coordinates
    // (horizontal, vertical)
    horizontal = desktop.right;
    vertical = desktop.bottom;
}
string ExePath() {
    char buffer[MAX_PATH];
    GetModuleFileNameA(NULL, buffer, MAX_PATH);
    string::size_type pos = string(buffer).find_last_of("\\/");
    return string(buffer).substr(0, pos);
}


int main()
{
    string Location, Avg_Position, Datapath, Maxfreq, Version;
    ofstream myfile;
    stringstream DataDir, datafilename, Position;
    bool CreateDir = true;

    int StringElement = 0;
    string s = ExePath();
    std::string delimiter = "\\";
    size_t pos = 0;
    std::string token;
    while ((pos = s.find(delimiter)) != std::string::npos) {
        StringElement++;
        token = s.substr(0, pos);
        if (StringElement == 7) {
            Version = token;
            break;
        }
        s.erase(0, pos + delimiter.length());
    }

    cout << CV_VERSION << "\n";
    cout << Version << "\n\n";
    cout << "Please key-in the location of your testing site: \n";
    cout << "Location:\t";
    getline(cin, Location);
    cout << "\nPlease key-in the path for the data files to be saved: \n";
    cout << "Path:\t";
    getline(cin, Datapath);
    cout << "\nPlease select start once the system is ready. \n\n";


    // Disable OpenCL explicitly here
    ocl::setUseOpenCL(false);
    VideoCapture capture(2);
    Mat current_frame, Gray_frame, Black_White, Black, Test;



    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //Trackbar region   /////////////////////////////////////////////////////////////////////////////////////////////////////
    //// For cropper
    int a = 0, b = 0, c = 0, d = 0;
    int

     blobcounter = 0;
        int x_counter = 0;
        int y_counter = 0;

        int buffer, counter = 0;
        int threshold_value = 0;
        int threshold_type = 3;
        int min_freq = 0;
        int state = 0;
        int const max_value = 255;
        int const max_type ...
(more)
edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by berak
close date 2019-04-04 05:53:59.630501

Comments

off topics: stdafx.h is not an opencv file.

LBerger gravatar imageLBerger ( 2019-04-04 03:14:23 -0600 )edit

also duplicate of [the last question]I(http://answers.opencv.org/...

and sorry @turiya, this is all indeed off-topic. you HAVE to learn, how to use your ide/compiler properly on your own, we can't help you here.

berak gravatar imageberak ( 2019-04-04 05:55:34 -0600 )edit