|
If it's embedded, go with C. Otherwise, just pick whichever one you want.
Jeremy Falcon
|
|
|
|
|
As the title states, I am having problems reading uncompressed avi files in MFC. It works fine on some files and reads different data on some avi files.
Here is the code-
pStream = g_GetAviStream(_T("D:\\Lab_Programs\\Matlab\\output.avi"), &frames, &fWidth, &fHeight, &iFirstFrame, &nPlanes, &fBufSize);
fWidthOffs = fWidth%4;
tempBuff = new BYTE[fWidth*fHeight*nPlanes];
ZeroMemory(tempBuff, sizeof(BYTE)*fWidth*fHeight*nPlanes);
pFrame = AVIStreamGetFrameOpen(pStream, NULL);
bytBuff = new BYTE[fBufSize];
for (i = 0; i < frames; i ++)
{
imgTemp = (BYTE*) AVIStreamGetFrame(pFrame, i);
RtlMoveMemory(&bih.biSize, imgTemp, sizeof(BITMAPINFOHEADER));
RtlMoveMemory(bytBuff, imgTemp+sizeof(BITMAPINFOHEADER)+sizeof(RGBQUAD)*256, bih.biSizeImage);
ind = i*fWidth*fHeight*nPlanes;
for (j = 0; j < fHeight; j ++) {
idxd1 = j*nStimVideoNX;
idxs = (fHeight-1-j) * (fWidth * nPlanes + fWidthOffs);
for (k = 0; k < fWidth; k ++) {
datain = bytBuff[idxs + k*nPlanes];
tempBuff[idxd1+k] = datain;
}
}
}
After doing this, I am writing tempBuff to a text file to view the contents in maltab and imshow it. If you play the video, you will see two black squares inside the frame, but when I check the text file for frame 3, I only see one black square. Here is the link[^] for a sample file that I am trying to read.
PKNT
|
|
|
|
|
Are you certain that all of your test files have a 256-colour palette? See the BITMAPINFOHEADER structure[^] for details about other possibilities.
Note also that the height, width, and number of planes are encoded in the header. Ensure that these are as expected before decoding!
Lastly, the BITMAPINFOHEADER contains its size in the first element. Use this either as a "sanity check" or instead of sizeof(BITMAPINFOHEADER).
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
For the file I attached in my first post, AVIFileInfo is returning the following data-
avi_info {dwMaxBytesPerSec=0 dwFlags=0 dwCaps=3 ...} _AVIFILEINFOA
dwMaxBytesPerSec 0 unsigned long
dwFlags 0 unsigned long
dwCaps 3 unsigned long
dwStreams 1 unsigned long
dwSuggestedBufferSize 2296 unsigned long
dwWidth 26 unsigned long
dwHeight 82 unsigned long
dwScale 33333 unsigned long
dwRate 1000000 unsigned long
dwLength 30 unsigned long
dwEditCount 0 unsigned long
szFileType 0x0068e930 "AVI Default File Handler" char [64]
When I write the frame to a text file after
imgTemp = (BYTE*) AVIStreamGetFrame(pFrame, i);
I see the correct header of 1064 bytes, but the image data doesn't have two black squares that I am supposed to see (for example from frame 3), but only one black square.
Any ideas?
PKNT
|
|
|
|
|
If you are writing the data to a text file in Windows, it is quite possible that you will see garbage. You must write the file as a binary file (e.g. fopen(file, "wb")).
I can't actually read your sample file (I don't have access to your OneDrive account), so I can't verify this myself.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
I guess I found the problem. It was the way Matlab is writing the avi files. By default, for uncompressed gray scale avi files it uses 64 level color map and indicies data to it. Now the problem is resolved.
PKNT
|
|
|
|
|
I am trying to rebuild small data base to improve on my terrible knowledge of pointers.
The array is pretty simple integers representing ASCII code , I do the conversion by casting the int or char to LCD print function for display. Works fine with one problem - one of the int in the array is a REAL number ( 0 thru 9) , not just ASCII representation of a number.
For illustration - the ints are 32 65 73 7 73
The "problem " the index #3 does not read just 7 , but 773.
And the array sizeof is also 3 , and it should be 4.
Majority of the code is just for debug.
I can change the real numbers to ASCII representation but would like to know why is this behaving this way.
Appreciate your help.
Vaclav
<pre><pre
int *pCarrier[sizeof(iRecordIndex)];
for (i = 0; i != sizeof(iRecordIndex); i++)
{
pCarrier[i] = &iRecord[i]; // assign data to pointer
lcd_i2c.setCursor(0, 0);
lcd_i2c.print("Index " );
lcd_i2c.print(i);
lcd_i2c.setCursor(0, 1);
lcd_i2c.print((char) iRecord[i] );
lcd_i2c.setCursor(0, 2);
lcd_i2c.print(iRecord[i] );
lcd_i2c.print(" ");
lcd_i2c.print(*pCarrier[i] );
delay(DELAY);
}
lcd_i2c.clear();
lcd_i2c.print("Database " );
lcd_i2c.setCursor(0, 1);
for (i = 0; i != sizeof(iRecordIndex)+ 1 ; i++)
{
lcd_i2c.print((int)*pCarrier[i] );
delay(DELAY);
}
pre></pre>
|
|
|
|
|
How is iRecord declared and initialized?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
Why are you using double dereferencing? It would be much easier to code (and certainly to understand) by using arrays of integers rather than pointers. Something like:
int pCarrier[sizeof(iRecordIndex)]; for (i = 0; i < sizeof(iRecordIndex); i++)
{
pCarrier[i] = iRecord[i];
Or better still just use the elements of the original array, since, presumably, it is a simple aray of integers.
|
|
|
|
|
I have modified the 3 position in the int array to ASCII representation and it worked.
I do not understand why it does not work with int 0 thru 9 in 3rd position.
I have included the database read and that is totally bogus when it fails.
I still do not understand what the sizeof(iRecordIndex) is telling me.
Modifying the iRecordIndex ( adding to it ) does not have any effects.
The record has been initialized - this is first time I am using it and it contains 5 ints and rest of it is all zeroes.
The iRecordIndex is 4 during this test.
PS I had the end test in for loop wrong, but the 3rd index value was still printing wrong on LCD.
<pre lang="c++"></pre>
//iRecord[iRecordIndex]
//iRecordIndex += 3;
int iField[32] = {}; // will need to reinitialize
int *pCarrier[sizeof(iRecordIndex)]; // ponter to field
for (i = 0; i != sizeof(iRecordIndex)+ 1 ; i++)
{
pCarrier[i] = &iRecord[i]; // assign data to pointer
lcd_i2c.setCursor(0, 0);
lcd_i2c.print("Index " );
lcd_i2c.print(i);
//lcd_i2c.print(pCarrier );
lcd_i2c.setCursor(0, 1);
lcd_i2c.print((char) iRecord[i] );
lcd_i2c.setCursor(0, 2);
lcd_i2c.print(iRecord[i] );
lcd_i2c.print(" ");
lcd_i2c.print(*pCarrier[i] );
delay(2*DELAY);
}
lcd_i2c.clear();
lcd_i2c.print("Database " );
lcd_i2c.setCursor(0, 1);
for (i = 0; i != sizeof(iRecordIndex) + 1 ; i++)
{
lcd_i2c.print((int)*pCarrier[i] );
delay(DELAY);
}
|
|
|
|
|
Vaclav_Sal wrote: I still do not understand what the sizeof(iRecordIndex) is telling me.
You have not told us how iRecordIndex is declared and initialized.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Sorry.
Both iRecord and iRecordIndex are declared as int and as class variables and initialized in the start of this loop.
The iRecord is reset for next iDatabaseIndex, but I am not that far in checking the code.
(The record needs to be split into several fields, again of variable length).
I wanted to "do pointers" since the database fields length vary and like to save some memory in ARM processor.
for (iDatabaseIndex = 0; iDatabaseIndex < MAX_DATABASE; iDatabaseIndex++)
{
iRecordIndex = 0;
iRecord[32] = {};
....
|
|
|
|
|
This is probably what you need:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
int main(void)
{
char str[256] = "32 65 73 7 73";
int *pn = NULL, n = 0;
char* _tsn = strtok(str, " ");
while (_tsn != NULL)
{
int* tmp = new int[n + 1];
if (pn != NULL) memcpy((void*)tmp, pn, sizeof(int) * n);
tmp[n++] = atoi(_tsn);
if (tmp != NULL) pn = tmp;
_tsn = strtok(NULL, " ");
}
for (int i = 0; i < n; i++)
printf("%d ", pn[i]);
printf("\n");
_getch();
return 0;
}
|
|
|
|
|
www.codeproject.com/KB/recipes/csha1/CSHA1-2.1-Source.zip
i downloaded d sha1(a hash algo) code from d given link,but i don't know how to use this zip file to encrypt my msg.
pls help!
|
|
|
|
|
Try asking the author of the article, there's a comment section at the bottom of the article for questions. Did you unzip the files and add them to your project?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Hello there. VC++ part of the visual studio is very slow. Debugging is very slow, choosing and compiling a project is very slow, typing is very slow (sometimes it takes more than one second for a letter to show after its corresponding key was hit).
Why is there so much delay in text editor and other things? (Rest of the visual studio i.e. C# and VB are fine). What could be wrong ??
======================================
Solved - Solution Below
======================================
I just installed the Sql Server Compact Edition and this solved my problem. I don't know whether I should have disabled the related components ORR what I did was the right solution. Any way, thanks all the guys for your input.
This world is going to explode due to international politics, SOON.
modified 12-Aug-15 8:39am.
|
|
|
|
|
Native code doesn't like managed IDE.
Seriously, I have the Expression Edition and see no difference in regards of C# or C++.
|
|
|
|
|
It's a problem for you, I have VS2013 Express and it works fine.
|
|
|
|
|
Same software is installed on another machine but it is working fine there. It is just this machine where it is problematic (c++ only). Do I need to check some settings like graphics or something (though I dont see a reason for it) ?
This world is going to explode due to international politics, SOON.
|
|
|
|
|
It could be any number of things. Maybe your computer has a bunch of add-ins running that is slowing the system down.
You can lead a developer to CodeProject, but you can't make them think.
The Theory of Gravity was invented for the sole purpose of distracting you from investigating the scientific fact that the Earth sucks.
|
|
|
|
|
Hello there, sorry but am a noob at this..... My question is: is there a python implementation of psola
|
|
|
|
|
Wrong forum.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
|
Hi!
I ran the Activating a Window program and found that it goes in an endless loop, where one of the three states it can switch to will be selected, however none of the close buttons on the message boxes function and the only way I was able to end the program was by use of the Task Manage. I have tried a variety of solutions, but none are worthy. I also notice that even when I use my mouse to react to the message boxes, the message that comes up can be This window has been activated, without the mouse.
This seems pretty dysfunctional in terms of a tool to switch between window, since a method should be possible by which to deactivate and close all the windows shown.
|
|
|
|