Does anybody know why
unsigned char myImage[512*480]; works but
unsigned char myImage[1004*1001]; does not?
I think its because the second line is a value too big for unsigned
char, is this correct?
If so:
How do I create this pointer for the size 1004*1001? I have tried
using long, int etc but the image processing function that I pass the
pointer to does not accept this. The function requires me to cast the
unsigned char into a long when I pass the pointer, I don't know if this
is making a difference; as your probably confused heres some code:
unsigned char myImage[512 * 480]; //Size for Halcon image
//unsigned char myImage[1004 * 1001]; //Size for Halcon image ///does
not work////////
//create a Halcon Image to receive output from edge detection
::gen_image1(&i mgIPPCannyOut, "byte", dev->nBufferWidth ,
dev->nBufferHeigh t, (long)myImage);
Thank You 5 8964
wallacej wrote: Does anybody know why
unsigned char myImage[512*480]; works but
unsigned char myImage[1004*1001]; does not?
I think its because the second line is a value too big for unsigned char, is this correct?
No.
<compilerspeici fic>
If this is an automatic array, your _stack_ is probably too small to
accommodate that large of an array.
</compilerspeicif ic>
Try a dynamic one:
unsigned char *myImage = new unsigned char[1004*1001];
just don't forget to dispose of it when you don't need it any longer:
delete[] myImage;
V
"wallacej" <ja************ *@yahoo.co.uk> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. . Does anybody know why
unsigned char myImage[512*480]; works but
unsigned char myImage[1004*1001]; does not?
Please describe 'work' and 'not work'. How does
your program's behavior (or success/failure of compile)
differ when using each of those definitions? I think its because the second line is a value too big for unsigned char, is this correct?
No. The range of a type has no bearing at all upon how
large an array can be. Without more specific description
of 'does not work', I can only make a few guesses:
- Your implementation' s type 'size_t' range does not include the
value 1004 * 1001.
- Your arrays above are defined with automatic storage duration
(i.e. at block scope), and 1004 * 1001 is larger than the number
of bytes alloted for automatic objects (can cause many implementations
to issue a 'stack overflow' message.
- Your arrays above are defined with static storage duration
(i.e. at file scope, or at block scope with the 'static' qualifier),
and 1004 * 1001 is larger than the number of bytes alloted for static
storage.
- The moon is in the wrong phase. :-) If so:
How do I create this pointer for the size 1004*1001?
What pointer? There is no pointer in your example code.
Only arrays.
I have tried using long, int
It seems to me you're simply guessing, 'shooting in the dark'.
I strongly recommend some books and study/practice time.
etc but the image processing function that I pass the pointer to does not accept this.
What function? What are its argument types and return type?
The function requires me to cast the unsigned char
What unsigned char?
into a long
Why? Is one of its paramters type 'long'? If so, why
are you passing an unsigned char?
when I pass the pointer,
What pointer? (Yes, when passed to a function, an array
is converted to a pointer to its first element, but we
cannot know if you're doing things correctly without
some description of the function you're calling (esp.
its signature)).
I don't know if this is making a difference; as your probably confused heres some code:
unsigned char myImage[512 * 480]; //Size for Halcon image //unsigned char myImage[1004 * 1001]; //Size for Halcon image ///does not work////////
Yes, your description does confuse me as to what you're
really asking. And no, that code doesn't help, it's exactly
the same as that near the top of your message. Again, saying
'does not work', helps us help you not at all.
//create a Halcon Image to receive output from edge detection ::gen_image1(&i mgIPPCannyOut, "byte", dev->nBufferWidth , dev->nBufferHeigh t, (long)myImage);
It's almost certainly a mistake to cast 'myImage' to type long.
What does such a value *mean*?
I suspect you need to do more reading about how to correctly
use the 'gen_image1' function (which part of course isn't topical
here).
-Mike
Mike Wahler wrote: "wallacej" <ja************ *@yahoo.co.uk> wrote in message news:11******** **************@ g43g2000cwa.goo glegroups.com.. . I think its because the second line is a value too big for unsigned char, is this correct?
No. The range of a type has no bearing at all upon how large an array can be.
I'm not sure you said what you meant to say there. The range of a type
is usually closely tied to the size of the type. The size of the type
can affect how large of an aggregate can be created by the
implementation.
The fact that the index can't be contained in the type is of no
consequence, because the array isn't indexed with the base type of the
array.
Brian
"Default User" <de***********@ yahoo.com> wrote in message
news:3l******** *****@individua l.net... Mike Wahler wrote:
"wallacej" <ja************ *@yahoo.co.uk> wrote in message news:11******** **************@ g43g2000cwa.goo glegroups.com.. . > I think its because the second line is a value too big for unsigned > char, is this correct?
No. The range of a type has no bearing at all upon how large an array can be.
I'm not sure you said what you meant to say there.
Perhaps not. Happens to me all the time with women. :-)
The range of a type is usually closely tied to the size of the type. The size of the type can affect how large of an aggregate can be created by the implementation.
Agreed. I suppose I meant to say, rather than (total) 'size
of an array', was 'number of elements in an array' (which is
of course governed by the range of type 'size_t'.) The fact that the index can't be contained in the type is of no consequence, because the array isn't indexed with the base type of the array.
Right. Thanks for trying to help divert any possible misunderstandin gs
my poor wording may have caused anyone.
-Mike
thanks for your help guys. I have read all of your suggestions and
learnt a great deal, you'll have probably guessed that I'm a bit of an
amateur at C++.
I started working through the list of suggestions in this topic in an
effort to solve my problem and the first suggestion seems to be
working. I created a dynamic array which does the job nicely.
However, my imaging system stops detecting particles after a certain
amount of time/images/particles. I have a feeling I've got a memory
leak somewhere. Anyhow, I'll rig the system up to a controlled test
and if the problem is relevant to this group i'll get back to you guys.
Thanks again
Wallace This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Roy Hills |
last post by:
When I'm reading from or writing to a network socket, I want to use a
struct to represent the structured data, but must use an unsigned char
buffer for the call to sendto() or recvfrom().
I have two questions:
1. Is it generally safe to "overlay" the structure on the buffer,
e.g.:
unsigned char buffer;
|
by: b83503104 |
last post by:
When are they not consistent?
|
by: cbachellam |
last post by:
Hello,
I am trying to call c++ dll function calls from C#. The c++ dll function
takes in pointer to unsigned char array. Can anybody help me in what
marshalling parameter value that i have to declare in C# side.
For eg:
in c++ X.dll the function is:
extern "C" __declspec(dllexport) void Getcharpointer(unsigned char* v)
{
//Just for test purpose, i alter and check on the C# side whether it
|
by: Tom |
last post by:
Hi newsgroup,
I have read a lot af articles about marshalling in C#, but none of
them could help me to solve the following problem:
There is a C-DLL with the following header-file:
++++++++ C Header file start ++++++++++++++++++++++++++++++
#ifndef __UFISC_H
#define __UFISC_H
|
by: cdrom205 |
last post by:
static void MDString ( unsigned char *input)
{
MD5_CTX context;
unsigned char digest;
unsigned int len = sizeof(input);//strlen (const char*)
md5.MD5Init (&context);
md5.MD5Update (&context, input, len);
// void MD5Update (MD5_CTX *context, unsigned char *input, unsigned
| |
by: ryanlee101 |
last post by:
I am getting a exception error when I complie my code.
The error is:
- imageData 0x00000000 <Bad Ptr>
type unsigned char *
I think it is from when I declare some of my char variables
|
by: yabansu |
last post by:
Hi,
I just want to know if there is a way of converting a string variable into a const unsigned char pointer. Alternatively, I expect a blabla() function as the following:
string str = "Hello";
const unsigned char* ptr = blabla(str);
Thanks...
yabansu
|
by: Yevgen Muntyan |
last post by:
Hey,
Why is it legal to do
union U {unsigned char u; int a;};
union U u;
u.a = 1;
u.u;
I tried to find it in the standard, but I only found that
|
by: edsunder |
last post by:
I'm making a "wrapper" for an unmanaged DLL (written, I'm fairly certain in C). I have a c++ "wrapper" that I'm trying to convert to VB.net. I've got most of the program working, but I've hit a brick wall.
I'm trying to convert the following two structures from their c++ versions to their vb.net versions. I cannot be sure which is the problem because both must be passed at the same time. The error I am getting is thrown by the object and...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |