Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6232117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:03:42+00:00 2026-05-24T10:03:42+00:00

I’m getting two compile errors: /home/sater/projects/MotionManager/videoProcess.cpp:11:1: error: a function-definition is not allowed here before

  • 0

I’m getting two compile errors:

/home/sater/projects/MotionManager/videoProcess.cpp:11:1: error: a function-definition is not allowed here before ‘{’ token
/home/sater/projects/MotionManager/main.cpp:85:1: error: expected ‘}’ at end of input

I checked to make sure that all parentheses and brackets were matched, but can’t find the root of this problem. Could you please take a look at my code to see if I’m misunderstanding something? I’m new to c++ and am coming from mostly web programming and scripting experience but I’m a learn by doing sort of person so please excuse any mistakes due to not having “read my book” because I don’t have one. A simple explanation or link to more information about my failure would be helpful.

It seems like there must be some problem in the way I call the processVideoFile function, but I can’t figure out what I did wrong. Thanks for spending the time to take a look.

main.cpp

    #include <iostream>
#include <stdio.h>
#include <string>
#include <time.h>
#include "parseMotion.cpp"
#include "resumepause.cpp"
#include "videoProcess.cpp"

using namespace std;

bool DEBUG = true;

int main(int argc, char **argv) {
    //Useful directory strings
    string camDir [3];
    camDir[0]= "cam01(Outside)/";
    camDir[1]= "cam02(Upper)/";
    camDir[2]= "cam03(Lower)/";

    string latestWD = "/Store/SecurityStorage/LatestVideos/";
    string archiveWD = "/Store/SecurityStorage/VideoArchive/";

    int threadStatus [3];
    threadStatus[0] = 0;
    threadStatus[1] = 0;
    threadStatus[2] = 0;
    //-50 paused
    //-1 couldn't connect initially to camera
    //0 Not yet started
    //1 Started successfully
    //2 lost connection to cam - retrying

    deque<string> fileDeque;
    deque<int> fileTimingDeque;



    int exitTrig = -1;
    int counter = 0;

    FILE *MotionIOStream = popen("motion 2>&1", "r");
    if(!MotionIOStream){
      exitTrig = 1;
    }
    while( exitTrig < 0 )
    {      
      //Set maximum length, fgets: get one line
      char buffer[1024]; 
      string lineOutput;
      lineOutput = fgets(buffer, sizeof(buffer), MotionIOStream);

      //check mysqldb for pause/resume
      int rpResult;
      rpResult = checkSchedule(threadStatus);
      if(rpResult != 0)
      {
    return rpResult;
      }

      //process video - fork
      int pid;
      pid = processVideoFiles(fileDeque, fileTimingDeque);
      if(pid == 0)
      {
    return 0;
      }

      //cout << "Starting to parse" << endl;
      parseMotionOutput(lineOutput, threadStatus, fileDeque, fileTimingDeque);

      counter++;
      //[3] Thread 3 started
      if( counter > 20 )
      {
    exitTrig = 2;
    pclose(MotionIOStream);
    system("killall motion");
    return 0;
      }
    }
    //Handle error returns here.
    //case 1: "Couldn't start motion."
    //case 2: ""
    return 0;
}

Here is videoProcess.cpp:

#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <time.h>
#include <boost/xpressive/xpressive_static.hpp>

using namespace boost::xpressive;

int processVideoFiles( std::deque<std::string> &fileDeque, std::deque<int> &fileTimingDeque )
{

  std::time_t secondsNow;
  secondsNow = std::time(NULL);

  int nextFileSeconds = fileTimingDeque.front();
  int diff = secondsNow - nextFileSeconds;
  if( diff > 120)
  {
    //Should fork
    int pid = fork();
    if(pid == 0){
      //Is child
      std::string filePath = fileDeque.front();
      mark_tag wd(1), camDir(2), dateDir(3), fileName(4);
      // /Store/SecurityStorage/LatestVideos/cam03(Lower)/2011-07-21/01-20110721112236.avi
      sregex pathRegex =  (wd= "/Store/SecurityStorage/LatestVideos/") >> (camDir= ("cam0" >> range('1', '3') >> '/') ) >> (dateDir= ( repeat<4,4>(range('0', '9')) >> '-' >> '0' | '1' >> range( '0', '9' ) >> '/') ) >> (fileName= ( repeat<2,2>(range('0','9')) >> '-' >> repeat<14,14>(range('0','9')) >> '.' >> "avi" ) ) ;
      smatch pathWhat;
      if( regex_search(filePath, pathWhat, pathRegex) )
      {
    std::cout << "The working directory for this file is:" << pathWhat[wd] << std::endl;
    std::cout << "The camera directory for this file is:" << pathWhat[camDir] << std::endl;
    std::cout << "The date directory for this file is:" << pathWhat[dateDir] << std::endl;
    std::cout << "The filename of this file is:" << pathWhat[fileName] << std::endl;
      }else
      {
    std::cout << "Error: Couldn't match the file path regex." << std::endl;
    return 0;
      }

      //mplayer $filepath -vo jpeg -ao null -frames 25
      std::string commandString = "mplayer " + filePath + " -vo jpeg -ao null -frames 25";
      const char* commandChar = commandString.c_str();

      int commandResult = system(commandChar);
      if(commandResult != 0)
      {
    std::cout << "Couldn't create jpeg files for some reason" << endl;
      }else
      {
    return 0;
      }

      //Last steps
      fileDeque.pop_front();
      fileTimingDeque.pop_front();
    }
      return pid;
  }else
  {
    return 1;
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:03:43+00:00Added an answer on May 24, 2026 at 10:03 am

    It seems like you have forgot to put ; after a class declaration somewhere, or forgot to put a matching }. The error is most likely in one of your header files that you haven’t shown.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.