Jump to content

  • Log In with Google      Sign In   
  • Create Account

Brother Bob

Member Since 26 Nov 2001
Online Last Active Today, 02:31 PM

#5045229 explaining arm neon code

Posted by Brother Bob on 21 March 2013 - 06:32 AM

From what I can decipher, it processed 8 consecutive 3x3 blocks per iteration. Therefore, you move left by 8x3=24 bytes, the width of 8 blocks, per column-iteration, and down 3 rows, or 3x width bytes, per row-iteration.




#5045216 explaining arm neon code

Posted by Brother Bob on 21 March 2013 - 05:52 AM

Let's just take a small image with some sensible numbers. Here's a 10x10 image, and the numbers represents the indices into that image.

 

     0     1     2     3     4     5     6     7     8     9
    10    11    12    13    14    15    16    17    18    19
    20    21    22    23    24    25    26    27    28    29
    30    31    32    33    34    35    36    37    38    39
    40    41    42    43    44    45    46    47    48    49
    50    51    52    53    54    55    56    57    58    59
    60    61    62    63    64    65    66    67    68    69
    70    71    72    73    74    75    76    77    78    79
    80    81    82    83    84    85    86    87    88    89
    90    91    92    93    94    95    96    97    98    99

In this case, width=10 and height=10. As you can see, no matter which pixel you are at, if you add width to its index, you get to the next pixel below it. Similarly, if you subtract width from any index, you get to the pixel above it.

 

Take the pixel at coordinate (5, 4) which has the index 45. If you want to go down one pixel to the coordinate (5, 5), you add 10 to 45 and you get to index 55, which is the index at coordinate (5, 5). If you thus have a pointer p=&image[45], then p[width] references the pixel width units from p, and thus reaching the pixel below it.




#5044053 Vector MADNESS

Posted by Brother Bob on 17 March 2013 - 03:52 PM

Use std::vector::back().

MatStack.back() * differentMatrix



#5042521 [Solved] Difference between GL_ARRAY_BUFFER and GL_ARRAY_BUFFER_ARB?

Posted by Brother Bob on 12 March 2013 - 06:21 PM

One constant belongs to the core API, and one belongs to an extension due to the ARB-suffix. They are probably defined to the same value, but that does not mean that you should mix them. If you're using the vertex buffer functions from the core API, then you should use the standard constant. If you're using the ARB-variant of the vertex buffer object extension, then you should use the one with the ARB-suffix.




#5041626 Cross Product of Many Vectors

Posted by Brother Bob on 10 March 2013 - 04:35 PM

On a second thought, the derivation of an optimal solution could have been much easier, so I'll just throw in another point of view just for the sake of it.

 

Given the notations from my last post, treat vn as a sample of a three-dimensional random process. Its distribution is dictated by the covariance matrix C and can be estimated by C=V*VT. You want to find the direction of least energy of the distribution, which is the direction that is perpendicular to the plane where the random samples are located. As in my previous solution, that is the eigenvector of V*VT with the smallest eigenvalue.




#5041528 Vertex Arrays

Posted by Brother Bob on 10 March 2013 - 09:13 AM

If vertices is an object of type std::vector, then &vertices is a pointer to the std::vector object and not the data the std::vector stores. To get the pointer to the data, you need to use &vertices[0], or, if you're on a C++11 compiler, vertices.data(). Same with the color array, of course.




#5041306 openGL app not working outside of visual studio.

Posted by Brother Bob on 09 March 2013 - 05:27 PM

You have a broken pointer somewhere in your code. I think that one in particular is related to freeing a pointer; you're trying to free a pointer that doesn't have a valid value, for example double deleting a pointer, or deleting an uninitialized pointer.




#5039105 "const wchar_t" is incompatible with parameter of type "LPCSTR"

Posted by Brother Bob on 04 March 2013 - 12:38 PM

Sounds like your program simply isn't consistent with what character set it uses. Proper text handling of almost any kind is not trivial as soon as different encodings comes into play. It seems like your code consists of a mix of narrow and wide characters/strings, and mixing text encodings can be a real problem.

 

Decide on one single encoding for your entire program, and stick with it everywhere. If you need to handle text in different encodings, then make helper functions that converts text between the proper encoding and your program's encoding. But ultimately, your core program should not handle more than one encoding.




#5039088 "const wchar_t" is incompatible with parameter of type "LPCSTR"

Posted by Brother Bob on 04 March 2013 - 11:34 AM

Select Properties in the Project menu. Then, under Configuration Properties and General, change the parameter Character Set to Use Unicode Character Set.




#5038404 Basic question

Posted by Brother Bob on 02 March 2013 - 06:41 AM

Store the words in a map of <string, int>. the first time you insert a word, store 1. If the word is already in the map, increment the integer.

It's even easier that that, because you don't even need special logic to handle the first insert. The map value constructs its content if the key is not present, and integers value initializes to zero, so just go ahead and increment at all times. Thus, just use the [] operator and increment it; if the key doesn't exist it is value initialized to zero before proceeding to increment it to one and everything is fine.




#5038380 passing 2D array to struct

Posted by Brother Bob on 02 March 2013 - 05:39 AM

Declare your filenames field as follows:

struct myStruct {
    char (*filenames)[48];
};



#5036477 What is the purpose of std::array?

Posted by Brother Bob on 25 February 2013 - 04:04 PM

Try passing int a[10] to a function and getting its size wink.png
 
You can do something like this:

template <typename T>
void printAll(const T& v)
{
    for (auto& value : v)
        std::cout << value << std::endl;
}
 
// You can call the above function with std::vector, std::array, etc., but not with int a[10]!
Edit: Also, check out this article

You may want to reconsider that example. The array is passed by reference and for for-each statement works with array types, so you can in fact pass an array and have it print all its values.




#5036392 Matrix inversion

Posted by Brother Bob on 25 February 2013 - 12:13 PM

Your matrix is very badly conditioned and will be extremely sensitive to numerical errors. If you want the same results as Matlab, then you're simply going to have to do the same calculations as Matlab.

 

As far as I remember, the Gauss-Jordan method is one of the worst general matrix inversion algorithms when it comes to numerical precision. You really need to feed it well-conditioned matrices for it to work.




#5035360 Searching closest color using manhattan distance on RGB

Posted by Brother Bob on 22 February 2013 - 05:16 AM

The solution is the surface of a symmetric diamond-shape centered at the origin with size d. Have two nested for-loops for the first two coordinates, let's call them A, and B, and solve A+B+C=d for the third coordinate C. That will give you the points on the diamond-shaped solution for one octant in 3D-space. Then apply all eight negation permutations to obtain the points for the remaining octants.

for(int A=0; A<=d; ++A)
    for(int B=0; B<=d-A; ++B)
        add solution ( A,  B,  d-A-B)
        add solution ( A,  B, -d-A-B)
        add solution ( A, -B,  d-A-B)
        add solution ( A, -B, -d-A-B)
        add solution (-A,  B,  d-A-B)
        add solution (-A,  B, -d-A-B)
        add solution (-A, -B,  d-A-B)
        add solution (-A, -B, -d-A-B)

Hope I got the math correct here, it may be off by one somewhere. You may also need to adjust the loops to eliminate duplicates at the end of the loop ranges, since, for example, A=-A when A=0 and so half the points will be the same for that iteration.




#5034743 glreadpixels don't work

Posted by Brother Bob on 20 February 2013 - 04:04 PM

Thanks for your reply.

I don't need to specify the size of the cvMat.The default constructor allocates enough space.

I will set the manification filter. Don't you see any other problem ?

I don't see anything obvious, no.

I write to write glreadpixels to a file, it only writes when it is specified as GLRGBA, and doesnt work with GLRGB...

Is the shader is a problem ? Should I disable it before glreadpixesl ?

The shaders do not affect glReadPixels.






PARTNERS