|
Thanks CPallini,
Cool!
regards,
George
|
|
|
|
|
Did you check when you want to allocate memory?
|
|
|
|
|
Thanks Hamid,
What do you mean check? Check what?
regards,
George
|
|
|
|
|
When you want to allocate dynamic memory did you check for example use of try/catch?
|
|
|
|
|
Hi Hamid,
Which example do you mean? URL please?
regards,
George
|
|
|
|
|
No I said for example use of try/catch not Example.
|
|
|
|
|
Hi Hamid,
I am confused, which sample do you mean? If you mean anything of this forum, could you provide a link please?
regards,
George
|
|
|
|
|
No I said (for example) not a example.dont worry
|
|
|
|
|
dear all
how to set path in setting of option? anyone has experience or some detail to introduce this? thanks a lot.
Li Zhiyuan
5/1/2008
|
|
|
|
|
What are you talking about ?
|
|
|
|
|
Hey Tox, was you on vacation, wasn't you?
Happy New Year and best wishes.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
yup, and to be fully exact, I'm still on vacation.
I was off from Codeproject because I went to Lithuania for the new year
|
|
|
|
|
Do you mean additional search paths for include files?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
yes, you are right, when we go to tool-> option, we can see executable file..but we also can choose include file, how to set the path there? i encountered a problem, after compilation,output showed me:
fatal error C1083: Cannot open include file: 'Centroids.h': No such file or directory
so i dun know how to set this path.
thanks
Li Zhiyuan
5/10/2006
|
|
|
|
|
Well, IMHO, the best behaviour will be to put your Centroids.h header file inside the project source folder (where is, for instance Centroids.cpp ) and then use:
#include "Centroids.h"
into Centroids.cpp .
However, if you really need to put Centroids.h in a special folder, then, adding such a folder to the VC++ include directories isn't difficult:
(1) Choose Tools->Options menu item
(2) Select Project and Solutions->VC++ Directories node.
(3) Select Include Files item in the Show Directories for list.
(4) Choose the New line (folder icon) button or press CTRL+INS key combination.
(5) Add the path of the folder wherein Centroids.h is (you can browse for).
(6) Enjoy compilation (remember the #include "Centroids.h" in the source code)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
yes, actually i did like this already, centroids just is a class in my header file... i installed vc++ 2005 in D driver, but my project in C driver..so i added a direcotry included my project in C driver...but the problem is still like this
Li Zhiyuan
5/10/2006
|
|
|
|
|
li zhiyuan wrote: i installed vc++ 2005 in D driver, but my project in C driver.
That shouldn't be a problem.
Check well all that you've made.
You can also try to start from zero agin.
Good luck.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
this is my all source code, i combined together, it can run smoothly, but i seperated, the problem is like above.
#include <iostream>
using std::endl;
using std::cin;
using std::cout;
#include <cstdlib>
using std::rand;
using std::srand;
#include <iomanip>
using std::setw;
using std::setprecision;
using std::ios;
using std::fixed;
using std::showpoint;
using std::setiosflags;
#include <ctime>
using std::time;
class Centroids
{
public:
void printArray(double a[3][4] )
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 4; j++)
cout << setw(3) << setprecision(6) << setiosflags(ios::fixed|ios::showpoint) << a[i][j] << " ";
cout << endl;
}
}
private:
double a[3][4];
};
int main()
{
Centroids matrix;
int number = 1;
for (int number = 1; number <=10; number++)
{
double a[3][4] = {{(double)rand()/RAND_MAX, (double)rand()/RAND_MAX, (double)rand()/RAND_MAX,( double)rand()/RAND_MAX},{(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX},{(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX}};
cout << setw(4) << number << endl;
matrix.printArray(a);
cout << endl;
}
number = number + 1;
return 0;
}
the following is what i seperated code above, can you help me to check? what is problem?
header file:
include <iostream>
using std::endl;
using std::cin;
using std::cout;
#include <iomanip>
using std::setw;
using std::setprecision;
using std::ios;
using std::fixed;
using std::showpoint;
using std::setiosflags;
class Centroids
{
public:
void printArray(double a[3][4] )
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 4; j++)
cout << setw(3) << setprecision(6) << setiosflags(ios::fixed|ios::showpoint) << a[i][j] << " ";
cout << endl;
}
}
private:
double a[3][4];
};
cpp code:
#include <iostream>
using std::endl;
using std::cin;
using std::cout;
#include <cstdlib>
using std::rand;
using std::srand;
#include <iomanip>
using std::setw;
using std::setprecision;
using std::ios;
using std::fixed;
using std::showpoint;
using std::setiosflags;
#include <ctime>
using std::time;
#include "Centroids.h"
int main()
{
Centroids matrix;
int number = 1;
for (int number = 1; number <=10; number++)
{
double a[3][4] = {{(double)rand()/RAND_MAX, (double)rand()/RAND_MAX, (double)rand()/RAND_MAX,( double)rand()/RAND_MAX},{(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX},{(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX}};
cout << setw(4) << number << endl;
matrix.printArray(a);
cout << endl;
}
number = number + 1;
return 0;
}
thanks a lot
Li Zhiyuan
5/10/2006
|
|
|
|
|
yes, actually i did like this already, centroids just is a class in my header file... i installed vc++ 2005 in D driver, but my project in C driver..so i added a direcotry included my project in C driver...but the problem is still like this.
the following is combined code:
#include <iostream>
using std::endl;
using std::cin;
using std::cout;
#include <cstdlib>
using std::rand;
using std::srand;
#include <iomanip>
using std::setw;
using std::setprecision;
using std::ios;
using std::fixed;
using std::showpoint;
using std::setiosflags;
#include <ctime>
using std::time;
class Centroids
{
public:
void printArray(double a[3][4] )
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 4; j++)
cout << setw(3) << setprecision(6) << setiosflags(ios::fixed|ios::showpoint) << a[i][j] << " ";
cout << endl;
}
}
private:
double a[3][4];
};
int main()
{
Centroids matrix;
int number = 1;
for (int number = 1; number <=10; number++)
{
double a[3][4] = {{(double)rand()/RAND_MAX, (double)rand()/RAND_MAX, (double)rand()/RAND_MAX,( double)rand()/RAND_MAX},{(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX},{(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX}};
cout << setw(4) << number << endl;
matrix.printArray(a);
cout << endl;
}
number = number + 1;
return 0;
}
the following is seperate code:
header file:
include <iostream>
using std::endl;
using std::cin;
using std::cout;
#include <iomanip>
using std::setw;
using std::setprecision;
using std::ios;
using std::fixed;
using std::showpoint;
using std::setiosflags;
class Centroids
{
public:
void printArray(double a[3][4] )
{
for (int i = 0; i <3; 3; i++)
{
for (int j = 0; j < 4; j++)
cout << setw(3)<< setprecision(6) << setiosflags(ios::fixed|ios::showpoint)<< a[i][j] <<; " ";
cout <<; endl;
}
}
private:
double a[3][4];
};
cpp code:
#include <iostream>
using std::endl;
using std::cin;
using std::cout;
#include <cstdlib>
using std::rand;
using std::srand;
#include <iomanip>
using std::setw;
using std::setprecision;
using std::ios;
using std::fixed;
using std::showpoint;
using std::setiosflags;
#include <ctime>
using std::time;
#include "Centroids.h"
int main()
{
Centroids matrix;
int number = 1;
for (int number = 1; number <=10; number++)
{
double a[3][4] = {{(double)rand()/RAND_MAX, (double)rand()/RAND_MAX, (double)rand()/RAND_MAX,( double)rand()/RAND_MAX},{(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX},{(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX}};
cout << setw(4)<< number << endl;
matrix.printArray(a);
cout << endl;
}
number = number + 1;
return 0;
}
Li Zhiyuan
5/10/2006
|
|
|
|
|
What you have here is a big ol' mess. Why have you duplicated the code in both the .h and .cpp files? Put the class declaration in the .h file like:
class Centroids
{
public:
void printArray( double a[3][4] );
}; Then put its definition in the .cpp file like:
#include "centroids.h"
void Centroids::printArray( double a[3][4] )
{
using namespace std;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 4; j++)
cout << setw(3) << setprecision(6) << setiosflags(ios::fixed | ios::showpoint) << a[i][j] << " ";
cout << endl;
}
} li zhiyuan wrote: int number = 1;
for (int number = 1;
Why do you have number declared twice?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: Why do you have number defined twice?
He has the Visual Studio Dumb Edition C++ Compiler.
Thank you for pointing out code mess. I overlooked his code, focusing my attempts to help him to properly set the environment.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
did u find any problem in my code? after i seperated these code, it has a problem after combilation, the problem is like previous one thati showed you in last session.
thanks
Li Zhiyuan
6/01/2008
|
|
|
|
|
Hi Friends
I Am new to this site
i got one problem regarding playback of mpeg compressed files
iam using windows mfc for this
iam receiving the file from the board via tcp protocol and iam storing in the hard disk and then calling decompression function like this
Decompression("filename.M4V");
HERE I WANT DIRECTLY WITHOUT STORING IN THE HARD DISK
IF WE WON'T GIVE EXTENSION TO FILE(LIKE .M4V,.MP4 ETC)IT IS NOT WORKING AT THE FUNCTION guess_format OF AV LIBRARY.
THE DETAILS OF THIS guess_format FUNCTION I DON'T KNOW
while i am storing the file (around 2 mb) in the buffer and calling decompression it is not working.but if you take from hard disk it is working....
pls help me
here m providing the code for reference
int Decompression(char *inputfile)
{
const char *filename;
AVOutputFormat *fmt;
AVFormatContext *oc;
AVStream *video_st;
double video_pts;
unsigned int i = 0;
AVFormatContext *pFormatCtx;
int videoStream = 0;
AVCodecContext *pCodecCtx;
AVFrame *pFrame;
AVCodec *pCodec;
AVPacket packet;
int frameFinished;
const char *filenamei;
AVOutputFormat *fmt1;
// initialize libavcodec, and register all codecs and formats */
av_register_all();
filename = "Girish1.YUV";
filenamei = inputfile;
// auto detect the output format from the name. default is mpeg. */
fmt = guess_format(NULL, filename, NULL);
if (!fmt)
{
printf("Could not deduce output format from file extension: using MPEG.\n");
fmt = guess_format("mpeg", NULL, NULL);
}
if (!fmt)
{
fprintf(stderr, "Could not find suitable output format\n");
exit(1);
}
fmt1 = guess_format(NULL, filenamei, NULL);
if (!fmt1)
{
printf("Could not deduce input format from file extension: using MPEG.\n");
fmt1 = guess_format("mpeg", NULL, NULL);
}
if (!fmt1)
{
fprintf(stderr, "Could not find suitable input format\n");
exit(1);
}
// Open video file input
if(av_open_input_file(&pFormatCtx, filenamei, NULL, 10000, NULL)!=0)
{
printf("Couldn't open input file\n");
return NULL; // Couldn't open file
}
// Retrieve stream information
if(av_find_stream_info(pFormatCtx)<0)
{
printf("Couldn't find stream information\n");
return NULL; // Couldn't open file
} // Couldn't find stream information
// Dump information about file onto standard error
dump_format(pFormatCtx, 0, filenamei, false);
// Find the first video stream
videoStream=-1;
for(i=0; i < (pFormatCtx->nb_streams); i++)
if(pFormatCtx->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO)
{
videoStream=i;
break;
}
if(videoStream==-1)
{
printf("Didn't find a video stream\n");
return NULL; // Didn't find a video stream
}
// Get a pointer to the codec context for the video stream
pCodecCtx=pFormatCtx->streams[videoStream]->codec;
pCodecCtx->width = RESW;
pCodecCtx->height =RESH;
// Find the decoder for the video stream
pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
if(pCodec==NULL)
{
printf("Codec not found\n");
return NULL; // Codec not found
}
// bitstreams where frame boundaries can fall in the middle of packets
/* if(pCodec->capabilities & CODEC_CAP_TRUNCATED)
{
pCodecCtx->flags|=CODEC_FLAG_TRUNCATED;
}*/
// Open codec
if(avcodec_open(pCodecCtx, pCodec)<0)
{
printf("Could not open codec\n");
return NULL; // Could not open codec
}
// Allocate video frame
/*pFrame = alloc_picture(pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height);
if (!pFrame)
{
fprintf(stderr, "Could not allocate picture\n");
exit(1);
}*/
// allocate the output format context */
oc = av_alloc_format_context();
if (!oc)
{
fprintf(stderr, "Memory error\n");
exit(1);
}
oc->oformat = fmt;
_snprintf(oc->filename, sizeof(oc->filename), "%s", filename);
// add the video streams using the default format codecs and initialize the codecs
video_st = NULL;
if (fmt->video_codec != CODEC_ID_NONE)
{
video_st = add_video_stream(oc, fmt->video_codec);
}
// set the output parameters
if (av_set_parameters(oc, NULL) < 0)
{
fprintf(stderr, "Invalid output format parameters\n");
exit(1);
}
dump_format(oc, 0, filename, 1);
// now that all the parameters are set, we can open the video codecs and allocate the necessary encode buffers
if (video_st)
{
if(!(open_video(oc, video_st)))
{
printf("\nfailed to open videostream for output");
exit(1);
}
}
// open the output file, if needed */
if (!(fmt->flags & AVFMT_NOFILE))
{
if (url_fopen(&oc->pb, filename, URL_WRONLY) < 0)
{
fprintf(stderr, "Could not open '%s'\n", filename);
exit(1);
}
}
// write the stream header, if any
if((av_write_header(oc)) != 0)
{
printf("\nfailed to write the header");
}
for(;;k++)
{
// compute current video time
if (video_st)
{
video_pts = (double)video_st->pts.val * video_st->time_base.num / video_st->time_base.den;
}
else
{
video_pts = 0.0;
}
pFrame = alloc_picture(pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height);
if (!pFrame)
{
fprintf(stderr, "Could not allocate picture\n");
exit(1);
}
// write interleaved video frames */
if(av_read_frame(pFormatCtx, &packet)>=0)
{
if(packet.stream_index==videoStream)
{
// Decode video frame
avcodec_decode_video(pCodecCtx, pFrame, &frameFinished, packet.data, packet.size);
video_outbuf_size1 = 2000000; //by me
video_outbuf1 = (unsigned char *) av_malloc(video_outbuf_size1);
if(not_init == false)
{
not_init = true;
InitConvertTable();
}
// ConvertYUVtoYUV(320,240,(unsigned int*)pFrame,(unsigned int*)pFrame);
ConvertYUV2RGB((unsigned char*)pFrame->data[0],(unsigned char*)pFrame->data[1],(unsigned char*)pFrame->data[2],video_outbuf1,RESW,RESH);
PostMessage(g_hWnd,ON_RENDER,(unsigned long)video_outbuf1, NULL);
//Sleep(100);
// Did we get a video frame?
if(frameFinished)
{
if(!(write_video_frame(oc, video_st,pFrame,i)))
{
printf("\nfailed to write the video frame");
exit(1);
}
av_free_packet(&packet);
av_free(pFrame);
}
}
}
else
break;
}
//av_free_packet(&packet);
//av_free(pFrame);
// close each codec */
if (video_st)
{
close_video(oc, video_st);
}
// write the trailer, if any */
if((av_write_trailer(oc)) != 0)
{
printf("\nfailed to write the trailer");
}
// free the streams */
for(i = 0; i < oc->nb_streams; i++)
{
av_freep(&oc->streams[i]->codec);
av_freep(&oc->streams[i]);
}
if (!(fmt->flags & AVFMT_NOFILE))
{
// close the output file */
url_fclose(&oc->pb);
}
// free the stream */
av_free(oc);
av_free(video_outbuf1);
// Close the codec
avcodec_close(pCodecCtx);
// Close the video file
av_close_input_file(pFormatCtx);
//free(p);
return 0;
}
Girish
Girish
|
|
|
|
|
In excel you can convert a date of 1/4/2008 to 39451 by formating a the cell to numeric.
Not sure how excel does this but would like to do the same thing in my VB.Net program.
Has anyone come across this? ANy Idea's?
Regards
|
|
|
|
|
If you have a look at Excel documentation (date serial numbers) , then a rough procedure maybe
Dim i As Long
Dim dt0 As DateTime, dt1 As DateTime
dt1 = New DateTime(2008, 1, 4)
dt0 = New DateTime(1900, 1, 1)
i = (dt1 - dt0).Days + 2
Please note, this doesn't return decimal numbers on fraction of days (as Excel does).
BTW try also to ask the VB/VB.NET forum.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|