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

  • SEARCH
  • Home
  • 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 7555311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:34:32+00:00 2026-05-30T11:34:32+00:00

I am trying to implement face recognition on camera captured faces.In order to make

  • 0

I am trying to implement face recognition on camera captured faces.In order to make a face dataset i need to store multiple images of single person.For that i need to grab multiple frames from camera and save them.

#include"cv.h"
#include"highgui.h"
#include <iostream>
using namespace cv;
// Grab the next camera frame. Waits until the next frame is ready, and
// provides direct access to it, so do NOT modify or free the returned image!
// Will automatically initialize the camera on the first frame.
#include"highgui.h"
#include<iostream>

using namespace cv;
IplImage* getCameraFrame(CvCapture* &camera);
int main()
{
    CvCapture* camera = 0;  // The camera device.
    while ( cvWaitKey(10) != 27 ) 
    {   // Quit on "Escape" key.
        IplImage *frame = getCameraFrame(camera);
        cvSaveImage("Frame:",frame);
    }
    return 0;
}
IplImage* getCameraFrame(CvCapture* &camera)
{
    IplImage *frame;
    int w, h;

    // If the camera hasn't been initialized, then open it.
    if (!camera) {
        printf("Acessing the camera ...\n");
        camera = cvCreateCameraCapture( 0 );
        if (!camera) {
            printf("Couldn't access the camera.\n");
            exit(1);
        }
        // Try to set the camera resolution to 320 x 240.
        cvSetCaptureProperty(camera, CV_CAP_PROP_FRAME_WIDTH, 320);
        cvSetCaptureProperty(camera, CV_CAP_PROP_FRAME_HEIGHT, 240);
        // Get the first frame, to make sure the camera is initialized.
        frame = cvQueryFrame( camera );
        if (frame) {
            w = frame->width;
            h = frame->height;
            printf("Got the camera at %dx%d resolution.\n", w, h);
        }
        // Wait a little, so that the camera can auto-adjust its brightness.
        Sleep(1000);    // (in milliseconds)
    }

    // Wait until the next camera frame is ready, then grab it.
    frame = cvQueryFrame( camera );
    if (!frame) {
        printf("Couldn't grab a camera frame.\n");
        exit(1);
    }
    return frame;
}

But in cvSaveImage i need to give a name to the image to be saved.the names should be unique otherwise multiple frames overwrite on 1image only.
How can i solve this problem?

  • 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-30T11:34:34+00:00Added an answer on May 30, 2026 at 11:34 am

    you can use a integer variable for counting sequence

    int counter = 0;
    char *filename = "Photo"
    
    while ( cvWaitKey(10) != 27 ) 
    {   // Quit on "Escape" key.
        IplImage *frame = getCameraFrame(camera);
    
        counter++;
        filename = getNextName(counter);
        cvSaveImage(filename ,frame);
    }
    

    in the getNextName() function you can do an integer conversion and a string concat .jpg

    char* getNextName(int counter)
    {
        char buf[5];
        char *filename = "Photo";
    
        // convert 123 to string [buf]
        itoa(counter, buf, 10);    // int to char 
        strcat(filename, buf);     // concat "Photo" + "1" = "Photo1"
        strcat(filename, ".jpg");  // concat "Photo1" + ".jpg" = "Photo1.jpg"
    
       return filename;
    } 
    

    it will automatically save your image using a new name with sequence of number.

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

Sidebar

Related Questions

I've been trying to implement the Facebook SDK into my application in order to
I've been trying to research a safer way to implement Cufón that would store
I'm trying to implement the Viola Johns face detection algorithm on Cuda platform (I'm
I am trying to implement a fixed-point class in C++, but I face problems
I'm trying to implement the technique described at : Compositing Images with Depth .
Just trying to implement mobFox into my app, but having trouble to make it
Trying to implement Wpf Listbox dragging, and I need the Wpf equivalent of the
Im trying to implement pagination using multiple searching criteria. Supposed I Have student table.
Trying to implement Piwik using REST API over http but need a little help.
I am trying to convert my SurfaceView (camera preview) into a Bitmap for face

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.